Exemple #1
0
        //-------------Draw Functions----------------

        public void InitlizeThryUI()
        {
            Config config = Config.Get();

            show_eyeIcon_tutorial = !EditorPrefs.GetBool("thry_openeEyeIcon", false);

            currentlyDrawing = editorData;
            active           = this;

            //get material targets
            editorData.materials = editorData.editor.targets.Select(o => o as Material).ToArray();

            editorData.shader = editorData.materials[0].shader;
            string defaultShaderName = editorData.materials[0].shader.name.Split(new string[] { "-queue" }, System.StringSplitOptions.None)[0].Replace(".differentQueues/", "");

            editorData.defaultShader = Shader.Find(defaultShaderName);

            editorData.animPropertySuffix = new string(editorData.materials[0].name.Trim().ToLower().Where(char.IsLetter).ToArray());

            currentlyDrawing = editorData;

            //collect shader properties
            CollectAllProperties();

            ShaderOptimizerProperty = editorData.propertyDictionary?["_ShaderOptimizerEnabled"];

            AddResetProperty();

            firstOnGUICall = false;
        }
Exemple #2
0
 void InitEditorData(MaterialEditor materialEditor)
 {
     editor = materialEditor;
     gui    = this;
     textureArrayProperties = new List <ShaderProperty>();
     firstCall = true;
 }
Exemple #3
0
        //-------------Draw Functions----------------

        public void InitlizeThryUI()
        {
            Config config = Config.Singleton;

            show_eyeIcon_tutorial = !EditorPrefs.GetBool("thry_openeEyeIcon", false);
            active = this;

            //get material targets
            materials = editor.targets.Select(o => o as Material).ToArray();

            shader = materials[0].shader;
            string defaultShaderName = materials[0].shader.name.Split(new string[] { "-queue" }, System.StringSplitOptions.None)[0].Replace(".differentQueues/", "");

            defaultShader = Shader.Find(defaultShaderName);

            animPropertySuffix = new string(materials[0].name.Trim().ToLower().Where(char.IsLetter).ToArray());

            //collect shader properties
            CollectAllProperties();

            if (ShaderOptimizer.IsShaderUsingThryOptimizer(shader))
            {
                ShaderOptimizerProperty = propertyDictionary[ShaderOptimizer.GetOptimizerPropertyName(shader)];
            }

            AddResetProperty();

            firstOnGUICall = false;
        }
Exemple #4
0
        public ShaderProperty(ShaderEditor shaderEditor, MaterialProperty materialProperty, string displayName, int xOffset, PropertyOptions options, bool forceOneLine) : base(shaderEditor, materialProperty, xOffset, displayName, options)
        {
            drawDefault       = false;
            this.forceOneLine = forceOneLine;

            property_index = System.Array.IndexOf(ShaderEditor.currentlyDrawing.properties, materialProperty);
        }
Exemple #5
0
 private void DiscardChanges()
 {
     prop.textureValue = privious_preview_texture;
     SetGradient(TextureHelper.GetGradient(privious_preview_texture));
     gradient_has_been_edited = false;
     ShaderEditor.Repaint();
 }
Exemple #6
0
        //-------------Draw Functions----------------

        public void InitlizeThryUI()
        {
            Config config = Config.Singleton;

            active = this;

            //get material targets
            materials = editor.targets.Select(o => o as Material).ToArray();

            shader = materials[0].shader;

            animPropertySuffix = ShaderOptimizer.GetAnimPropertySuffix(materials[0]);

            _isPresetEditor = materials.Length == 1 && Presets.ArePreset(materials);

            //collect shader properties
            CollectAllProperties();

            if (ShaderOptimizer.IsShaderUsingThryOptimizer(shader))
            {
                ShaderOptimizerProperty = propertyDictionary[ShaderOptimizer.GetOptimizerPropertyName(shader)];
                if (ShaderOptimizerProperty != null)
                {
                    ShaderOptimizerProperty.exempt_from_locked_disabling = true;
                }
            }

            AddResetProperty();

            firstOnGUICall = false;
        }
