Ejemplo n.º 1
0
        private void ScriptingDefineGUI()
        {
            GUILayout.BeginVertical("Box");

            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            _showScriptingDefine = EditorGUILayout.Foldout(_showScriptingDefine, "Scripting Define", true);
            GUILayout.EndHorizontal();

            if (_showScriptingDefine)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Defined");
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.TextField(_currentScriptingDefine.Defined);
                GUI.enabled = _currentScriptingDefine.IsAnyDefined;
                if (GUILayout.Button("Clear", "Minibutton", GUILayout.Width(40)))
                {
                    _currentScriptingDefine.ClearDefines();
                }
                GUI.enabled = true;
                if (GUILayout.Button("New", "Minibutton", GUILayout.Width(40)))
                {
                    _isNewDefine = !_isNewDefine;
                    _newDefine   = "";
                }
                if (GUILayout.Button("Apply", "Minibutton", GUILayout.Width(45)))
                {
                    _currentScriptingDefine.Apply();
                }
                GUILayout.EndHorizontal();

                if (_isNewDefine)
                {
                    GUILayout.BeginHorizontal();
                    _newDefine = EditorGUILayout.TextField(_newDefine);
                    if (GUILayout.Button("OK", "Minibutton", GUILayout.Width(30)))
                    {
                        if (_newDefine != "")
                        {
                            _currentScriptingDefine.AddDefine(_newDefine);
                            _isNewDefine = false;
                            _newDefine   = "";
                        }
                        else
                        {
                            GlobalTools.LogError("输入的宏定义不能为空!");
                        }
                    }
                    if (GUILayout.Button("NO", "Minibutton", GUILayout.Width(30)))
                    {
                        _isNewDefine = false;
                        _newDefine   = "";
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Historical record");
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Clear record", "Minibutton", GUILayout.Width(80)))
                    {
                        _currentScriptingDefine.ClearDefinesRecord();
                    }
                    GUILayout.EndHorizontal();

                    for (int i = 0; i < _currentScriptingDefine.DefinedsRecord.Count; i++)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        GUILayout.Label(_currentScriptingDefine.DefinedsRecord[i], "PR PrefabLabel");
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Use", "Minibutton", GUILayout.Width(30)))
                        {
                            _newDefine += _currentScriptingDefine.DefinedsRecord[i] + ";";
                        }
                        GUILayout.EndHorizontal();
                    }
                }
            }

            GUILayout.EndVertical();
        }
Ejemplo n.º 2
0
        private void ScriptingDefineGUI()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Defined");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUILayout.TextField(_currentScriptingDefine.Defined);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUI.enabled         = _currentScriptingDefine.IsAnyDefined;
            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Clear", EditorStyles.miniButtonLeft))
            {
                _currentScriptingDefine.ClearDefines();
            }
            GUI.enabled         = true;
            GUI.backgroundColor = Color.yellow;
            if (GUILayout.Button("New", EditorStyles.miniButtonMid))
            {
                _isNewDefine = !_isNewDefine;
                _newDefine   = "";
            }
            if (GUILayout.Button("Apply", EditorStyles.miniButtonRight))
            {
                _currentScriptingDefine.Apply();
            }
            GUI.backgroundColor = Color.white;
            GUILayout.EndHorizontal();

            if (_isNewDefine)
            {
                GUILayout.BeginHorizontal();
                _newDefine = EditorGUILayout.TextField(_newDefine);
                if (GUILayout.Button("OK", EditorStyles.miniButtonLeft, GUILayout.Width(30)))
                {
                    if (_newDefine != "")
                    {
                        _currentScriptingDefine.AddDefine(_newDefine);
                        _isNewDefine = false;
                        _newDefine   = "";
                    }
                    else
                    {
                        Log.Error("输入的宏定义不能为空!");
                    }
                }
                if (GUILayout.Button("NO", EditorStyles.miniButtonRight, GUILayout.Width(30)))
                {
                    _isNewDefine = false;
                    _newDefine   = "";
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Historical record");
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Clear record", EditorStyles.miniButton, GUILayout.Width(80)))
                {
                    _currentScriptingDefine.ClearDefinesRecord();
                }
                GUILayout.EndHorizontal();

                for (int i = 0; i < _currentScriptingDefine.DefinedsRecord.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);
                    GUILayout.Label(_currentScriptingDefine.DefinedsRecord[i], "PR PrefabLabel");
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Use", EditorStyles.miniButton, GUILayout.Width(30)))
                    {
                        _newDefine += _currentScriptingDefine.DefinedsRecord[i] + ";";
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }