Exemplo n.º 1
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            IsDrawing = true;
            //Init
            bool reloadUI = _isFirstOnGUICall || (_doReloadNextDraw && Event.current.type == EventType.Layout) || (materialEditor.target as Material).shader != Shader;

            if (reloadUI)
            {
                InitEditorData(materialEditor);
                Properties = props;
                InitlizeThryUI();
            }

            //Update Data
            Properties = props;
            Shader     = Materials[0].shader;
            Input.Update(IsLockedMaterial);
            ActiveRenderer    = Selection.activeTransform?.GetComponent <Renderer>();
            IsInAnimationMode = AnimationMode.InAnimationMode();

            Active = this;

            GUIManualReloadButton();
            GUIShaderVersioning();

            GUITopBar();
            GUISearchBar();
            Presets.PresetEditorGUI(this);
            ShaderTranslator.SuggestedTranslationButtonGUI(this);

            //PROPERTIES
            foreach (ShaderPart part in MainGroup.parts)
            {
                part.Draw();
            }

            //Render Queue selection
            if (VRCInterface.IsVRCSDKInstalled())
            {
                _vRCFallbackProperty.Draw();
            }
            if (Config.Singleton.showRenderQueue)
            {
                _renderQueueProperty.Draw();
            }

            BetterTooltips.DrawActive();

            GUIFooters();

            HandleEvents();

            IsDrawing = false;
        }
Exemplo 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();
        }
Exemplo n.º 3
0
        public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
        {
            //Unity sets the render queue to the shader defult when changing shader
            //This seems to be some deeper process that cant be disabled so i just set it again after the swap
            //Even material.shader = newShader resets the queue. (this is actually the only thing the base function does)
            int previousQueue = material.renderQueue;

            base.AssignNewShaderToMaterial(material, oldShader, newShader);
            material.renderQueue           = previousQueue;
            SuggestedTranslationDefinition = ShaderTranslator.CheckForExistingTranslationFile(oldShader, newShader);
            _doReloadNextDraw = true;
            _didSwapToShader  = true;
        }