Beispiel #1
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (!is_init)
            {
                Init(prop);
            }

            EditorGUI.BeginChangeCheck();
            if (EditorGUI.EndChangeCheck())
            {
                Init(prop);
            }

            UpdateRects(position);
            if (ShaderEditor.input.MouseClick && border_position.Contains(Event.current.mousePosition))
            {
                ShaderEditor.input.Use();
                PropertyOptions options = ShaderEditor.currentlyDrawing.currentProperty.options;
                GradientEditor.Open(data, prop, options.texture, options.force_texture_options, !options.force_texture_options);
            }

            GuiHelper.drawSmallTextureProperty(position, prop, label, editor, DrawingData.currentTexProperty.hasFoldoutProperties);

            GradientField();
        }
Beispiel #2
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (!is_init)
            {
                Init(prop);
            }

            EditorGUI.BeginChangeCheck();
            GuiHelper.drawSmallTextureProperty(position, prop, label, editor, DrawingData.currentTexProperty.hasFoldoutProperties);
            if (EditorGUI.EndChangeCheck())
            {
                Init(prop);
            }

            Rect border_position   = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, Screen.width - EditorGUIUtility.labelWidth - position.x - EditorGUI.indentLevel * 15 - 10, position.height);
            Rect gradient_position = new Rect(border_position.x + 1, border_position.y + 1, border_position.width - 2, border_position.height - 2);

            Texture2D backgroundTexture = TextureHelper.GetBackgroundTexture();
            Rect      texCoordsRect     = new Rect(0, 0, gradient_position.width / backgroundTexture.width, gradient_position.height / backgroundTexture.height);

            GUI.DrawTextureWithTexCoords(gradient_position, backgroundTexture, texCoordsRect, false);

            if (data.preview_texture != null)
            {
                TextureWrapMode wrap_mode = data.preview_texture.wrapMode;
                data.preview_texture.wrapMode = TextureWrapMode.Clamp;
                bool    vertical = data.preview_texture.height > data.preview_texture.width;
                Vector2 pivot    = new Vector2();
                if (vertical)
                {
                    pivot = new Vector2(gradient_position.x, gradient_position.y + gradient_position.height);
                    GUIUtility.RotateAroundPivot(-90, pivot);
                    gradient_position.y += gradient_position.height;
                    float h = gradient_position.width;
                    gradient_position.width  = gradient_position.height;
                    gradient_position.y     += h;
                    gradient_position.height = -h;
                }
                GUI.DrawTexture(gradient_position, data.preview_texture, ScaleMode.StretchToFill, true);
                if (vertical)
                {
                    GUIUtility.RotateAroundPivot(90, pivot);
                }
                GUI.DrawTexture(border_position, data.preview_texture, ScaleMode.StretchToFill, false, 0, Color.grey, 1, 1);
                data.preview_texture.wrapMode = wrap_mode;
            }
            else
            {
                GUI.DrawTexture(border_position, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 0, Color.grey, 1, 1);
            }

            if (Event.current.type == EventType.MouseDown && border_position.Contains(Event.current.mousePosition))
            {
                GradientEditor.Open(data, prop, !ThryEditor.currentlyDrawing.currentProperty.options.force_texture_options);
            }
        }
Beispiel #3
0
        public static void Open(GradientData data, MaterialProperty prop, TextureData predefinedTextureSettings, bool force_texture_options = false, bool show_texture_options = true)
        {
            texture_settings_data = LoadTextureSettings(prop, predefinedTextureSettings, force_texture_options);
            data.gradient         = TextureHelper.GetGradient(prop.textureValue);
            GradientEditor window = (GradientEditor)EditorWindow.GetWindow(typeof(GradientEditor));

            window.privious_preview_texture = prop.textureValue;
            window.prop = prop;
            window.data = data;
            window.show_texture_options = show_texture_options;
            window.minSize = new Vector2(350, 350);
            window.Show();
        }
        public static void Open(GradientData data, MaterialProperty prop)
        {
            data.gradient         = Helper.GetGradient(prop.textureValue);
            texture_settings_data = null;
            GradientEditor window = (GradientEditor)EditorWindow.GetWindow(typeof(GradientEditor));

            window.privious_preview_texture = prop.textureValue;
            window.prop = prop;
            window.data = data;
            window.SetGradient(data.gradient);
            window.gradient_has_been_edited = false;
            window.Show();
        }
        public static void Open(GradientData data, MaterialProperty prop, bool show_texture_options = true)
        {
            data.gradient         = TextureHelper.GetGradient(prop.textureValue);
            texture_settings_data = null;
            GradientEditor window = (GradientEditor)EditorWindow.GetWindow(typeof(GradientEditor));

            window.privious_preview_texture = prop.textureValue;
            window.prop = prop;
            window.data = data;
            window.SetGradient(data.gradient);
            window.gradient_has_been_edited = false;
            window.show_texture_options     = show_texture_options;
            window.minSize = new Vector2(350, 350);
            window.Show();
        }
Beispiel #6
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (!is_init)
            {
                Init(prop);
            }

            EditorGUI.BeginChangeCheck();
            editor.TexturePropertyMiniThumbnail(position, prop, label.text, label.tooltip);
            if (EditorGUI.EndChangeCheck())
            {
                Init(prop);
            }

            Rect border_position   = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, Screen.width - EditorGUIUtility.labelWidth - position.x - EditorGUI.indentLevel * 15 - 10, position.height);
            Rect gradient_position = new Rect(border_position.x + 1, border_position.y + 1, border_position.width - 2, border_position.height - 2);

            Texture2D backgroundTexture = Helper.GetBackgroundTexture();
            Rect      texCoordsRect     = new Rect(0, 0, gradient_position.width / backgroundTexture.width, gradient_position.height / backgroundTexture.height);

            GUI.DrawTextureWithTexCoords(gradient_position, backgroundTexture, texCoordsRect, false);

            if (data.preview_texture != null)
            {
                TextureWrapMode wrap_mode = data.preview_texture.wrapMode;
                data.preview_texture.wrapMode = TextureWrapMode.Clamp;
                GUI.DrawTexture(gradient_position, data.preview_texture, ScaleMode.StretchToFill, true);
                GUI.DrawTexture(border_position, data.preview_texture, ScaleMode.StretchToFill, false, 0, Color.grey, 1, 1);
                data.preview_texture.wrapMode = wrap_mode;
            }
            else
            {
                GUI.DrawTexture(border_position, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 0, Color.grey, 1, 1);
            }

            if (Event.current.type == EventType.MouseDown && border_position.Contains(Event.current.mousePosition))
            {
                GradientEditor.Open(data, prop, !ThryEditor.currentlyDrawing.currentProperty.options.force_texture_options);
            }
        }
Beispiel #7
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (!is_init)
            {
                Init(prop);
            }

            EditorGUI.BeginChangeCheck();
            GuiHelper.drawSmallTextureProperty(position, prop, label, editor, DrawingData.currentTexProperty.hasFoldoutProperties);
            if (EditorGUI.EndChangeCheck())
            {
                Init(prop);
            }

            UpdateRects(position);
            GradientField();

            if (Event.current.type == EventType.MouseDown && border_position.Contains(Event.current.mousePosition))
            {
                GradientEditor.Open(data, prop, !ThryEditor.currentlyDrawing.currentProperty.options.force_texture_options);
            }
        }