Exemplo n.º 1
0
        private static void GUIGradients()
        {
            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
            Text("gradient_name", false);
            string gradient_name = Config.Get().gradient_name;

            if (gradient_name.Contains("<hash>"))
            {
                GUILayout.Label(Locale.editor.Get("gradient_good_naming"), Styles.Get().greenStyle, GUILayout.ExpandWidth(false));
            }
            else if (gradient_name.Contains("<material>"))
            {
                if (gradient_name.Contains("<prop>"))
                {
                    GUILayout.Label(Locale.editor.Get("gradient_good_naming"), Styles.Get().greenStyle, GUILayout.ExpandWidth(false));
                }
                else
                {
                    GUILayout.Label(Locale.editor.Get("gradient_add_hash_or_prop"), Styles.Get().yellowStyle, GUILayout.ExpandWidth(false));
                }
            }
            else if (gradient_name.Contains("<prop>"))
            {
                GUILayout.Label(Locale.editor.Get("gradient_add_material"), Styles.Get().yellowStyle, GUILayout.ExpandWidth(false));
            }
            else
            {
                GUILayout.Label(Locale.editor.Get("gradient_add_material_or_prop"), Styles.Get().redStyle, GUILayout.ExpandWidth(false));
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 2
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();
        }
        public static void DrawHeader(ref bool enabled, ref bool options, GUIContent name)
        {
            var r = EditorGUILayout.BeginHorizontal("box");

            enabled = EditorGUILayout.Toggle(enabled, EditorStyles.radioButton, GUILayout.MaxWidth(15.0f));
            options = GUI.Toggle(r, options, GUIContent.none, new GUIStyle());
            EditorGUILayout.LabelField(name, Styles.Get().dropDownHeaderLabel);
            EditorGUILayout.EndHorizontal();
        }
        public void Foldout(int xOffset, GUIContent content, ThryEditor gui)
        {
            var style = new GUIStyle(Styles.Get().dropDownHeader);

            style.margin.left = 30 * xOffset;

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

            DrawingData.lastGuiObjectRect = rect;
            //rect with text
            GUI.Box(rect, content, style);

            PropertyOptions options = ThryEditor.currentlyDrawing.currentProperty.options;

            if (options.button_right != null && options.button_right.condition_show.Test())
            {
                Rect       buttonRect    = new Rect(rect);
                GUIContent buttoncontent = new GUIContent(options.button_right.text, options.button_right.hover);
                float      width         = Styles.Get().dropDownHeaderButton.CalcSize(buttoncontent).x;
                width            = width < rect.width / 3 ? rect.width / 3 : width;
                buttonRect.x    += buttonRect.width - width - 10;
                buttonRect.y    += 2;
                buttonRect.width = width;
                if (GUI.Button(buttonRect, buttoncontent, Styles.Get().dropDownHeaderButton))
                {
                    if (options.button_right.action != null)
                    {
                        options.button_right.action.Perform();
                    }
                }
                EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link);
            }

            var e = Event.current;

            var toggleRect = new Rect(rect.x + 4f, rect.y + 2f, 13f, 13f);

            if (e.type == EventType.Repaint)
            {
                //small arrow
                EditorStyles.foldout.Draw(toggleRect, false, false, getState(), false);
            }

            if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition) && !e.alt)
            {
                this.Toggle();
                e.Use();
            }
        }
Exemplo n.º 5
0
 private void GUINotification()
 {
     if (isFirstPopop)
     {
         GUILayout.Label(" " + Locale.editor.Get("first_install_message"), Styles.Get().greenStyle);
     }
     else if (updatedVersion == -1)
     {
         GUILayout.Label(" " + Locale.editor.Get("update_message"), Styles.Get().greenStyle);
     }
     else if (updatedVersion == 1)
     {
         GUILayout.Label(" " + Locale.editor.Get("downgrade_message"), Styles.Get().yellowStyle);
     }
 }
