public static void DrawMasterLabel(string shaderName, float y)
        {
            Rect rect = new Rect(0, y, Screen.width, 18);

            EditorGUI.LabelField(rect, "<size=16>" + shaderName + "</size>", Styles.Get().masterLabel);
        }
        public static void drawStylizedBigTextureProperty(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor, bool hasFoldoutProperties, bool skip_drag_and_drop_handling = false)
        {
            position.x     += (EditorGUI.indentLevel) * 15;
            position.width -= (EditorGUI.indentLevel) * 15;
            Rect rect = GUILayoutUtility.GetRect(label, Styles.Get().bigTextureStyle);

            rect.x     += (EditorGUI.indentLevel) * 15;
            rect.width -= (EditorGUI.indentLevel) * 15;
            Rect border = new Rect(rect);

            border.position = new Vector2(border.x, border.y - position.height);
            border.height  += position.height;

            if (DrawingData.currentTexProperty.reference_properties_exist)
            {
                border.height += 8;
                foreach (string r_property in DrawingData.currentTexProperty.options.reference_properties)
                {
                    border.height += editor.GetPropertyHeight(ThryEditor.currentlyDrawing.propertyDictionary[r_property].materialProperty);
                }
            }


            //background
            GUI.DrawTexture(border, Styles.rounded_texture, ScaleMode.StretchToFill, true);
            Rect quad = new Rect(border);

            quad.width = quad.height / 2;
            GUI.DrawTextureWithTexCoords(quad, Styles.rounded_texture, new Rect(0, 0, 0.5f, 1), true);
            quad.x += border.width - quad.width;
            GUI.DrawTextureWithTexCoords(quad, Styles.rounded_texture, new Rect(0.5f, 0, 0.5f, 1), true);

            quad.width  = border.height - 4;
            quad.height = quad.width;
            quad.x      = border.x + border.width - quad.width - 1;
            quad.y     += 2;


            Rect preview_rect_border = new Rect(position);

            preview_rect_border.height = rect.height + position.height - 6;
            preview_rect_border.width  = preview_rect_border.height;
            preview_rect_border.y     += 3;
            preview_rect_border.x     += position.width - preview_rect_border.width - 3;
            Rect preview_rect = new Rect(preview_rect_border);

            preview_rect.height -= 6;
            preview_rect.width  -= 6;
            preview_rect.x      += 3;
            preview_rect.y      += 3;
            if (prop.hasMixedValue)
            {
                Rect mixedRect = new Rect(preview_rect);
                mixedRect.y -= 5;
                mixedRect.x += mixedRect.width / 2 - 4;
                GUI.Label(mixedRect, "_");
            }
            else if (prop.textureValue != null)
            {
                GUI.DrawTexture(preview_rect, prop.textureValue);
            }
            GUI.DrawTexture(preview_rect_border, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 0, Color.grey, 3, 5);

            //selection button and pinging
            Rect select_rect = new Rect(preview_rect);

            select_rect.height = 12;
            select_rect.y     += preview_rect.height - 12;
            if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == texturePickerWindow)
            {
                prop.textureValue = (Texture)EditorGUIUtility.GetObjectPickerObject();
                ThryEditor.repaint();
            }
            if (Event.current.commandName == "ObjectSelectorClosed" && EditorGUIUtility.GetObjectPickerControlID() == texturePickerWindow)
            {
                texturePickerWindow = -1;
            }
            if (GUI.Button(select_rect, "Select", EditorStyles.miniButton))
            {
                EditorGUIUtility.ShowObjectPicker <Texture>(prop.textureValue, false, "", 0);
                texturePickerWindow = EditorGUIUtility.GetObjectPickerControlID();
            }
            else if (Event.current.type == EventType.MouseDown && preview_rect.Contains(Event.current.mousePosition))
            {
                EditorGUIUtility.PingObject(prop.textureValue);
            }

            if (!skip_drag_and_drop_handling)
            {
                if ((ThryEditor.input.is_drag_drop_event) && preview_rect.Contains(ThryEditor.input.mouse_position) && DragAndDrop.objectReferences[0] is Texture)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    if (ThryEditor.input.is_drop_event)
                    {
                        DragAndDrop.AcceptDrag();
                        prop.textureValue = (Texture)DragAndDrop.objectReferences[0];
                    }
                }
            }

            //scale offset rect
            if (hasFoldoutProperties)
            {
                if (DrawingData.currentTexProperty.hasScaleOffset)
                {
                    Rect scale_offset_rect = new Rect(position);
                    scale_offset_rect.y     += 37;
                    scale_offset_rect.width -= 2 + preview_rect.width + 10;
                    editor.TextureScaleOffsetProperty(scale_offset_rect, prop);
                }

                PropertyOptions options = DrawingData.currentTexProperty.options;
                if (options.reference_properties != null)
                {
                    foreach (string r_property in options.reference_properties)
                    {
                        ThryEditor.ShaderProperty property = ThryEditor.currentlyDrawing.propertyDictionary[r_property];
                        EditorGUI.indentLevel *= 2;
                        ThryEditor.currentlyDrawing.editor.ShaderProperty(property.materialProperty, property.content);
                        EditorGUI.indentLevel /= 2;
                    }
                }
            }

            Rect label_rect = new Rect(position);

            label_rect.x += 2;
            label_rect.y += 2;
            GUI.Label(label_rect, label);

            GUILayoutUtility.GetRect(0, 5);

            DrawingData.lastGuiObjectHeaderRect = position;
            DrawingData.lastGuiObjectRect       = border;
        }
