Exemple #1
0
            public void OnBeforeSerialize()
            {
                serializableObject.SetValueOfType(type, value);

                if (protoProperty != null)
                {
                    protoPropertyOwner = protoProperty.Owner;
                }
            }
Exemple #2
0
            public static Property FromField(FieldInfo field, DataPrototype propertyOwner)
            {
                var property = new Property()
                {
                    Owner = propertyOwner,
                    Name  = field.Name,
                    Value = field.GetValue(propertyOwner),
                    DelegatesToPrototype = false,
                    ProtoProperty        = null,
                    Type = field.FieldType,
                };

                return(property);
            }
    private static void QueryPropertyUserInput(DataPrototype.Property property, DataPrototype data)
    {
        var input = GetUnityEditorPropertyInputFieldValue(property);

        if(property.DelegatesToPrototype)
            property.ProtoProperty = GetProtoPropertyUserInput(property, data);
        else
            property.Value = input;

        property.DelegatesToPrototype = GetPrototypeDelegationUserInput(property);
    }
 private static bool GetPrototypeDelegationUserInput(DataPrototype.Property property)
 {
     GUI.enabled = true;
     return EditorGUILayout.Toggle(property.DelegatesToPrototype, GUILayout.Width(PROTOTYPE_DELEGATION_TOGGLE_WIDTH));
 }
 private static object GetUnityEditorPropertyInputFieldValue(DataPrototype.Property property)
 {
     GUI.enabled = !property.DelegatesToPrototype;
     return property.Type.GetUnityEditorInputFieldValue(property.Value);
 }
    private static DataPrototype.Property GetProtoPropertyUserInput(DataPrototype.Property property, DataPrototype data)
    {
        GUI.enabled = property.DelegatesToPrototype;

        var currentProtoPropertyOwner = property.ProtoProperty == null ? null : property.ProtoProperty.Owner;
        var protoPropertyOwner = (DataPrototype) EditorGUILayout.ObjectField(currentProtoPropertyOwner, data.GetType(), true);

        if(protoPropertyOwner != null)
            return protoPropertyOwner.GetProperty(property.Name);

        return null;
    }
    private static void DrawPropertyUserInput(DataPrototype.Property property, DataPrototype data)
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel(property.Name);

        if(DoesInputFieldExistForProperty(property))
            QueryPropertyUserInput(property, data);

        EditorGUILayout.EndHorizontal();
    }
 private static bool DoesInputFieldExistForProperty(DataPrototype.Property property)
 {
     return property.Type.IsSubtypeOrEqualToOneOf(VALID_PROPERTY_TYPES);
 }
            public void OnBeforeSerialize() {
                serializableObject.SetValueOfType(type, value);

                if(protoProperty != null)
                    protoPropertyOwner = protoProperty.Owner;
            }
 public static Property FromField(FieldInfo field, DataPrototype propertyOwner) {
     var property = new Property() {
         Owner = propertyOwner,
         Name = field.Name,
         Value = field.GetValue(propertyOwner),
         DelegatesToPrototype = false,
         ProtoProperty = null,
         Type = field.FieldType,
     };
     return property;
 }