Exemple #7
0
        public void HandleKajAnimatable()
        {
            Rect lastRect = GUILayoutUtility.GetLastRect();

            if (ShaderEditor.active.isLockedMaterial == false && Event.current.isMouse && Event.current.button == 1 && lastRect.Contains(Event.current.mousePosition))
            {
                if (Event.current.control && Config.Singleton.renameAnimatedProps)
                {
                    if (!is_animated)
                    {
                        is_animated = true;
                    }

                    if (is_animated)
                    {
                        is_renaming = !is_renaming;
                    }
                }
                else
                {
                    is_animated = !is_animated;
                }
                ShaderOptimizer.SetAnimatedTag(materialProperty, is_animated ? (is_renaming ? "2" : "1") : "");
                ShaderEditor.Repaint();
            }
            if (is_animated)
            {
                Rect r = new Rect(8, lastRect.y + 2, 16, 16);
                GUI.DrawTexture(r, is_renaming ? Styles.texture_animated_renamed : Styles.texture_animated, ScaleMode.StretchToFill, true);
            }
        }
Exemple #8
0
        //-------------Draw Functions----------------

        public void OnOpen()
        {
            Config config = Config.Get();

            show_eyeIcon_tutorial = !EditorPrefs.GetBool("thry_openeEyeIcon", false);

            currentlyDrawing = editorData;
            active           = this;

            //get material targets
            UnityEngine.Object[] targets = editorData.editor.targets;
            editorData.materials = new Material[targets.Length];
            for (int i = 0; i < targets.Length; i++)
            {
                editorData.materials[i] = targets[i] as Material;
            }

            editorData.shader = editorData.materials[0].shader;
            string defaultShaderName = editorData.materials[0].shader.name.Split(new string[] { "-queue" }, System.StringSplitOptions.None)[0].Replace(".differentQueues/", "");

            editorData.defaultShader = Shader.Find(defaultShaderName);

            //collect shader properties
            CollectAllProperties();

            AddResetProperty();

            firstOnGUICall = false;
        }
Exemple #9
0
        public static void HeaderHiderGUI(ShaderEditor editor)
        {
            EditorGUILayout.BeginHorizontal(Styles.style_toolbar);
            if (GUILayout.Button("Simple", Styles.style_toolbar_toggle(state == HeaderHidingType.simple)))
            {
                SetType(HeaderHidingType.simple);
            }
            if (GUILayout.Button("Show All", Styles.style_toolbar_toggle(state == HeaderHidingType.show_all)))
            {
                SetType(HeaderHidingType.show_all);
            }
            Rect right = GUILayoutUtility.GetRect(10, 20);
            Rect arrow = new Rect(right.x + right.width - 20, right.y, 20, 20);

            if (GUI.Button(arrow, Styles.icon_menu, EditorStyles.largeLabel))
            {
                DrawHeaderHiderMenu(arrow, editor.shaderParts);
            }
            if (GUI.Button(right, "Custom", Styles.style_toolbar_toggle(state == HeaderHidingType.custom)))
            {
                SetType(HeaderHidingType.custom);
            }

            GUI.Button(arrow, Styles.icon_menu, EditorStyles.largeLabel);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
Exemple #10
0
 private void UpdateGradientPreviewTexture()
 {
     data.preview_texture = Converter.GradientToTexture(data.gradient, textureSettings.width, textureSettings.height);
     textureSettings.ApplyModes(data.preview_texture);
     prop.textureValue        = data.preview_texture;
     gradient_has_been_edited = true;
     ShaderEditor.Repaint();
 }
        public static void OnEditorRemove()
        {
            string dir_path = ShaderEditor.GetShaderEditorDirectoryPath() + "/thry_modules";

            if (Directory.Exists(dir_path))
            {
                TrashHandler.MoveDirectoryToTrash(dir_path);
            }
        }
Exemple #12
0
 public static void DrawLocaleSelection(GUIContent label, string[] locales, int selected)
 {
     EditorGUI.BeginChangeCheck();
     selected = EditorGUILayout.Popup(label.text, selected, locales);
     if (EditorGUI.EndChangeCheck())
     {
         ShaderEditor.active.propertyDictionary[ShaderEditor.PROPERTY_NAME_LOCALE].materialProperty.floatValue = selected;
         ShaderEditor.reload();
     }
 }
Exemple #13
0
        private static string GetThryModulesDirectoryPath()
        {
            string editor_path = ShaderEditor.GetShaderEditorDirectoryPath();

            if (editor_path == null)
            {
                editor_path = "Assets";
            }
            return(editor_path + "/thry_modules");
        }
Exemple #14
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;
        }
