Пример #1
0
        /// <summary>
        /// draw list element
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="index"></param>
        /// <param name="isactive"></param>
        /// <param name="isfocused"></param>
        private void OnDrawElementVariables(Rect rect, int index, bool isactive, bool isfocused)
        {
            SavableVariable saveVar    = settingObject.Data[index];
            IListItemDrawer itemDrawer = (IListItemDrawer)settingObject.Data[index];


            EditorGUI.BeginChangeCheck();

            if (itemDrawer != null)
            {
                itemDrawer.OnDrawElement(rect, line_height);
            }
            else if (saveVar != null)
            {
                GUI.Label(new Rect(new Vector2(rect.position.x, rect.position.y + line_height), new Vector2(rect.width, line_height)), saveVar.ToString());
            }
            else
            {
                saveVar = (SavableVariable)EditorGUI.ObjectField(
                    new Rect(rect.position, new Vector2(rect.width, line_height)),
                    saveVar, typeof(SavableVariable), false);
            }
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(saveVar);
                SaveChanges();
            }
        }
Пример #2
0
 private void FindVariables()
 {
     string[] ass = AssetDatabase.FindAssets("t:SavableVariable");
     foreach (string a in ass)
     {
         if (AssetDatabase.GUIDToAssetPath(a).Contains("/" + settingObject.name + "/"))
         {
             SavableVariable sv = (SavableVariable)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(a), typeof(SavableVariable));
             if (!settingObject.Data.Contains(sv))
             {
                 settingObject.Data.Add(sv);
             }
         }
     }
     EditorUtility.SetDirty(settingObject);
 }