Example #1
0
 public override void DrawDefault()
 {
     GuiHelper.DrawLocaleSelection(this.content, ShaderEditor.currentlyDrawing.gui.locale.available_locales, ShaderEditor.currentlyDrawing.gui.locale.selected_locale_index);
 }
Example #2
0
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     GuiHelper.drawConfigTextureProperty(position, prop, label, editor, ((TextureProperty)ShaderEditor.active.currentProperty).hasScaleOffset);
     GuiHelper.sRGBWarning(prop);
 }
Example #3
0
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     GuiHelper.drawSmallTextureProperty(position, prop, label, editor, ((TextureProperty)ThryEditor.currentlyDrawing.currentProperty).hasScaleOffset);
 }
Example #4
0
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     GuiHelper.MinMaxSlider(position, label, prop);
 }
Example #5
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))
            {
                OnOpen();
            }
            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
            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 if exists
            if (masterLabelText != null)
            {
                GuiHelper.DrawMasterLabel(masterLabelText, 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)
            {
                header_search_term = EditorGUILayout.TextField(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)
            {
                editorData.propertyDictionary["_ShaderOptimizerEnabled"].Draw();
            }

            //PROPERTIES
            if (header_search_term == "" || show_search_bar == false)
            {
                foreach (ShaderPart part in shaderparts.parts)
                {
                    part.Draw();
                }
            }
            else
            {
                foreach (ShaderPart part in editorData.propertyDictionary.Values)
                {
                    if (IsSearchedFor(part, header_search_term))
                    {
                        part.Draw();
                    }
                }
            }

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

            //footer
            GuiHelper.drawFooters(footer);

            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;
        }