void Initialize()
    {
        textStyle           = new GUIStyle();
        textStyle.alignment = TextAnchor.UpperCenter;

        bigTextStyle           = new GUIStyle(EditorStyles.boldLabel);
        bigTextStyle.fontSize  = 24;
        bigTextStyle.alignment = TextAnchor.UpperCenter;

        miniTextStyle           = new GUIStyle(EditorStyles.miniLabel);
        miniTextStyle.alignment = TextAnchor.UpperCenter;

        flipbookLogo = FGTextEditor.LoadEditorResource <Texture2D>("CreatedByFlipbookGames.png");
    }
예제 #2
0
        protected void OnGUI()
        {
            if (Event.current.isKey && TabSwitcher.OnGUIGlobal())
            {
                return;
            }

            EditorWindow console = consoleWindowField.GetValue(null) as EditorWindow;

            if (console == null)
            {
                EditorGUILayout.HelpBox(@"Script Inspector Console can only work when the Console tab is also open.

Click the button below to open the Console window...", MessageType.Info);
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Open Console Widnow"))
                {
                    GetWindow(consoleWindowType);
                    Focus();
                    Repaint();
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                return;
            }

            Rect oldPosition = console.position;

            editorWindowPosField.SetValue(console, position);

            try
            {
                bool contextClick = Event.current.type == EventType.ContextClick ||
                                    Event.current.type == EventType.MouseUp && Event.current.button == 1 && Application.platform == RuntimePlatform.OSXEditor;
                if (contextClick && GUIUtility.hotControl == 0 &&
                    Event.current.mousePosition.y > EditorStyles.toolbar.fixedHeight)
                {
                    int lvHeight = (int)consoleLVHeightField.GetValue(console);
                    if (lvHeight > Event.current.mousePosition.y - EditorStyles.toolbar.fixedHeight)
                    {
                        Event.current.type       = EventType.MouseDown;
                        Event.current.button     = 0;
                        Event.current.clickCount = 1;
                        try { consoleOnGUIMethod.Invoke(console, null); } catch { }
                        GUIUtility.hotControl = 0;

                        DoPopupMenu(console);
                    }
                }
                else if (Event.current.type == EventType.MouseDown && Event.current.clickCount == 2 && Event.current.mousePosition.y > EditorStyles.toolbar.fixedHeight ||
                         Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
                {
                    OpenLogEntry(console);
                    GUIUtility.hotControl = 0;
                    GUIUtility.ExitGUI();
                }
                try { consoleOnGUIMethod.Invoke(console, null); } catch { }

#if UNITY_2019_3_OR_NEWER
                var rc = new Rect(413f, -1f, 160f, 18f);
#elif UNITY_2017_1_OR_NEWER
                var rc = new Rect(355f, -1f, 144f, 18f);
#else
                var rc = new Rect(254f, -1f, 144f, 18f);
#endif
                var autoFocusText = SISettings.autoFocusConsole == 0 ? "Auto-Focus: Never" :
                                    SISettings.autoFocusConsole == 1 ? "Auto-Focus: On Error" : "Auto-Focus: On Compile";
                if (GUI.Button(rc, autoFocusText, EditorStyles.toolbarDropDown))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Never"), SISettings.autoFocusConsole == 0,
                                 () => { SISettings.autoFocusConsole.Value = 0; });
                    menu.AddItem(new GUIContent("On Compile Error"), SISettings.autoFocusConsole == 1,
                                 () => { SISettings.autoFocusConsole.Value = 1; });
                    menu.AddItem(new GUIContent("On Compile"), SISettings.autoFocusConsole == 2,
                                 () => { SISettings.autoFocusConsole.Value = 2; });
                    menu.DropDown(rc);
                }

#if !UNITY_2019_3_OR_NEWER
                if (font == null && SISettings.monospacedFontConsole)
                {
                    font = FGTextEditor.LoadEditorResource <Font>("Smooth Fonts/DejaVu Sans Mono.ttf");
                    SetConsoleFont(font);
                }

                rc.xMin = rc.xMax + 4f;
                rc.xMax = rc.xMin + 100f;
                if (SISettings.monospacedFontConsole != GUI.Toggle(rc, SISettings.monospacedFontConsole, "Monospaced Font", EditorStyles.toolbarButton))
                {
                    SISettings.monospacedFontConsole.Value = !SISettings.monospacedFontConsole;

                    if (font == null && SISettings.monospacedFontConsole)
                    {
                        font = FGTextEditor.LoadEditorResource <Font>("Smooth Fonts/DejaVu Sans Mono.ttf");
                    }

                    SetConsoleFont(SISettings.monospacedFontConsole ? font : null);
                }
#endif
            }
            finally
            {
                editorWindowPosField.SetValue(console, oldPosition);
            }
        }
예제 #3
0
        private static void LoadSymbolIcons()
        {
            SymbolKind[] kinds = { SymbolKind.Namespace,       SymbolKind.Interface,          SymbolKind.Enum,           SymbolKind.Struct,
                                   SymbolKind.Class,           SymbolKind.Delegate,           SymbolKind.Field,          SymbolKind.ConstantField,SymbolKind.LocalConstant,
                                   SymbolKind.EnumMember,      SymbolKind.Property,           SymbolKind.Event,          SymbolKind.Indexer,
                                   SymbolKind.Method,          SymbolKind.Constructor,        SymbolKind.Destructor,     SymbolKind.Operator,
                                   SymbolKind.Accessor,        SymbolKind.Parameter,          SymbolKind.CatchParameter, SymbolKind.Variable,
                                   SymbolKind.ForEachVariable, SymbolKind.FromClauseVariable, SymbolKind.TypeParameter,
                                   SymbolKind.Label };
            var          oneForAll = new HashSet <SymbolKind> {
                SymbolKind.Namespace, SymbolKind.EnumMember, SymbolKind.Parameter,
                SymbolKind.CatchParameter, SymbolKind.Variable, SymbolKind.ForEachVariable, SymbolKind.FromClauseVariable,
                SymbolKind.TypeParameter, SymbolKind.Label, SymbolKind.LocalConstant, SymbolKind.Constructor, SymbolKind.Destructor
            };

            symbolIcons = new Texture2D[System.Enum.GetNames(typeof(SymbolKind)).Length, 3];
            for (var i = 0; i < kinds.Length; i++)
            {
                var kind = kinds[i].ToString();
                if (kind == "ConstantField" || kind == "LocalConstant")
                {
                    kind = "Constant";
                }
                else if (kind == "EnumMember")
                {
                    kind = "EnumItem";
                }
                var index = (int)kinds[i];
                symbolIcons[index, 0] = FGTextEditor.LoadEditorResource <Texture2D>("Symbol Icons/VSObject_" + kind + ".png");
                if (oneForAll.Contains(kinds[i]))
                {
                    symbolIcons[index, 1] = symbolIcons[index, 0];
                    symbolIcons[index, 2] = symbolIcons[index, 0];
                }
                else
                {
                    symbolIcons[index, 1] = FGTextEditor.LoadEditorResource <Texture2D>("Symbol Icons/VSObject_" + kind + "_Protected.png");
                    symbolIcons[index, 2] = FGTextEditor.LoadEditorResource <Texture2D>("Symbol Icons/VSObject_" + kind + "_Private.png");
                }

#if SI3_WARNINGS
                if (symbolIcons[index, 0] == null)
                {
                    Debug.LogWarning("No icon for " + kind);
                }
                if (symbolIcons[index, 1] == null)
                {
                    Debug.LogWarning("No icon for protected " + kind);
                }
                if (symbolIcons[index, 2] == null)
                {
                    Debug.LogWarning("No icon for private " + kind);
                }
#endif
            }
            symbolIcons[(int)SymbolKind._Keyword, 0] = keywordIcon = FGTextEditor.LoadEditorResource <Texture2D>("Symbol Icons/Keyword.png");
            symbolIcons[(int)SymbolKind._Keyword, 1] = keywordIcon;
            symbolIcons[(int)SymbolKind._Keyword, 2] = keywordIcon;
            var snippetIcon = FGTextEditor.LoadEditorResource <Texture2D>("Symbol Icons/Snippet.png");
            symbolIcons[(int)SymbolKind._Snippet, 0] = snippetIcon;
            symbolIcons[(int)SymbolKind._Snippet, 1] = snippetIcon;
            symbolIcons[(int)SymbolKind._Snippet, 2] = snippetIcon;

            inactiveListItem = FGTextEditor.LoadEditorResource <Texture2D>("inactiveListItem.png");
            selectedListItem = FGTextEditor.LoadEditorResource <Texture2D>("selectedListItem.png");
        }