Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    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);
            }
        }
    }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
    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);
        }
    }
Exemplo n.º 5
0
    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();
    }
Exemplo n.º 6
0
    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);
    }