示例#1
0
 public static void Load()
 {
     if (infos == null)
     {
         infos = new List <KeyColInfo>();
         //List<string> fs = new List<string>();
         foreach (var assembly in TreeDomain.workAssemblies)
         {
             foreach (var item in assembly.GetTypes())
             {
                 var kc = item.GetCustomAttribute <KeyCollection>();
                 if (kc != null)
                 {
                     KeyColInfo info = new KeyColInfo();
                     info.typeName = item.FullName;
                     //fs.Add(info.typeName);
                     foreach (var field in item.GetFields(BindingFlags.Static | BindingFlags.Public))
                     {
                         info.fieldNames.Add(field.Name);
                         info.fieldValues.Add((string)field.GetValue(null));
                     }
                     infos.Add(info);
                 }
             }
         }
     }
 }
示例#2
0
        private void OnEnable()
        {
            KeyColInfo.Load();
            infos = KeyColInfo.infos;
            if (fields == null)
            {
                List <string> fs = new List <string>();
                for (int i = 0; i < infos.Count; i++)
                {
                    fs.Add(infos[i].typeName);
                }
                fields = fs.ToArray();
            }
            var tar = target as KeyPdr;

            for (int i = 0; i < infos.Count; i++)
            {
                var info = infos[i];
                if (info.typeName == tar.selectType)
                {
                    selectType = i;
                    for (int j = 0; j < info.fieldNames.Count; j++)
                    {
                        if (info.fieldNames[j] == tar.selectField)
                        {
                            selectField = j;
                            break;
                        }
                    }
                    break;
                }
            }
        }
示例#3
0
        void DrawInfo(KeyPdr pdr)
        {
            int _selectType  = EditorHelper.Popup(selectType, fields, "Select Collection");
            int _selectField = selectField;

            if (_selectType >= 0)
            {
                KeyColInfo info = infos[_selectType];
                pdr.selectType = info.typeName;
                _selectField   = EditorHelper.Popup(selectField, info.fieldNames.ToArray(), "Select Key");
                if (_selectField >= 0)
                {
                    pdr.selectField = info.fieldNames[_selectField];
                    pdr.value.value = info.fieldValues[_selectField];
                    pdr.name        = pdr.value.value;
                    //Debug.Log(pdr.value.value);
                }
            }
            if (_selectType != selectType || _selectField != selectField)
            {
                UnityEditor.EditorUtility.SetDirty(pdr);
            }
            selectType  = _selectType;
            selectField = _selectField;
        }