示例#1
0
		public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
		{
			Stack<MaterialProperty> cProps = new Stack<MaterialProperty>();
			for (int i = 0; i < 4; i++)
			{
				if (i == 0)
				{
					cProps.Push(prop);
					continue;
				}

				var p = LWGUI.FindProp(colorStr[i - 1], props);
				if (p != null && p.type == MaterialProperty.PropType.Color)
					cProps.Push(p);
			}

			int count = cProps.Count;

			var rect = EditorGUILayout.GetControlRect();

			var p1 = cProps.Pop();
			EditorGUI.showMixedValue = p1.hasMixedValue;
			editor.ColorProperty(rect, p1, label.text);

			for (int i = 1; i < count; i++)
			{
				var cProp = cProps.Pop();
				EditorGUI.showMixedValue = cProp.hasMixedValue;
				Rect r = new Rect(rect);
				var interval = 13 * i * (-0.25f + EditorGUI.indentLevel * 1.25f);
				float w = propRight * (0.8f + EditorGUI.indentLevel * 0.2f);
				r.xMin += r.width - w * (i + 1) + interval;
				r.xMax -= w * i - interval;

				EditorGUI.BeginChangeCheck();
				Color src, dst;
				if (isHSV)
					src = Func.HSVToRGB(cProp.colorValue.linear).gamma;
				else
					src = cProp.colorValue;
				var hdr = (prop.flags & MaterialProperty.PropFlags.HDR) != MaterialProperty.PropFlags.None;
				dst = EditorGUI.ColorField(r, GUIContent.none, src, true, true, hdr);
				if (EditorGUI.EndChangeCheck())
				{
					if (isHSV)
						cProp.colorValue = Func.RGBToHSV(dst.linear).gamma;
					else
						cProp.colorValue = dst;
				}
			}

			EditorGUI.showMixedValue = false;
			Func.SetShaderKeyWord(editor.targets, preHSVKeyWord, isHSV);
		}
 public static MaterialProperty[] GetProperties(MaterialEditor editor)
 {
     if (editor.customShaderGUI != null && editor.customShaderGUI is LWGUI)
     {
         LWGUI gui = editor.customShaderGUI as LWGUI;
         return gui.props;
     }
     else
     {
         Debug.LogWarning("Please add \"CustomEditor \"JTRP.ShaderDrawer.LWGUI\"\" to the end of your shader!");
         return null;
     }
 }
示例#3
0
        public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            EditorGUI.ColorField(new Rect(-999, 0, 0, 0), new Color(0, 0, 0, 0));

            var r = EditorGUILayout.GetControlRect();
            MaterialProperty p = null;

            if (extraPropName != "" && extraPropName != "_")
            {
                p = LWGUI.FindProp(extraPropName, props, true);
            }

            if (p != null)
            {
                //Rect rect = Rect.zero;
                Rect rect = new Rect(0, 0, 0, 0);
                if (p.type == MaterialProperty.PropType.Range)
                {
                    var w = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 0;
                    rect = MaterialEditor.GetRectAfterLabelWidth(r);
                    EditorGUIUtility.labelWidth = w;
                }
                else
                {
                    rect = MaterialEditor.GetRectAfterLabelWidth(r);
                }

                editor.TexturePropertyMiniThumbnail(r, prop, label.text, label.tooltip);

                var i = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                editor.ShaderProperty(rect, p, string.Empty);
                EditorGUI.indentLevel = i;
            }
            else
            {
                EditorGUI.showMixedValue = prop.hasMixedValue;
                editor.TexturePropertyMiniThumbnail(r, prop, label.text, label.tooltip);
            }
            EditorGUI.showMixedValue = false;
        }
        public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            var r = EditorGUILayout.GetControlRect(true);

            if (extraPropName != "" && extraPropName != "_")
            {
                var p = LWGUI.FindProp(extraPropName, props, true);
                if (p != null)
                {
                    EditorGUI.showMixedValue = p.hasMixedValue;
                    editor.ShaderProperty(r, p, " ");
                }
                EditorGUI.showMixedValue = prop.hasMixedValue;
                editor.TexturePropertyMiniThumbnail(r, prop, label.text, label.tooltip);
            }
            else
            {
                EditorGUI.ColorField(new Rect(-999, 0, 0, 0), new Color(0, 0, 0, 0));
                EditorGUI.showMixedValue = prop.hasMixedValue;
                editor.TexturePropertyMiniThumbnail(r, prop, label.text, label.tooltip);
            }
            EditorGUI.showMixedValue = false;
        }