Exemple #1
0
    private void _ExtractProperties()
    {
        properties.Clear();
        propertyTable.Clear();

        Object targetObject;

        if (proxy != null)
        {
            mySerializedObject = new SerializedObject(proxy);
            targetObject       = proxy;
        }
        else if (serializedObject != null)
        {
            mySerializedObject = serializedObject;
            targetObject       = target;
        }
        else
        {
            return;
        }

        FieldInfo[] fields = targetObject.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
        foreach (FieldInfo field in fields)
        {
            if ((field.Attributes & (FieldAttributes.NotSerialized | FieldAttributes.Static)) == 0)
            {
                if (!field.IsPublic)
                {
                    object[] serialize = field.GetCustomAttributes(typeof(SerializeField), true);
                    if (serialize == null || serialize.Length <= 0)
                    {
                        continue;
                    }
                }

                object[] hide = field.GetCustomAttributes(typeof(HideInInspector), true);
                if (hide != null && hide.Length > 0)
                {
                    continue;
                }

                SerializedProperty dependentProperty = null;
                SECTR_ToolTip      toolTip           = null;
                object[]           tooltips          = field.GetCustomAttributes(typeof(SECTR_ToolTip), true);
                if (tooltips.Length > 0)
                {
                    toolTip = ((SECTR_ToolTip)tooltips[0]);
                    if (!string.IsNullOrEmpty(toolTip.DependentProperty))
                    {
                        dependentProperty = mySerializedObject.FindProperty(toolTip.DependentProperty);
                    }
                }
                PropertyData newProperty = new PropertyData(field.FieldType, mySerializedObject.FindProperty(field.Name), dependentProperty, toolTip);
                properties.Add(newProperty);
                propertyTable.Add(field.Name, newProperty);
            }
        }
    }
Exemple #2
0
 public PropertyData(System.Type propertyType, SerializedProperty property, SerializedProperty dependentProperty, SECTR_ToolTip toolTip)
 {
     this.propertyType      = propertyType;
     this.property          = property;
     this.dependentProperty = dependentProperty;
     // Fancy reg-ex to insert spaces between lower and upper case letters while preserving acronyms.
     this.niceName = ObjectNames.NicifyVariableName(property.name);
     this.niceName = char.ToUpper(this.niceName[0]) + this.niceName.Substring(1);
     if (toolTip != null)
     {
         this.toolTip = toolTip;
     }
     else
     {
         this.toolTip = new SECTR_ToolTip(null);
     }
 }