Exemple #15
0
        static OnCompileHandler()
        {
            //Init Editor Variables with paths
            ShaderEditor.GetShaderEditorDirectoryPath();

            Config.OnCompile();
            ModuleHandler.OnCompile();
            TrashHandler.EmptyThryTrash();

            UnityFixer.CheckAPICompatibility(); //check that Net_2.0 is ApiLevel
            UnityFixer.CheckDrawingDll();       //check that drawing.dll is imported
        }
Exemple #16
0
        private static bool CheckForEditorRemove(string[] assets)
        {
            string test_for = ShaderEditor.GetShaderEditorDirectoryPath() + "/Editor/ShaderEditor.cs";

            foreach (string p in assets)
            {
                if (p == test_for)
                {
                    return(true);
                }
            }
            return(false);
        }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            _isDrawing = true;
            //Init
            bool reloadUI = firstOnGUICall || (reloadNextDraw && 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;
            UpdateEvents();

            active = this;

            GUIManualReloadButton();
            GUIShaderVersioning();

            GUITopBar();
            GUISearchBar();
            GUIComplexity();

            //Optimizer is now drawn wherever the property is. might change back later
            //ShaderOptimizerProperty?.Draw();

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

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

            BetterTooltips.DrawActive();

            GUIFooters();

            HandleEvents();

            _isDrawing = false;
        }
Exemple #18
0
 public virtual void HandleRightClickToggles(bool isInHeader)
 {
     if (ShaderEditor.input.RightClick && DrawingData.tooltipCheckRect.Contains(Event.current.mousePosition))
     {
         //Preset toggle
         if (Event.current.shift)
         {
             if (shaderEditor._isPresetEditor && isInHeader == false)
             {
                 is_preset = !is_preset;
                 Presets.SetProperty(shaderEditor.materials[0], materialProperty, is_preset);
                 ShaderEditor.Repaint();
                 ShaderEditor.input.Use();
             }
         }
         //Animated toggle
         else
         {
             if (is_animatable && isInHeader == false && this is ShaderHeader == false)
             {
                 if (Event.current.control && Config.Singleton.renameAnimatedProps)
                 {
                     if (!is_animated)
                     {
                         is_animated = true;
                         is_renaming = true;
                     }
                     else if (!is_renaming)
                     {
                         is_renaming = true;
                     }
                     else
                     {
                         is_animated = false;
                         is_renaming = false;
                     }
                 }
                 else
                 {
                     is_animated = !is_animated;
                     is_renaming = false;
                 }
                 ShaderOptimizer.SetAnimatedTag(materialProperty, is_animated ? (is_renaming ? "2" : "1") : "");
                 ShaderEditor.Repaint();
                 ShaderEditor.input.Use();
             }
         }
     }
 }
Exemple #19
0
 public ShaderHeader(ShaderEditor shaderEditor, MaterialProperty prop, MaterialEditor materialEditor, string displayName, int xOffset, PropertyOptions options) : base(shaderEditor, prop, materialEditor, displayName, xOffset, options)
 {
     if (DrawingData.lastPropertyDrawerType == DrawerType.Header)
     {
         //new header setup with drawer
         this.headerDrawer = DrawingData.lastPropertyDrawer as ThryHeaderDrawer;
     }
     else
     {
         //legacy setup with HideInInspector
         this.headerDrawer = new ThryHeaderDrawer();
         isLegacy          = true;
     }
     this.headerDrawer.xOffset = xOffset;
 }
Exemple #20
0
        public ShaderProperty(ShaderEditor shaderEditor, MaterialProperty materialProperty, string displayName, int xOffset, PropertyOptions options, bool forceOneLine, int property_index) : base(shaderEditor, materialProperty, xOffset, displayName, options)
        {
            this.doCustomDrawLogic  = false;
            this.doForceIntoOneLine = forceOneLine;

            if (materialProperty.type == MaterialProperty.PropType.Vector && forceOneLine == false)
            {
                this.doCustomHeightOffset = !DrawingData.lastPropertyUsedCustomDrawer;
                this.customHeightOffset   = -EditorGUIUtility.singleLineHeight;
            }

            this.doDrawTwoFields = options.reference_property != null;

            this.property_index = property_index;
        }
