Esempio n. 1
0
        private void GUITopBar()
        {
            //if header is texture, draw it first so other ui elements can be positions below
            if (shaderHeader != null && shaderHeader.options.texture != null)
            {
                shaderHeader.Draw();
            }
            Rect mainHeaderRect = EditorGUILayout.BeginHorizontal();

            //draw editor settings button
            if (GUILayout.Button(new GUIContent("", Styles.settings_icon), EditorStyles.largeLabel, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)))
            {
                Thry.Settings window = Thry.Settings.getInstance();
                window.Show();
                window.Focus();
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            if (GUILayout.Button(Styles.search_icon, EditorStyles.largeLabel, GUILayout.MaxHeight(20)))
            {
                show_search_bar = !show_search_bar;
            }

            //draw master label text after ui elements, so it can be positioned between
            if (shaderHeader != null)
            {
                shaderHeader.Draw(new CRect(mainHeaderRect));
            }

            //GUILayout.Label("Thryrallo",GUILayout.ExpandWidth(true));
            GUILayout.Label("@UI by Thryrallo", Styles.made_by_style, GUILayout.Height(25), GUILayout.MaxWidth(100));
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 2
0
        private void GUITopBar()
        {
            //if header is texture, draw it first so other ui elements can be positions below
            if (_shaderHeader != null && _shaderHeader.Options.texture != null)
            {
                _shaderHeader.Draw();
            }

            bool drawAboveToolbar = EditorGUIUtility.wideMode == false;

            if (drawAboveToolbar)
            {
                _shaderHeader.Draw(new CRect(EditorGUILayout.GetControlRect()));
            }

            Rect mainHeaderRect = EditorGUILayout.BeginHorizontal();

            //draw editor settings button
            if (GuiHelper.ButtonWithCursor(Styles.icon_style_settings, "Settings", 25, 25))
            {
                EditorWindow.GetWindow <Settings>(false, "Thry Settings", true);
            }
            if (GuiHelper.ButtonWithCursor(Styles.icon_style_search, "Search", 25, 25))
            {
                DoShowSearchBar = !DoShowSearchBar;
                if (!DoShowSearchBar)
                {
                    ClearSearch();
                }
            }
            Presets.PresetGUI(this);

            //draw master label text after ui elements, so it can be positioned between
            if (_shaderHeader != null && !drawAboveToolbar)
            {
                _shaderHeader.Draw(new CRect(mainHeaderRect));
            }

            GUILayout.FlexibleSpace();
            Rect popupPosition;

            if (GuiHelper.ButtonWithCursor(Styles.icon_style_tools, "Tools", 25, 25, out popupPosition))
            {
                PopupTools(popupPosition);
            }
            ShaderTranslator.TranslationSelectionGUI(this);
            if (GuiHelper.ButtonWithCursor(Styles.icon_style_thryIcon, "Thryrallo", 25, 25))
            {
                Application.OpenURL("https://www.twitter.com/thryrallo");
            }
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 3
0
        private void GUITopBar()
        {
            //if header is texture, draw it first so other ui elements can be positions below
            if (shaderHeader != null && shaderHeader.options.texture != null)
            {
                shaderHeader.Draw();
            }
            Rect mainHeaderRect = EditorGUILayout.BeginHorizontal();

            //draw editor settings button
            if (GuiHelper.ButtonWithCursor(Styles.icon_style_settings, 25, 25))
            {
                Thry.Settings window = Thry.Settings.getInstance();
                window.Show();
                window.Focus();
            }
            if (GuiHelper.ButtonWithCursor(Styles.icon_style_search, 25, 25))
            {
                show_search_bar = !show_search_bar;
                if (!show_search_bar)
                {
                    ClearSearch();
                }
            }
            Rect presetR = GUILayoutUtility.GetRect(25, 25);

            Presets.PresetGUI(presetR, this);

            //draw master label text after ui elements, so it can be positioned between
            if (shaderHeader != null)
            {
                shaderHeader.Draw(new CRect(mainHeaderRect));
            }

            //GUILayout.Label("Thryrallo",GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.Label("@UI by Thryrallo", Styles.made_by_style, GUILayout.Height(25), GUILayout.MaxWidth(100));
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 4
0
        //-------------Main Function--------------
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            if (firstOnGUICall || (reloadNextDraw && Event.current.type == EventType.Layout))
            {
                editorData        = new EditorData();
                editorData.editor = materialEditor;
                editorData.gui    = this;
                editorData.textureArrayProperties = new List <ShaderProperty>();
                editorData.firstCall = true;
            }
            editorData.properties = props;


            CheckInAnimationRecordMode();
            m_RenderersForAnimationMode = MaterialEditor.PrepareMaterialPropertiesForAnimationMode(props, GUI.enabled);

            UpdateEvents();

            //first time call inits
            if (firstOnGUICall || (reloadNextDraw && Event.current.type == EventType.Layout))
            {
                InitlizeThryUI();
            }
            editorData.shader = editorData.materials[0].shader;

            currentlyDrawing = editorData;
            active           = this;

            //sync shader and get preset handler
            Config config = Config.Get();

            if (editorData.materials != null)
            {
                Mediator.SetActiveShader(editorData.materials[0].shader);
            }

            //TOP Bar
            //if header is texture, draw it first so other ui elements can be positions below
            if (shaderHeader != null && shaderHeader.options.texture != null)
            {
                shaderHeader.Draw();
            }
            Rect mainHeaderRect = EditorGUILayout.BeginHorizontal();

            //draw editor settings button
            if (GUILayout.Button(new GUIContent("", Styles.settings_icon), EditorStyles.largeLabel, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)))
            {
                Thry.Settings window = Thry.Settings.getInstance();
                window.Show();
                window.Focus();
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            if (GUILayout.Button(Styles.search_icon, EditorStyles.largeLabel, GUILayout.MaxHeight(20)))
            {
                show_search_bar = !show_search_bar;
            }

            //draw master label text after ui elements, so it can be positioned between
            shaderHeader?.Draw(new CRect(mainHeaderRect));

            //GUILayout.Label("Thryrallo",GUILayout.ExpandWidth(true));
            GUILayout.Label("@UI by Thryrallo", Styles.made_by_style, GUILayout.Height(25), GUILayout.MaxWidth(100));
            EditorGUILayout.EndHorizontal();

            if (show_search_bar)
            {
                EditorGUI.BeginChangeCheck();
                header_search_term = EditorGUILayout.TextField(header_search_term);
                if (EditorGUI.EndChangeCheck())  //Cache the search
                {
                    editorData.searchedShaderParts = GetFilterSearchedParts(header_search_term);
                }
            }

            //Visibility menu
            if (editorData.show_HeaderHider)
            {
                HeaderHider.HeaderHiderGUI(editorData);
            }

            //bool isMaterialLocked = editorData.use_ShaderOptimizer && editorData.propertyDictionary["_ShaderOptimizerEnabled"].materialProperty.floatValue == 1;
            if (editorData.use_ShaderOptimizer)
            {
                ShaderOptimizerProperty?.Draw();
            }

            //PROPERTIES
            if (show_search_bar && !string.IsNullOrWhiteSpace(header_search_term) && editorData.searchedShaderParts != null)
            {
                foreach (ShaderProperty part in editorData.searchedShaderParts)
                {
                    part.Draw();
                }
            }
            else
            {
                foreach (ShaderPart part in mainHeader.parts)
                {
                    part.Draw();
                }
            }

            //Render Queue selection
            if (config.showRenderQueue)
            {
                materialEditor.RenderQueueField();
            }

            //footer
            try
            {
                GuiHelper.drawFooters(footer);
            }catch (Exception ex)
            {
                Debug.LogWarning(ex);
            }

            if (GUILayout.Button("@UI Made by Thryrallo", Styles.made_by_style))
            {
                Application.OpenURL("https://www.twitter.com/thryrallo");
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);

            Event e      = Event.current;
            bool  isUndo = (e.type == EventType.ExecuteCommand || e.type == EventType.ValidateCommand) && e.commandName == "UndoRedoPerformed";

            if (reloadNextDraw && Event.current.type == EventType.Layout)
            {
                reloadNextDraw = false;
            }
            if (isUndo)
            {
                reloadNextDraw = true;
            }

            //on swap
            if (on_swap_to_actions != null && swapped_to_shader)
            {
                foreach (DefineableAction a in on_swap_to_actions)
                {
                    a.Perform();
                }
                on_swap_to_actions = null;
                swapped_to_shader  = false;
            }

            //test if material has been reset
            if (wasUsed && e.type == EventType.Repaint)
            {
                if (editorData.materials[0].HasProperty("shader_is_using_thry_editor") && editorData.materials[0].GetFloat("shader_is_using_thry_editor") != 69)
                {
                    reloadNextDraw = true;
                    HandleReset();
                    wasUsed = true;
                }
            }

            if (e.type == EventType.Used)
            {
                wasUsed = true;
            }
            if (input.HadMouseDownRepaint)
            {
                input.HadMouseDown = false;
            }
            input.HadMouseDownRepaint  = false;
            editorData.firstCall       = false;
            materialPropertyDictionary = null;
        }