public bool ApplyModifiedProperties() { if (!changed) { return(false); } changed = false; if (isCircular) { return(circularRef.ApplyModifiedProperties()); } Type fieldType = value == null ? type : value.GetType(); for (int i = 0; i < children.Count; i++) { SerializedPropertyX child = children[i]; child.ApplyModifiedProperties(); if (IsArrayLike) { IList list = value as IList; list[i] = child.Value; } else { fieldType.GetField(child.name, BindFlags).SetValue(value, child.Value); } } return(true); }
public void ApplyModifiedProperties(SerializedPropertyX parent) { Type fieldType = value == null ? type : value.GetType(); if (value == null) { value = CreateValue(type); } if (value == null) { return; } for (int i = 0; i < children.Count; i++) { SerializedPropertyX child = children[i]; child.ApplyModifiedProperties(this); if (IsArrayLike) { IList list = value as IList; list[i] = child.Value; } else { fieldType.GetField(child.name, BindFlags).SetValue(value, child.Value); } } }
public void ChangedIsClearedWhenApplyingModifiedProperties() { TestThingSerialized thing = new TestThingSerialized(); SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThingSerialized), thing); property.Value = new TestThingSerialized(); Assert.IsTrue(property.Changed); property.ApplyModifiedProperties(); Assert.IsFalse(property.Changed); }
public void ApplyModifiedProperties() { Type type = root.GetType(); for (int i = 0; i < rootProperty.ChildCount; i++) { SerializedPropertyX property = rootProperty.GetChildAt(i); property.ApplyModifiedProperties(rootProperty); type.GetField(property.name, BindFlags).SetValue(root, property.Value); } }
private void CalculateButton(SerializedPropertyX property) { property.ApplyModifiedProperties(); property.Update(); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Calculate Formula", GUILayout.Width(150))) { DamageFormula d = property.GetValue <DamageFormula>(); d.OnUse(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
public bool ApplyModifiedProperties() { Type type = root.GetType(); bool changed = false; for (int i = 0; i < rootProperty.ChildCount; i++) { SerializedPropertyX property = rootProperty.GetChildAt(i); bool didChildChange = property.ApplyModifiedProperties(); if (!changed && didChildChange) { changed = true; } type.GetField(property.name, BindFlags).SetValue(root, property.Value); } return(changed); }