예제 #1
0
        void DrawTexturePropertyWithScaleOffsetOpacity(MaterialProperty textureProperty, MaterialProperty opacityProperty)
        {
            Rect rect = EditorGUILayout.GetControlRect(true, MaterialEditor.GetDefaultPropertyHeight(textureProperty), EditorStyles.layerMaskField);

            materialEditor.TextureProperty(rect, textureProperty, Styles.TextureLabel, false);

            EditorGUI.BeginDisabledGroup(textureProperty.textureValue == null);

            rect    = materialEditor.GetTexturePropertyCustomArea(rect);
            rect.y -= 16f;
            materialEditor.TextureScaleOffsetProperty(rect, textureProperty);

            rect.Set(rect.x, rect.y + 3 * 16f, rect.width, 16f);
            EditorGUIUtility.labelWidth = 65f;
            rect = EditorGUI.PrefixLabel(rect, Styles.OpacityLabel);
            EditorGUIUtility.labelWidth = 0f;

            EditorGUI.showMixedValue = opacityProperty.hasMixedValue;
            EditorGUI.BeginChangeCheck();
            float opacity = EditorGUI.Slider(rect, GUIContent.none, opacityProperty.floatValue, 0f, 1f);

            if (EditorGUI.EndChangeCheck())
            {
                materialEditor.RegisterPropertyChangeUndo(Styles.OpacityLabel.text);
                opacityProperty.floatValue = opacity;
            }
            EditorGUI.showMixedValue = false;

            EditorGUI.EndDisabledGroup();
        }
    override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("GetHeight: " + label+ " RTP_MaterialProp" );

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
            if (customEditor.showFlag && (show_for_active_layer == -1 || customEditor.active_layer == show_for_active_layer) && prop.name != "dummy_end")
            {
                if (miniThumbFlag)
                {
                    return(20);
                }
                else
                {
                    if ((prop.type == MaterialProperty.PropType.Vector) && byLayerFlag)
                    {
                        return(17);
                    }
                    else
                    {
                        return(MaterialEditor.GetDefaultPropertyHeight(prop));
                    }
                }
            }
            return(-2);
        }
        return(MaterialEditor.GetDefaultPropertyHeight(prop));
    }
예제 #3
0
        public static void DrawShaderPropertySameLIne(this MaterialEditor editor, MaterialProperty property)
        {
            Rect r = EditorGUILayout.GetControlRect(true, 0, EditorStyles.layerMaskField);

            r.y     -= HEADER_HEIGHT;
            r.height = MaterialEditor.GetDefaultPropertyHeight(property);
            editor.ShaderProperty(r, property, " ");
        }
 override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (checkVisible(editor))
     {
         return(MaterialEditor.GetDefaultPropertyHeight(prop));
     }
     return(-2);
 }
예제 #5
0
    protected void Vec3Prop(GUIContent label, MaterialProperty prop)
    {
        EditorGUI.BeginChangeCheck();
        EditorGUI.showMixedValue = prop.hasMixedValue;
        Rect    controlRect = EditorGUILayout.GetControlRect(true, MaterialEditor.GetDefaultPropertyHeight(prop), EditorStyles.layerMaskField, new GUILayoutOption[0]);
        Vector3 vec3        = EditorGUI.Vector3Field(controlRect, label, new Vector3(prop.vectorValue.x, prop.vectorValue.y, prop.vectorValue.z));

        EditorGUI.showMixedValue = false;
        if (EditorGUI.EndChangeCheck())
        {
            prop.vectorValue = new Vector4(vec3.x, vec3.y, vec3.z, prop.vectorValue.w);
        }
    }
예제 #6
0
    protected void Vec2Prop(GUIContent label, MaterialProperty prop1, MaterialProperty prop2)
    {
        EditorGUI.BeginChangeCheck();
        EditorGUI.showMixedValue = prop1.hasMixedValue || prop2.hasMixedValue;
        Rect    controlRect = EditorGUILayout.GetControlRect(true, MaterialEditor.GetDefaultPropertyHeight(prop1), EditorStyles.layerMaskField, new GUILayoutOption[0]);
        Vector2 vec2        = EditorGUI.Vector2Field(controlRect, label, new Vector2(prop1.floatValue, prop2.floatValue));

        EditorGUI.showMixedValue = false;
        if (EditorGUI.EndChangeCheck())
        {
            prop1.floatValue = vec2.x;
            prop2.floatValue = vec2.y;
        }
    }