Exemple #21
0
        private static void Toggle(string configField, string label, string hover, GUIStyle label_style = null)
        {
            Config config = Config.Singleton;

            System.Reflection.FieldInfo field = typeof(Config).GetField(configField);
            if (field != null)
            {
                bool value = (bool)field.GetValue(config);
                if (Toggle(value, label, hover, label_style) != value)
                {
                    field.SetValue(config, !value);
                    config.save();
                    ShaderEditor.Repaint();
                }
            }
        }
Exemple #22
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            _isDrawing = true;
            //Init
            bool reloadUI = firstOnGUICall || (reloadNextDraw && 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);

            active = this;

            GUIManualReloadButton();
            GUIShaderVersioning();

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

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

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

            BetterTooltips.DrawActive();

            GUIFooters();

            HandleEvents();

            _isDrawing = false;
        }
Exemple #23
0
        public void Foldout(int xOffset, GUIContent content, ShaderEditor gui)
        {
            PropertyOptions options = ShaderEditor.currentlyDrawing.currentProperty.options;
            Event           e       = Event.current;
            GUIStyle        style   = new GUIStyle(Styles.dropDownHeader);

            style.margin.left = 15 * xOffset + 15;

            Rect rect = GUILayoutUtility.GetRect(16f + 20f, 22f, style);

            DrawingData.lastGuiObjectHeaderRect = rect;

            DrawBoxAndContent(rect, e, content, options, style);

            DrawSmallArrow(rect, e);
            HandleToggleInput(e, rect);
        }
Exemple #24
0
        public ShaderPart(MaterialProperty prop, int xOffset, string displayName, PropertyOptions options)
        {
            this.materialProperty           = prop;
            this.xOffset                    = xOffset;
            this.options                    = options;
            this.content                    = new GUIContent(displayName, options.tooltip);
            this.reference_properties_exist = options.reference_properties != null && options.reference_properties.Length > 0;
            this.reference_property_exists  = options.reference_property != null;

            if (prop == null)
            {
                return;
            }
            this.kaj_isAnimatedProperty = ShaderEditor.FindProperty(ShaderEditor.currentlyDrawing.properties, prop.name + "Animated");
            this.is_animatable          = kaj_isAnimatedProperty != null;
            this.is_animated            = is_animatable && kaj_isAnimatedProperty.floatValue > 0;
            this.is_renaming            = is_animatable && kaj_isAnimatedProperty.floatValue == 2;
        }
Exemple #25
0
 private static void LocaleDropdown()
 {
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.BeginHorizontal();
     GUILayout.Label(new GUIContent(Locale.editor.Get("locale"), Locale.editor.Get("locale_tooltip")), GUILayout.ExpandWidth(false));
     Locale.editor.selected_locale_index = EditorGUILayout.Popup(Locale.editor.selected_locale_index, Locale.editor.available_locales, GUILayout.ExpandWidth(false));
     if (Locale.editor.Get("translator").Length > 0)
     {
         GUILayout.Label(Locale.editor.Get("translation") + ": " + Locale.editor.Get("translator"), GUILayout.ExpandWidth(false));
     }
     EditorGUILayout.EndHorizontal();
     if (EditorGUI.EndChangeCheck())
     {
         Config.Singleton.locale = Locale.editor.available_locales[Locale.editor.selected_locale_index];
         Config.Singleton.Save();
         ShaderEditor.ReloadActive();
     }
 }
