示例#1
0
 public void AddField(CoherentUIGTPropertyField f)
 {
     m_Fields.Add(f);
 }
示例#2
0
    public static CoherentUIGTFoldout[] GetProperties(System.Object obj)
    {
        CoherentUIGTFoldout[] foldouts = new CoherentUIGTFoldout[(int)CoherentUIGTExposePropertyInfo.FoldoutType.Count];

        PropertyInfo[] infos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

        foreach (PropertyInfo info in infos)
        {
            if (!(info.CanRead && info.CanWrite))
            {
                continue;
            }

            object[] attributes = info.GetCustomAttributes(true);

            bool   isExposed     = false;
            object infoAttribute = null;

            foreach (object o in attributes)
            {
                var t = o.GetType();
                if (t == typeof(CoherentUIGTExposePropertyAttribute) ||
                    (t == typeof(CoherentUIGTExposePropertyStandaloneAttribute) &&
                     IsStandaloneTarget()) ||
                    (t == typeof(CoherentUIGTExposePropertyMobileAttribute) &&
                     IsMobileTarget()))
                {
                    infoAttribute = o;
                    isExposed     = true;
                    break;
                }
            }

            if (!isExposed)
            {
                continue;
            }

            SerializedPropertyType type = SerializedPropertyType.Integer;

            if (CoherentUIGTPropertyField.GetPropertyType(info, out type))
            {
                CoherentUIGTPropertyField field = new CoherentUIGTPropertyField(obj, info, type, infoAttribute);

                var category = CoherentUIGTExposePropertyInfo.FoldoutType.General;
                var attr     = infoAttribute as CoherentUIGTExposePropertyInfo;
                if (attr != null)
                {
                    category = attr.Category;
                }

                if (foldouts[(int)category] == null)
                {
                    foldouts[(int)category] = new CoherentUIGTFoldout(category);
                }
                foldouts[(int)category].AddField(field);
            }
        }

        return(foldouts);
    }