public object DrawAndGetNewValue(Type type, string fieldName, object value, Entity entity, int index, IComponent component) { var myObject = (CustomObject)value; var fieldType = myObject.GetType().GetField("name").FieldType; EntityInspector.DrawAndSetElement(fieldType, "customObject.name", myObject.name, entity, index, component, newValue => myObject.name = (string)newValue); return(myObject); }
/// <summary> /// Creates and positions a new inspector control for the passed property. /// </summary> /// <param name="inspectorProperty">Property to create an inspector control for.</param> /// <param name="currentValue">Current value of the observed property.</param> /// <param name="valueInherited">Indicates if the current value was inherited.</param> public IInspectorControl CreateInspectorControlFor( InspectorPropertyAttribute inspectorProperty, object currentValue, bool valueInherited) { // Create inspector control. IInspectorControl inspectorControl; if (inspectorProperty.IsList) { inspectorControl = new ListInspector(); } else if (inspectorProperty is InspectorBoolAttribute) { inspectorControl = new CheckBoxInspector(); } else if (inspectorProperty is InspectorStringAttribute) { inspectorControl = new TextBoxInspector(); } else if (inspectorProperty is InspectorFloatAttribute) { inspectorControl = new SingleUpDownInspector(); } else if (inspectorProperty is InspectorIntAttribute) { inspectorControl = new IntegerUpDownInspector(); } else if (inspectorProperty is InspectorEnumAttribute) { inspectorControl = new ComboBoxInspector(); } else if (inspectorProperty is InspectorBlueprintAttribute) { inspectorControl = null; } else if (inspectorProperty is InspectorDataAttribute) { inspectorControl = new DataInspector(); } else if (inspectorProperty is InspectorEntityAttribute) { inspectorControl = new EntityInspector(); } else { inspectorControl = null; } // Setup control. if (inspectorControl != null) { inspectorControl.Init(inspectorProperty, this.editorContext, this.localizationContext, currentValue, valueInherited); } return(inspectorControl); }