Exemple #26
0
        public bool has_not_searchedFor = false; //used for property search

        public ShaderPart(ShaderEditor shaderEditor, MaterialProperty prop, int xOffset, string displayName, PropertyOptions options)
        {
            this.shaderEditor               = shaderEditor;
            this.materialProperty           = prop;
            this.xOffset                    = xOffset;
            this.options                    = options;
            this.content                    = new GUIContent(displayName);
            this.tooltip                    = new BetterTooltips.Tooltip(options.tooltip);
            this.reference_properties_exist = options.reference_properties != null && options.reference_properties.Length > 0;
            this.reference_property_exists  = options.reference_property != null;
            this.is_preset                  = shaderEditor._isPresetEditor && Presets.IsPreset(shaderEditor.materials[0], prop);

            if (prop == null)
            {
                return;
            }
            bool   propHasDuplicate = shaderEditor.GetMaterialProperty(prop.name + "_" + shaderEditor.animPropertySuffix) != null;
            string tag = null;

            //If prop is og, but is duplicated (locked) dont have it animateable
            if (propHasDuplicate)
            {
                this.is_animatable = false;
            }
            else
            {
                //if prop is a duplicated or renamed get og property to check for animted status
                if (prop.name.Contains(shaderEditor.animPropertySuffix))
                {
                    string ogName = prop.name.Substring(0, prop.name.Length - shaderEditor.animPropertySuffix.Length - 1);
                    tag = ShaderOptimizer.GetAnimatedTag(materialProperty.targets[0] as Material, ogName);
                }
                else
                {
                    tag = ShaderOptimizer.GetAnimatedTag(materialProperty);
                }
                this.is_animatable = true;
            }


            this.is_animated = is_animatable && tag != "";
            this.is_renaming = is_animatable && tag == "2";
        }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            //Init
            bool reloadUI = firstOnGUICall || (reloadNextDraw && Event.current.type == EventType.Layout);

            if (reloadUI)
            {
                InitEditorData(materialEditor);
                editorData.properties = props;
                InitlizeThryUI();
            }

            //Update Data
            editorData.properties = props;
            editorData.shader     = editorData.materials[0].shader;
            UpdateEvents();

            currentlyDrawing = editorData;
            active           = this;

            GUITopBar();
            GUISearchBar();
            GUIComplexity();

            ShaderOptimizerProperty?.Draw();

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

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

            GUIFooters();

            HandleEvents();
        }
Exemple #28
0
        private static void Dropdown(string configField, string label, string hover, GUIStyle label_style = null)
        {
            Config config = Config.Singleton;

            System.Reflection.FieldInfo field = typeof(Config).GetField(configField);
            if (field != null)
            {
                Enum value = (Enum)field.GetValue(config);
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(57);
                GUILayout.Label(new GUIContent(label, hover), GUILayout.ExpandWidth(false));
                value = EditorGUILayout.EnumPopup(value, GUILayout.ExpandWidth(false));
                EditorGUILayout.EndHorizontal();
                if (EditorGUI.EndChangeCheck())
                {
                    field.SetValue(config, value);
                    config.save();
                    ShaderEditor.Repaint();
                }
            }
        }
Exemple #29
0
        //-------------Draw Functions----------------

        public void InitlizeThryUI()
        {
            Config config = Config.Singleton;

            Active = this;
            Helper.RegisterEditorUse();

            //get material targets
            Materials = Editor.targets.Select(o => o as Material).ToArray();

            Shader = Materials[0].shader;

            RenamedPropertySuffix = ShaderOptimizer.GetRenamedPropertySuffix(Materials[0]);

            IsPresetEditor = Materials.Length == 1 && Presets.ArePreset(Materials);

            //collect shader properties
            CollectAllProperties();

            if (ShaderOptimizer.IsShaderUsingThryOptimizer(Shader))
            {
                ShaderOptimizerProperty = PropertyDictionary[ShaderOptimizer.GetOptimizerPropertyName(Shader)];
                if (ShaderOptimizerProperty != null)
                {
                    ShaderOptimizerProperty.ExemptFromLockedDisabling = true;
                }
            }

            _renderQueueProperty = new RenderQueueProperty(this);
            _vRCFallbackProperty = new VRCFallbackProperty(this);
            ShaderParts.Add(_renderQueueProperty);
            ShaderParts.Add(_vRCFallbackProperty);

            AddResetProperty();

            _isFirstOnGUICall = false;
        }
Exemple #30
0
 private void UpdatePreviewTexture(Texture texture)
 {
     data.preview_texture = texture;
     prop.textureValue    = texture;
     ShaderEditor.Repaint();
 }