| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using BansheeEngine;
- namespace BansheeEditor
- {
- public class InspectableObject : InspectableObjectBase
- {
- private const int IndentAmount = 15;
- private object oldPropertyValue;
- private GUILabel guiLabel;
- private GUILayout guiChildLayout;
- private GUILayoutY guiContentLayout;
- private bool isInitialized;
- public InspectableObject(string title, InspectableFieldLayout layout, SerializableProperty property)
- : base(title, layout, property)
- {
-
- }
- protected void Initialize(int layoutIndex)
- {
- if (property.Type != SerializableProperty.FieldType.Object)
- return;
- guiLabel = new GUILabel(title);
- layout.AddElement(layoutIndex, guiLabel);
- guiChildLayout = layout.AddLayoutX(layoutIndex);
- guiChildLayout.AddSpace(IndentAmount);
- guiContentLayout = guiChildLayout.AddLayoutY();
- SerializableObject serializableObject = property.GetObject();
- foreach (var field in serializableObject.fields)
- {
- if (!field.Inspectable)
- continue;
- if (field.HasCustomInspector)
- AddChild(CreateCustomInspectable(field.CustomInspectorType, field.Name, new InspectableFieldLayout(guiContentLayout), field.GetProperty()));
- else
- AddChild(CreateDefaultInspectable(field.Name, new InspectableFieldLayout(guiContentLayout), field.GetProperty()));
- }
- isInitialized = true;
- }
- protected override bool IsModified()
- {
- if (!isInitialized)
- return true;
- object newPropertyValue = property.GetValue<object>();
- if (oldPropertyValue != newPropertyValue)
- {
- oldPropertyValue = newPropertyValue;
- return true;
- }
- return base.IsModified();
- }
- protected override void Update(int index)
- {
- base.Update(index);
- if (!isInitialized)
- Initialize(index);
- // TODO - Update GUI element(s) with value from property
- }
- }
- }
|