예제 #7
0
    override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("GetHeight: " + label+ " RTP_MaterialProp" );

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
            if (customEditor.showFlag)
            {
                return(20);
            }
            return(-2);
        }
        return(MaterialEditor.GetDefaultPropertyHeight(prop));
    }
예제 #8
0
        public static void DrawShurikenStyleHeader(Rect position, string text, MaterialProperty prop = null, bool alwaysOn = false)
        {
            // SurikenStyleHeader
            var style = new GUIStyle("ShurikenModuleTitle");

            style.font          = EditorStyles.boldLabel.font;
            style.fixedHeight   = 20;
            style.contentOffset = new Vector2(20, -2);
            // Draw
            position.y += 8;
            position    = EditorGUI.IndentedRect(position);
            GUI.Box(position, text, style);

            if (prop != null)
            {
                if (alwaysOn)
                {
                    if (prop.hasMixedValue || prop.floatValue == 0.0f)
                    {
                        prop.floatValue = 1.0f;
                    }
                }
                else
                {
                    // Toggle
                    Rect r = EditorGUILayout.GetControlRect(true, 0, EditorStyles.layerMaskField);
                    r.y     -= 25;
                    r.height = MaterialEditor.GetDefaultPropertyHeight(prop);

                    bool value = 0.001f < Math.Abs(prop.floatValue);
                    EditorGUI.showMixedValue = prop.hasMixedValue;
                    EditorGUI.BeginChangeCheck();
                    value = EditorGUI.Toggle(r, " ", value);
                    if (EditorGUI.EndChangeCheck())
                    {
                        prop.floatValue = value ? 1.0f : 0.0f;
                    }
                    EditorGUI.showMixedValue = false;

                    // ▼
                    var toggleRect = new Rect(position.x + 4f, position.y + 2f, 13f, 13f);
                    if (Event.current.type == EventType.Repaint)
                    {
                        EditorStyles.foldout.Draw(toggleRect, false, false, value, false);
                    }
                }
            }
        }
    override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        bool inactiveFlag = false;

        if (checkVisible(editor, ref inactiveFlag))
        {
            if (prop.floatValue == 1)
            {
                return(MaterialEditor.GetDefaultPropertyHeight(prop));
            }
            else
            {
                return(MaterialEditor.GetDefaultPropertyHeight(prop) - 5);
            }
        }
        return(-2);
    }
예제 #10
0
        void DrawNoisePreview(NoiseTextureImageChannel channel, MaterialProperty scaleOffsetProperty, MaterialProperty strengthProperty, MaterialProperty amountOfBending = null)
        {
            Vector4 scaleOffset = scaleOffsetProperty.vectorValue;
            Vector2 scale       = new Vector2(scaleOffset.x, scaleOffset.y);
            Vector2 offset      = new Vector2(scaleOffset.z, scaleOffset.w);

            Rect totalRect   = EditorGUILayout.GetControlRect(true, MaterialEditor.GetDefaultPropertyHeight(noiseTexture), EditorStyles.layerMaskField);
            Rect previewRect = totalRect;

            previewRect.xMin = previewRect.xMax - EditorGUIUtility.fieldWidth;
            Rect fieldsRect = totalRect;

            fieldsRect.yMin += 16f;
            fieldsRect.xMax -= EditorGUIUtility.fieldWidth + 2f;
            Rect scaleFieldRect    = new Rect(fieldsRect.x, fieldsRect.y, fieldsRect.width, 16f);
            Rect offsetFieldRect   = new Rect(fieldsRect.x, scaleFieldRect.y + 16f, fieldsRect.width, 16f);
            Rect strengthFieldRect = new Rect(fieldsRect.x, offsetFieldRect.y + 16f, fieldsRect.width, 16f);

            GUI.DrawTexture(previewRect, noiseTexturePreviews [(int)channel], ScaleMode.ScaleToFit);
            EditorGUI.BeginChangeCheck();
            EditorGUIUtility.labelWidth = 65f;
            scaleFieldRect = EditorGUI.PrefixLabel(scaleFieldRect, Styles.NoiseScaleLabel);
            Vector2 newScale = EditorGUI.Vector2Field(scaleFieldRect, GUIContent.none, scale);

            offsetFieldRect = EditorGUI.PrefixLabel(offsetFieldRect, Styles.NoiseOffsetLabel);
            Vector2 newOffset = EditorGUI.Vector2Field(offsetFieldRect, GUIContent.none, offset);

            strengthFieldRect        = EditorGUI.PrefixLabel(strengthFieldRect, Styles.NoiseStrengthLabel);
            EditorGUI.showMixedValue = strengthProperty.hasMixedValue;
            float strength = EditorGUI.Slider(strengthFieldRect, strengthProperty.floatValue, strengthProperty.rangeLimits.x, strengthProperty.rangeLimits.y);

            EditorGUI.showMixedValue    = false;
            EditorGUIUtility.labelWidth = 0f;
            if (EditorGUI.EndChangeCheck())
            {
                scaleOffsetProperty.vectorValue = new Vector4(newScale.x, newScale.y, newOffset.x, newOffset.y);
                strengthProperty.floatValue     = strength;
                GenerateNoise(channel, scaleOffsetProperty, strengthProperty, amountOfBending);
            }
        }
