| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BansheeEngine;
- namespace BansheeEditor
- {
- public class InspectableInt : InspectableObjectBase
- {
- private int oldPropertyValue;
- private GUILabel guiLabel;
- private bool isInitialized = false;
- public InspectableInt(string title, SerializableProperty property)
- :base(title, property)
- {
- }
- protected void Initialize(GUILayout layout)
- {
- if(property.Type == SerializableProperty.FieldType.Int)
- {
- guiLabel = new GUILabel(title);
- layout.AddElement(guiLabel); // TODO - Use an IntEditorField
- }
- isInitialized = true;
- }
- protected override bool IsModified()
- {
- if (!isInitialized)
- return true;
- int newPropertyValue = property.GetValue<int>();
- if (oldPropertyValue != newPropertyValue)
- {
- oldPropertyValue = newPropertyValue;
- return true;
- }
- return base.IsModified();
- }
- protected override void Update(GUILayout layout)
- {
- base.Update(layout);
- if (!isInitialized)
- Initialize(layout);
- // TODO - Update GUI element(s) with value from property
- }
- public override void Destroy()
- {
- if (guiLabel != null)
- guiLabel.Destroy();
- base.Destroy();
- }
- }
- }
|