更新
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace GraphicsCat.MarkupShaderGUIInternal
|
||||
{
|
||||
public class DrawerBase : MaterialPropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44bdec5ea5fc66045bba90e4b0ac2487
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/MarkupShaderGUI/Editor/MaterialPropertyDrawers/DrawerBase.cs
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 500e4264ac254614db0b04ab2f902f95
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GraphicsCat.MarkupShaderGUIInternal.Experimental
|
||||
{
|
||||
internal class IntEnum : MaterialPropertyDrawer
|
||||
{
|
||||
private readonly string[] m_Names;
|
||||
|
||||
public IntEnum(params string[] names)
|
||||
{
|
||||
m_Names = names;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
if (prop.propertyType != UnityEngine.Rendering.ShaderPropertyType.Float && prop.propertyType != UnityEngine.Rendering.ShaderPropertyType.Int)
|
||||
{
|
||||
EditorGUI.LabelField(position, label, "Use with Float or Int only.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Preserve previous mixed value state
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
int currentValue = PropertyUtils.GetAsInt(prop);
|
||||
if (currentValue < 0 || currentValue >= m_Names.Length)
|
||||
currentValue = 0;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
int newValue = EditorGUI.Popup(position, label, currentValue, m_Names);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
// Apply to all selected materials
|
||||
PropertyUtils.SetAsInt(prop, newValue);
|
||||
}
|
||||
|
||||
// Reset mixed value state
|
||||
EditorGUI.showMixedValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7680902a49d7ab74f89149a6ea7764c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/MarkupShaderGUI/Editor/MaterialPropertyDrawers/Experimental/IntEnum.cs
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,51 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace GraphicsCat.MarkupShaderGUIInternal
|
||||
{
|
||||
public class FloatRange : DrawerBase
|
||||
{
|
||||
float m_Min;
|
||||
float m_Max;
|
||||
|
||||
public FloatRange(float min, float max)
|
||||
{
|
||||
m_Min = min;
|
||||
m_Max = max;
|
||||
}
|
||||
|
||||
public FloatRange(string min, string max)
|
||||
{
|
||||
m_Min = AttributeUtils.ParseNumber(min);
|
||||
m_Max = AttributeUtils.ParseNumber(max);
|
||||
}
|
||||
|
||||
public FloatRange(float min, string max)
|
||||
{
|
||||
m_Min = min;
|
||||
m_Max = AttributeUtils.ParseNumber(max);
|
||||
}
|
||||
|
||||
public FloatRange(string min, float max)
|
||||
{
|
||||
m_Min = AttributeUtils.ParseNumber(min);
|
||||
m_Max = max;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var value = DrawHelper.DrawFloatRange(prop.displayName, prop.floatValue, m_Min, m_Max);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
prop.floatValue = value;
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d95e281c1b08dc4cb19bccbebd4ebad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/MarkupShaderGUI/Editor/MaterialPropertyDrawers/FloatRange.cs
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,34 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GraphicsCat.MarkupShaderGUIInternal
|
||||
{
|
||||
public class HelpBox : DrawerBase
|
||||
{
|
||||
private MessageType m_MessageType = MessageType.None;
|
||||
|
||||
public HelpBox()
|
||||
{
|
||||
}
|
||||
|
||||
public HelpBox(string messageType)
|
||||
{
|
||||
switch (messageType)
|
||||
{
|
||||
case "Info": m_MessageType = MessageType.Info; break;
|
||||
case "Warning": m_MessageType = MessageType.Warning; break;
|
||||
case "Error": m_MessageType = MessageType.Error; break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
var message = prop.displayName;
|
||||
EditorGUILayout.HelpBox(message, m_MessageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc4496d4ab0501c4f8426d8900371a3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/MarkupShaderGUI/Editor/MaterialPropertyDrawers/HelpBox.cs
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,34 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace GraphicsCat.MarkupShaderGUIInternal
|
||||
{
|
||||
public class MiniTexture : DrawerBase
|
||||
{
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
var rect = EditorGUILayout.GetControlRect(true, 20f, EditorStyles.layerMaskField);
|
||||
editor.TexturePropertyMiniThumbnail(rect, prop, "", label);
|
||||
|
||||
rect.x += 31;
|
||||
var guiContent = GUIUtils.TempContent(prop.displayName);
|
||||
EditorGUI.LabelField(rect, guiContent);
|
||||
|
||||
var material = editor.target as Material;
|
||||
var shader = material.shader;
|
||||
var texturePropIndex = shader.FindPropertyIndex(prop.name);
|
||||
ShaderPropertyFlags shaderPropFlags = shader.GetPropertyFlags(texturePropIndex);
|
||||
if ((shaderPropFlags & ShaderPropertyFlags.NoScaleOffset) == 0)
|
||||
{
|
||||
// GUI.enabled = prop.textureValue != null;
|
||||
editor.TextureScaleOffsetProperty(prop);
|
||||
// GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bd506808f8f0924b8c38e6dbbde9176
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/MarkupShaderGUI/Editor/MaterialPropertyDrawers/MiniTexture.cs
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,162 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GraphicsCat.MarkupShaderGUIInternal
|
||||
{
|
||||
public class MultiLineVector : DrawerBase
|
||||
{
|
||||
readonly string[] k_DefaultNames = new string[] { "- X", "- Y", "- Z", "- W" };
|
||||
|
||||
float m_Len;
|
||||
string[] m_Names = new string[] { "- X", "- Y", "- Z", "- W" };
|
||||
float[] m_Min = new float[] { short.MinValue, short.MinValue, short.MinValue, short.MinValue };
|
||||
float[] m_Max = new float[] { short.MaxValue, short.MaxValue, short.MaxValue, short.MaxValue };
|
||||
|
||||
public MultiLineVector(float len)
|
||||
{
|
||||
m_Len = (int)len;
|
||||
}
|
||||
|
||||
public MultiLineVector(float len, float min, float max)
|
||||
{
|
||||
m_Len = (int)len;
|
||||
m_Min = new float[4] { min, min, min, min };
|
||||
m_Max = new float[4] { max, max, max, max };
|
||||
}
|
||||
|
||||
public MultiLineVector(float len, string minStr, string maxStr)
|
||||
{
|
||||
var min = AttributeUtils.ParseNumber(minStr);
|
||||
var max = AttributeUtils.ParseNumber(maxStr);
|
||||
|
||||
m_Len = (int)len;
|
||||
m_Min = new float[4] { min, min, min, min };
|
||||
m_Max = new float[4] { max, max, max, max };
|
||||
}
|
||||
|
||||
public MultiLineVector(float len, params object[] args)
|
||||
{
|
||||
m_Len = (int)len;
|
||||
|
||||
for (int i = 0; i < args.Length && i < 4 * 3; i++)
|
||||
{
|
||||
var str = args[i].ToString();
|
||||
|
||||
int channel = i / 3;
|
||||
int slot = i % 3;
|
||||
|
||||
if (slot == 0)
|
||||
{
|
||||
m_Names[channel] = "- " + str;
|
||||
}
|
||||
else if (slot == 1)
|
||||
{
|
||||
str = str.Replace("n", "-").Replace("f", "");
|
||||
m_Min[channel] = Convert.ToSingle(str);
|
||||
}
|
||||
else if (slot == 2)
|
||||
{
|
||||
str = str.Replace("n", "-").Replace("f", "");
|
||||
m_Max[channel] = Convert.ToSingle(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
EditorGUI.LabelField(position, label);
|
||||
|
||||
var hasMixedValueX = false;
|
||||
var hasMixedValueY = false;
|
||||
var hasMixedValueZ = false;
|
||||
var hasMixedValueW = false;
|
||||
for (int i = 0, len = editor.targets.Length; i < len - 1; i++)
|
||||
{
|
||||
var mat1 = editor.targets[i] as Material;
|
||||
var mat2 = editor.targets[i + 1] as Material;
|
||||
|
||||
var value1 = mat1.GetVector(prop.name);
|
||||
var value2 = mat2.GetVector(prop.name);
|
||||
|
||||
if (value1.x != value2.x)
|
||||
hasMixedValueX = true;
|
||||
if (value1.y != value2.y)
|
||||
hasMixedValueY = true;
|
||||
if (value1.z != value2.z)
|
||||
hasMixedValueZ = true;
|
||||
if (value1.w != value2.w)
|
||||
hasMixedValueW = true;
|
||||
}
|
||||
|
||||
var propValue = prop.vectorValue;
|
||||
|
||||
var xChanged = false;
|
||||
if (m_Len >= 1)
|
||||
{
|
||||
EditorGUI.showMixedValue = hasMixedValueX;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
propValue.x = DrawHelper.DrawFloatRange(m_Names[0], propValue.x, m_Min[0], m_Max[0]);
|
||||
xChanged = EditorGUI.EndChangeCheck();
|
||||
EditorGUI.showMixedValue = false;
|
||||
}
|
||||
|
||||
var yChanged = false;
|
||||
if (m_Len >= 2)
|
||||
{
|
||||
EditorGUI.showMixedValue = hasMixedValueY;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
propValue.y = DrawHelper.DrawFloatRange(m_Names[1], propValue.y, m_Min[1], m_Max[1]);
|
||||
yChanged = EditorGUI.EndChangeCheck();
|
||||
EditorGUI.showMixedValue = false;
|
||||
}
|
||||
|
||||
var zChanged = false;
|
||||
if (m_Len >= 3)
|
||||
{
|
||||
EditorGUI.showMixedValue = hasMixedValueZ;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
propValue.z = DrawHelper.DrawFloatRange(m_Names[2], propValue.z, m_Min[2], m_Max[2]);
|
||||
zChanged = EditorGUI.EndChangeCheck();
|
||||
EditorGUI.showMixedValue = false;
|
||||
}
|
||||
|
||||
var wChanged = false;
|
||||
if (m_Len >= 4)
|
||||
{
|
||||
EditorGUI.showMixedValue = hasMixedValueW;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
propValue.w = DrawHelper.DrawFloatRange(m_Names[3], propValue.w, m_Min[3], m_Max[3]);
|
||||
wChanged = EditorGUI.EndChangeCheck();
|
||||
EditorGUI.showMixedValue = false;
|
||||
}
|
||||
|
||||
foreach (var target in prop.targets)
|
||||
{
|
||||
var mat = target as Material;
|
||||
|
||||
var newValue = mat.GetVector(prop.name);
|
||||
|
||||
if (xChanged)
|
||||
newValue.x = propValue.x;
|
||||
if (yChanged)
|
||||
newValue.y = propValue.y;
|
||||
if (zChanged)
|
||||
newValue.z = propValue.z;
|
||||
if (wChanged)
|
||||
newValue.w = propValue.w;
|
||||
|
||||
mat.SetVector(prop.name, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3880f234611f2f24ea6d64cde1f05156
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/MarkupShaderGUI/Editor/MaterialPropertyDrawers/MultiLineVector.cs
|
||||
uploadId: 820558
|
||||
Reference in New Issue
Block a user