Exemplo n.º 6
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);
     }
 }
        public static void drawBigTextureProperty(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor, bool scaleOffset)
        {
            Rect  rect = GUILayoutUtility.GetRect(label, Styles.Get().bigTextureStyle);
            float defaultLabelWidth = EditorGUIUtility.labelWidth;
            float defaultFieldWidth = EditorGUIUtility.fieldWidth;

            editor.SetDefaultGUIWidths();
            editor.TextureProperty(position, prop, label.text, label.tooltip, scaleOffset);
            EditorGUIUtility.labelWidth         = defaultLabelWidth;
            EditorGUIUtility.fieldWidth         = defaultFieldWidth;
            DrawingData.lastGuiObjectHeaderRect = position;
            Rect object_rect = new Rect(position);

            object_rect.height           += rect.height;
            DrawingData.lastGuiObjectRect = object_rect;
        }
Exemplo n.º 8
0
        private static bool Foldout(GUIContent content, bool expanded)
        {
            var rect = GUILayoutUtility.GetRect(16f + 20f, 22f, Styles.Get().dropDownHeader);

            GUI.Box(rect, content, Styles.Get().dropDownHeader);
            var   toggleRect = new Rect(rect.x + 4f, rect.y + 2f, 13f, 13f);
            Event e          = Event.current;

            if (e.type == EventType.Repaint)
            {
                EditorStyles.foldout.Draw(toggleRect, false, false, expanded, false);
            }
            if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition) && !e.alt)
            {
                expanded = !expanded;
                e.Use();
            }
            return(expanded);
        }
 public static void drawBigTextureProperty(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor, bool scaleOffset)
 {
     GUILayoutUtility.GetRect(label, Styles.Get().bigTextureStyle);
     editor.TextureProperty(position, prop, label.text, label.tooltip, scaleOffset);
     DrawingData.lastGuiObjectRect = position;
 }
 public static void DrawMasterLabel(string shaderName)
 {
     EditorGUILayout.LabelField("<size=16>" + shaderName + "</size>", Styles.Get().masterLabel, GUILayout.MinHeight(18));
 }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        public static void drawSmallTextureProperty(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor, bool scaleOffset, bool has_panning_field = false)
        {
            Rect thumbnailPos = position;

            thumbnailPos.x += scaleOffset ? 20 : 0;
            editor.TexturePropertyMiniThumbnail(thumbnailPos, prop, label.text, (scaleOffset? "Click here for scale / offset":"") + (label.tooltip != "" ? " | " : "") + label.tooltip);
            if (scaleOffset && DrawingData.currentTexProperty != null)
            {
                //draw dropdown triangle
                thumbnailPos.x += ThryEditor.currentlyDrawing.currentProperty.xOffset * 30;
                if (Event.current.type == EventType.Repaint)
                {
                    EditorStyles.foldout.Draw(thumbnailPos, false, false, DrawingData.currentTexProperty.showScaleOffset, false);
                }
                //test click and draw scale/offset
                if (DrawingData.currentTexProperty.showScaleOffset)
                {
                    ThryEditor.currentlyDrawing.editor.TextureScaleOffsetProperty(prop);
                    if (has_panning_field && ThryEditor.currentlyDrawing.currentProperty.options.reference_property != null)
                    {
                        ThryEditor.ShaderProperty pan_property = ThryEditor.currentlyDrawing.propertyDictionary[ThryEditor.currentlyDrawing.currentProperty.options.reference_property];
                        EditorGUI.indentLevel *= 2;
                        ThryEditor.currentlyDrawing.editor.ShaderProperty(GUILayoutUtility.GetRect(pan_property.content, Styles.Get().vectorPropertyStyle), pan_property.materialProperty, pan_property.content);
                        EditorGUI.indentLevel /= 2;
                    }
                }
                if (ThryEditor.MouseClick && position.Contains(Event.current.mousePosition))
                {
                    DrawingData.currentTexProperty.showScaleOffset = !DrawingData.currentTexProperty.showScaleOffset;
                    editor.Repaint();
                }
            }

            DrawingData.lastGuiObjectRect = position;
        }
        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;
        }
Exemplo n.º 14
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();
        }