예제 #11
0
 public override float GetPropertyHeight(MaterialProperty prop, String label, MaterialEditor editor)
 {
     return(MaterialEditor.GetDefaultPropertyHeight(prop));
 }
        protected void DrawTextureProperties(string name, int distortionEffectChannelIndex)
        {
            float defaultLabelWidth = EditorGUIUtility.labelWidth;

            var textureProperty        = FindProperty(name, _materialProperties);
            var textureOpacityProperty = FindProperty(name + "Opacity", _materialProperties);

            var textureSheetKeywordState = FindProperty(_shaderKeywordsPrefix + name.Replace("Surface", "WaterSurface").TrimStart('_') + "SheetEnabled", _materialProperties);
            var textureLerpKeywordState  = FindProperty(_shaderKeywordsPrefix + name.Replace("Surface", "WaterSurface").TrimStart('_') + "SheetWithLerpEnabled", _materialProperties);
            var textureColumns           = FindProperty(name + "SheetColumns", _materialProperties);
            var textureInverseColumns    = FindProperty(name + "SheetInverseColumns", _materialProperties);
            var textureRows            = FindProperty(name + "SheetRows", _materialProperties);
            var textureInverseRows     = FindProperty(name + "SheetInverseRows", _materialProperties);
            var textureFramesPerSecond = FindProperty(name + "SheetFramesPerSecond", _materialProperties);
            var textureFramesCount     = FindProperty(name + "SheetFramesCount", _materialProperties);

            Texture texture = textureProperty.textureValue;

            Rect rect = EditorGUILayout.GetControlRect(true, MaterialEditor.GetDefaultPropertyHeight(textureProperty));

            EditorGUI.BeginChangeCheck();
            _materialEditor.TextureProperty(rect, textureProperty, string.Empty, false);
            bool hasChangedTexture = EditorGUI.EndChangeCheck();

            EditorGUI.BeginDisabledGroup(texture == null);

            rect        = _materialEditor.GetTexturePropertyCustomArea(rect);
            rect.height = 16f;
            rect.y     -= 19f;
            rect.xMin  -= 14f;
            float rectWidth = rect.width;
            float rectX     = rect.x;

            EditorGUIUtility.labelWidth = 115f;

            DrawShaderKeywordPropertyToggle(rect, textureSheetKeywordState, "Is A Texture Sheet", true);

            bool isTextureSheet = textureSheetKeywordState.floatValue == 1f;

            EditorGUI.BeginDisabledGroup(!isTextureSheet);

            rect.y += 17f;

            if (rectWidth > 190f)
            {
                rect = EditorGUI.PrefixLabel(rect, TempContent("Columns & Rows"));
                EditorGUIUtility.labelWidth = 14f;
            }
            else
            {
                EditorGUIUtility.labelWidth = 28f;
            }

            rect.xMax -= rect.width * 0.5f;

            EditorGUI.BeginChangeCheck();

            _materialEditor.ShaderProperty(rect, textureColumns, "C");

            rect.x += rect.width;

            _materialEditor.ShaderProperty(rect, textureRows, "R");

            if (EditorGUI.EndChangeCheck())
            {
                textureFramesCount.floatValue    = textureColumns.floatValue * textureRows.floatValue;
                textureInverseColumns.floatValue = 1f / textureColumns.floatValue;
                textureInverseRows.floatValue    = 1f / textureRows.floatValue;
            }

            rect.Set(rectX, rect.y + 17f, rectWidth - 43f, 16f);

            string framesPerSecondLabel;

            if (rectWidth > 190f)
            {
                EditorGUIUtility.labelWidth = 115f;
                framesPerSecondLabel        = "Frames Per Second";
            }
            else
            {
                EditorGUIUtility.labelWidth = 28f;
                framesPerSecondLabel        = "FPS";
            }
            _materialEditor.ShaderProperty(rect, textureFramesPerSecond, framesPerSecondLabel);

            rect.xMax += 43f;
            rect.xMin  = rect.xMax - 43f;

            EditorGUIUtility.labelWidth = 26f;

            DrawShaderKeywordPropertyToggle(rect, textureLerpKeywordState, "Lerp");

            EditorGUI.EndDisabledGroup();

            rect.Set(rectX, rect.y + 17f, rectWidth, 16f);

            if (rectWidth > 180f)
            {
                EditorGUIUtility.labelWidth = 48f;
                rect = EditorGUI.PrefixLabel(rect, TempContent("Opacity"));
            }
            else
            {
                EditorGUIUtility.labelWidth = 28f;
                rect = EditorGUI.PrefixLabel(rect, TempContent("O"));
            }

            _materialEditor.RangeProperty(rect, textureOpacityProperty, string.Empty);

            if (!_isWaterfallShader)
            {
                MaterialProperty scrollingSpeedX = FindProperty(name + "ScrollingSpeedX", _materialProperties);
                MaterialProperty scrollingSpeedY = FindProperty(name + "ScrollingSpeedY", _materialProperties);
                Vector2          scrollingSpeed  = new Vector2(scrollingSpeedX.floatValue, scrollingSpeedY.floatValue);

                EditorGUIUtility.labelWidth = 95f;
                var scrollingSpeedRect = EditorGUILayout.GetControlRect();
                scrollingSpeedRect.y    -= 5f;
                EditorGUI.showMixedValue = scrollingSpeedX.hasMixedValue || scrollingSpeedY.hasMixedValue;
                EditorGUI.BeginChangeCheck();
                scrollingSpeedRect = EditorGUI.PrefixLabel(scrollingSpeedRect, TempContent("Scrolling Speed"));
                scrollingSpeed     = EditorGUI.Vector2Field(scrollingSpeedRect, string.Empty, scrollingSpeed);
                if (EditorGUI.EndChangeCheck())
                {
                    scrollingSpeedX.floatValue = scrollingSpeed.x;
                    scrollingSpeedY.floatValue = scrollingSpeed.y;
                }
            }
            else if (!(name.Contains("Top") || name.Contains("Bottom")))
            {
                MaterialProperty scrollSpeed = FindProperty(name + "ScrollingSpeed", _materialProperties);
                EditorGUIUtility.labelWidth = 115f;
                var scrollSpeedRect = EditorGUILayout.GetControlRect();
                scrollSpeedRect.y -= 5f;
                _materialEditor.ShaderProperty(scrollSpeedRect, scrollSpeed, "Scrolling Speed");
            }

            if (textureProperty.textureValue != null && textureProperty.textureValue.wrapMode == TextureWrapMode.Clamp)
            {
                EditorGUILayout.HelpBox("Please make sure that the texture wrap mode is set to \"Repeat\" in the texture import settings!", MessageType.Warning);
                if (GUILayout.Button("Change Wrap Mode to \"Repeat\""))
                {
                    TextureImporter textureImportSettings = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter;
                    textureImportSettings.wrapMode = TextureWrapMode.Repeat;
                    textureImportSettings.SaveAndReimport();
                }
            }

            EditorGUIUtility.labelWidth = 55f;

            if (isTextureSheet)
            {
                DrawTextureTilingModeProperties(name, hasChangedTexture, textureColumns.floatValue, textureRows.floatValue);
            }
            else
            {
                DrawTextureTilingModeProperties(name, hasChangedTexture);
            }

            if (distortionEffectChannelIndex != -1)
            {
                DrawDistortionEffectProperties(name, distortionEffectChannelIndex);
            }

            EditorGUI.EndDisabledGroup();

            EditorGUIUtility.labelWidth = defaultLabelWidth;
        }
예제 #13
0
 public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     return(IsVisible(editor) ? MaterialEditor.GetDefaultPropertyHeight(prop) : 0);
 }
예제 #14
0
 public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     return(NeedShow(editor) ? MaterialEditor.GetDefaultPropertyHeight(prop) : -2);
 }
예제 #15
0
 Rect GetRect(MaterialProperty prop)
 {
     return(EditorGUILayout.GetControlRect(true, MaterialEditor.GetDefaultPropertyHeight(prop), EditorStyles.layerMaskField));
 }
예제 #16
0
 protected virtual float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
 {
     return(MaterialEditor.GetDefaultPropertyHeight(prop));
 }
예제 #17
0
 private static Rect GetRect(MaterialProperty prop)
 {
     return(EditorGUILayout.GetControlRect(true, MaterialEditor.GetDefaultPropertyHeight(prop)));
 }