예제 #3
0
        private static void GUIGradients()
        {
            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
            Text("gradient_name", SETTINGS_CONTENT[(int)SETTINGS_IDX.gradient_file_name], false);
            string gradient_name = Config.Get().gradient_name;

            if (gradient_name.Contains("<hash>"))
            {
                GUILayout.Label("Good naming.", Styles.Get().greenStyle, GUILayout.ExpandWidth(false));
            }
            else if (gradient_name.Contains("<material>"))
            {
                if (gradient_name.Contains("<prop>"))
                {
                    GUILayout.Label("Good naming.", Styles.Get().greenStyle, GUILayout.ExpandWidth(false));
                }
                else
                {
                    GUILayout.Label("Consider adding <hash> or <prop>.", Styles.Get().yellowStyle, GUILayout.ExpandWidth(false));
                }
            }
            else if (gradient_name.Contains("<prop>"))
            {
                GUILayout.Label("Consider adding <material>.", Styles.Get().yellowStyle, GUILayout.ExpandWidth(false));
            }
            else
            {
                GUILayout.Label("Add <material> <hash> or <prop> to destingish between gradients.", Styles.Get().redStyle, GUILayout.ExpandWidth(false));
            }
            GUILayout.EndHorizontal();
        }
예제 #4
0
        private void GUIModulesInstalation()
        {
            if (ModuleHandler.GetModules() == null)
            {
                return;
            }
            if (ModuleHandler.GetModules().Count > 0)
            {
                GUILayout.Label(Locale.editor.Get("header_modules"), EditorStyles.boldLabel);
            }
            bool disabled = false;

            foreach (ModuleHeader module in ModuleHandler.GetModules())
            {
                if (module.is_being_installed_or_removed)
                {
                    disabled = true;
                }
            }
            EditorGUI.BeginDisabledGroup(disabled);
            foreach (ModuleHeader module in ModuleHandler.GetModules())
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginDisabledGroup(!module.available_requirement_fullfilled);
                EditorGUI.BeginChangeCheck();
                bool is_installed     = Helper.ClassExists(module.available_module.classname);
                bool update_available = is_installed;
                if (module.installed_module != null)
                {
                    update_available = Helper.compareVersions(module.installed_module.version, module.available_module.version) == 1;
                }
                string displayName = module.available_module.name;
                if (module.installed_module != null)
                {
                    displayName += " v" + module.installed_module.version;
                }

                bool install = GUILayout.Toggle(is_installed, new GUIContent(displayName, module.available_module.description), GUILayout.ExpandWidth(false));
                if (EditorGUI.EndChangeCheck())
                {
                    ModuleHandler.InstallRemoveModule(module, install);
                }
                if (update_available)
                {
                    if (GUILayout.Button("update to v" + module.available_module.version, GUILayout.ExpandWidth(false)))
                    {
                        ModuleHandler.UpdateModule(module);
                    }
                }
                EditorGUI.EndDisabledGroup();
                if (module.available_module.requirement != null && (update_available || !is_installed))
                {
                    if (module.available_requirement_fullfilled)
                    {
                        GUILayout.Label(Locale.editor.Get("requirements") + ": " + module.available_module.requirement.ToString(), Styles.Get().greenStyle);
                    }
                    else
                    {
                        GUILayout.Label(Locale.editor.Get("requirements") + ": " + module.available_module.requirement.ToString(), Styles.Get().redStyle);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUI.EndDisabledGroup();
        }
예제 #5
0
 private void GUINotification()
 {
     if (isFirstPopop)
     {
         GUILayout.Label(" Thry Shader Editor successfully installed. This is the editor settings window.", Styles.Get().greenStyle);
     }
     else if (updatedVersion == -1)
     {
         GUILayout.Label(" Thry editor has been updated", Styles.Get().greenStyle);
     }
     else if (updatedVersion == 1)
     {
         GUILayout.Label(" Warning: The Version of Thry Editor has declined", Styles.Get().yellowStyle);
     }
 }