/// <inheritdoc/> protected internal override object GetValue(int seqIndex) { SerializableArray serzArray = property.GetArray(); // Create a property wrapper for native arrays so we get notified when the array values change if (style.StyleFlags.HasFlag(InspectableFieldStyleFlags.NativeWrapper)) { SerializableProperty.Getter getter = () => { Array array = property.GetValue <Array>(); if (array != null) { return(array.GetValue(seqIndex)); } else { return(null); } }; SerializableProperty.Setter setter = (object value) => { Array array = property.GetValue <Array>(); if (array != null) { array.SetValue(value, seqIndex); property.SetValue(array); } }; return(new SerializableProperty(serzArray.ElementPropertyType, serzArray.ElementType, getter, setter)); } else { return(serzArray.GetProperty(seqIndex)); } }
/// <summary> /// Registers a new row in the layout for the provided property. The type of row is determined by the property type. /// </summary> /// <param name="parent">Parent foldout row to which to append the new elements.</param> /// <param name="name">Name of the field the property belongs to.</param> /// <param name="path">Slash separated path to the field from its parent object.</param> /// <param name="property">Property to create the row for.</param> /// <param name="element">Element containing data for the newly created row. Only valid if method returns true. /// </param> /// <returns>Returns true if the row was successfully added, false otherwise.</returns> private bool AddPropertyRow(Element parent, string name, string path, SerializableProperty property, out Element element) { switch (property.Type) { case SerializableProperty.FieldType.Bool: case SerializableProperty.FieldType.Float: case SerializableProperty.FieldType.Int: case SerializableProperty.FieldType.Color: case SerializableProperty.FieldType.Vector2: case SerializableProperty.FieldType.Vector3: case SerializableProperty.FieldType.Vector4: element = AddFieldRow(parent.childLayout, name, parent.so, parent.comp, path, property.Type); return true; case SerializableProperty.FieldType.Object: { Action<Element, bool> toggleCallback = (toggleParent, expand) => { SerializableObject childObject = new SerializableObject(property.InternalType, null); ToggleObjectFoldout(toggleParent, childObject, expand); }; element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback); } return true; case SerializableProperty.FieldType.Array: { Action<Element, bool> toggleCallback = (toggleParent, expand) => { SerializableArray childObject = property.GetArray(); if (childObject != null) ToggleArrayFoldout(toggleParent, childObject, expand); }; element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback); } return true; case SerializableProperty.FieldType.List: { Action<Element, bool> toggleCallback = (toggleParent, expand) => { SerializableList childObject = property.GetList(); if (childObject != null) ToggleListFoldout(toggleParent, childObject, expand); }; element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback); } return true; } element = new Element(); return false; }
/// <summary> /// Registers a new row in the layout for the provided property. The type of row is determined by the property type. /// </summary> /// <param name="parent">Parent foldout row to which to append the new elements.</param> /// <param name="name">Name of the field the property belongs to.</param> /// <param name="path">Slash separated path to the field from its parent object.</param> /// <param name="property">Property to create the row for.</param> /// <param name="element">Element containing data for the newly created row. Only valid if method returns true. /// </param> /// <returns>Returns true if the row was successfully added, false otherwise.</returns> private bool AddPropertyRow(Element parent, string name, string path, SerializableProperty property, out Element element) { switch (property.Type) { case SerializableProperty.FieldType.Bool: case SerializableProperty.FieldType.Float: case SerializableProperty.FieldType.Int: case SerializableProperty.FieldType.Color: case SerializableProperty.FieldType.Vector2: case SerializableProperty.FieldType.Vector3: case SerializableProperty.FieldType.Vector4: element = AddFieldRow(parent.childLayout, name, parent.so, parent.comp, path, property.Type); return(true); case SerializableProperty.FieldType.Object: { Action <Element, bool> toggleCallback = (toggleParent, expand) => { SerializableObject childObject = new SerializableObject(property.InternalType, null); ToggleObjectFoldout(toggleParent, childObject, expand); }; element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback); } return(true); case SerializableProperty.FieldType.Array: { Action <Element, bool> toggleCallback = (toggleParent, expand) => { SerializableArray childObject = property.GetArray(); if (childObject != null) { ToggleArrayFoldout(toggleParent, childObject, expand); } }; element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback); } return(true); case SerializableProperty.FieldType.List: { Action <Element, bool> toggleCallback = (toggleParent, expand) => { SerializableList childObject = property.GetList(); if (childObject != null) { ToggleListFoldout(toggleParent, childObject, expand); } }; element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback); } return(true); } element = new Element(); return(false); }
/// <inheritdoc/> protected internal override object GetValue(int seqIndex) { SerializableArray array = property.GetArray(); return(array.GetProperty(seqIndex)); }