コード例 #1
0
 public static lhDefineManager GetInstance()
 {
     if (m_instance != null)
     {
         return(null);
     }
     return(m_instance = new lhDefineManager());
 }
コード例 #2
0
 public void Dispose()
 {
     m_instance = null;
 }
コード例 #3
0
        void OnGUI()
        {
            if (EditorApplication.isCompiling)
            {
                GUILayout.Label("loading....");
                return;
            }
            if (!m_initialize)
            {
                m_defineManager = lhDefineManager.GetInstance();
                m_initialize    = true;
                lhDefineManager.Apply();
            }
            EditorGUILayout.BeginVertical();
            {
                Rect item = EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                {
                    GUIContent createContent = new GUIContent("Create");
                    Rect       createRect    = GUILayoutUtility.GetRect(createContent, EditorStyles.toolbarButton);
                    if (GUI.Button(createRect, createContent, EditorStyles.toolbarButton))
                    {
                        lhDefineManager.CreateDefine();
                    }
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Apply", EditorStyles.toolbarButton))
                    {
                        if (EditorUtility.DisplayDialog("Warning", "Are you sure Apply?", "Ok", "Cancel"))
                        {
                            lhDefineManager.Apply();
                        }
                    }
                } EditorGUILayout.EndHorizontal();
                GUI.SetNextControlName("ScrollPosition");
                m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition);
                {
                    foreach (var define in lhDefineManager.defineList)
                    {
                        Rect itemRect = EditorGUILayout.BeginHorizontal();
                        {
                            define.active = GUILayout.Toggle(define.active, "");
                            if (define.renaming)
                            {
                                GUIContent cancelContent = new GUIContent("×");
                                if (GUI.Button(GUILayoutUtility.GetRect(cancelContent, EditorStyles.miniButton, GUILayout.ExpandWidth(false)), cancelContent))
                                {
                                    define.renaming = false;
                                    GUI.FocusControl("ScrollPosition");
                                }
                                GUIContent certainContent = new GUIContent("√");
                                if (GUI.Button(GUILayoutUtility.GetRect(certainContent, EditorStyles.miniButton, GUILayout.ExpandWidth(false)), certainContent))
                                {
                                    define.renaming   = false;
                                    define.defineName = define.oldDefineName;
                                }
                                define.oldDefineName = EditorGUILayout.TextField(define.oldDefineName);
                            }
                            else
                            {
                                GUILayout.Label(define.defineName);
                            }
                            GUILayout.FlexibleSpace();
                            define.targetGroupValue = EditorGUILayout.MaskField(define.targetGroupValue, System.Enum.GetNames(typeof(lhDefineManager.DefineTargetGroup)), EditorStyles.layerMaskField);
                            //Debug.Log(define.targetGroupValue);
                            if (GUILayout.Button("X", EditorStyles.miniLabel))
                            {
                                if (EditorUtility.DisplayDialog("Warning", "Are you sure delete it", "Ok", "Cancel"))
                                {
                                    lhDefineManager.DeleteDefine(define);
                                    return;
                                }
                            }
                        } EditorGUILayout.EndHorizontal();

                        if (IsMouseOn(itemRect))
                        {
                            if (Event.current.keyCode == KeyCode.F2)
                            {
                                define.renaming      = true;
                                define.oldDefineName = define.defineName;
                                Repaint();
                            }
                            if (Event.current.keyCode == KeyCode.Return)
                            {
                                define.renaming   = false;
                                define.defineName = define.oldDefineName;
                                Repaint();
                            }
                        }
                    }
                } EditorGUILayout.EndScrollView();
            } EditorGUILayout.EndVertical();
        }