Example #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();
        }
Example #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);
            }
        }
Example #3
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            Init();
            Rect border_position = new Rect(position.x + EditorGUIUtility.labelWidth - 15, position.y, position.width - EditorGUIUtility.labelWidth - position.x + 15, position.height);

            EditorGUI.BeginChangeCheck();
            curve = EditorGUI.CurveField(border_position, curve);
            if (EditorGUI.EndChangeCheck())
            {
                UpdateCurveTexture(prop);
            }

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

            CheckWindowForCurveEditor();

            if (window == null && !saved)
            {
                Save(prop);
            }
        }
Example #4
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);
            }
        }
Example #5
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            Rect texturePosition = new Rect(position.x, position.y, EditorGUIUtility.labelWidth, position.height);
            Rect buttonPosition  = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, position.width - EditorGUIUtility.labelWidth - position.x, position.height);

            LoadType();
            if (_doesGradientFloodTypeExist)
            {
                if (GUI.Button(buttonPosition, buttonText))
                {
                    ShaderEditor.input.Use();
                    Init();
                    _showGui = !_showGui;
                }
            }
            if (_showGui && _hasGradientFoolTool)
            {
                this.prop = prop;
                _onGui.Invoke(_gradientFloodObject, new object[0]);
            }
            GuiHelper.drawSmallTextureProperty(texturePosition, prop, label, editor, DrawingData.currentTexProperty.hasFoldoutProperties);
        }
Example #6
0
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     GuiHelper.drawSmallTextureProperty(position, prop, label, editor, ((ThryEditor.TextureProperty)ThryEditor.currentlyDrawing.currentProperty).hasScaleOffset, true);
 }
Example #7
0
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     GuiHelper.drawSmallTextureProperty(position, prop, label, editor, ((TextureProperty)ShaderEditor.active.currentProperty).hasScaleOffset);
 }