feat: Initial commit

This commit is contained in:
2025-02-14 16:06:00 +08:00
commit da75a84e02
1056 changed files with 163517 additions and 0 deletions

View File

@@ -0,0 +1,677 @@
#if HDRP_10_7_OR_NEWER
using UnityEngine;
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
namespace TMPro.EditorUtilities
{
/// <summary>Base class for TextMesh Pro shader GUIs.</summary>
internal abstract class TMP_BaseHDRPLitShaderGUI : LightingShaderGraphGUI
{
/// <summary>Representation of a #pragma shader_feature.</summary>
/// <description>It is assumed that the first feature option is for no keyword (underscores).</description>
protected class ShaderFeature
{
public string undoLabel;
public GUIContent label;
/// <summary>The keyword labels, for display. Include the no-keyword as the first option.</summary>
public GUIContent[] keywordLabels;
/// <summary>The shader keywords. Exclude the no-keyword option.</summary>
public string[] keywords;
int m_State;
public bool Active
{
get { return m_State >= 0; }
}
public int State
{
get { return m_State; }
}
public void ReadState(Material material)
{
for (int i = 0; i < keywords.Length; i++)
{
if (material.IsKeywordEnabled(keywords[i]))
{
m_State = i;
return;
}
}
m_State = -1;
}
public void SetActive(bool active, Material material)
{
m_State = active ? 0 : -1;
SetStateKeywords(material);
}
public void DoPopup(MaterialEditor editor, Material material)
{
EditorGUI.BeginChangeCheck();
int selection = EditorGUILayout.Popup(label, m_State + 1, keywordLabels);
if (EditorGUI.EndChangeCheck())
{
m_State = selection - 1;
editor.RegisterPropertyChangeUndo(undoLabel);
SetStateKeywords(material);
}
}
void SetStateKeywords(Material material)
{
for (int i = 0; i < keywords.Length; i++)
{
if (i == m_State)
{
material.EnableKeyword(keywords[i]);
}
else
{
material.DisableKeyword(keywords[i]);
}
}
}
}
static GUIContent s_TempLabel = new GUIContent();
protected static bool s_DebugExtended;
static int s_UndoRedoCount, s_LastSeenUndoRedoCount;
static float[][] s_TempFloats =
{
null, new float[1], new float[2], new float[3], new float[4]
};
protected static GUIContent[] s_XywhVectorLabels =
{
new GUIContent("X"),
new GUIContent("Y"),
new GUIContent("W", "Width"),
new GUIContent("H", "Height")
};
protected static GUIContent[] s_LbrtVectorLabels =
{
new GUIContent("L", "Left"),
new GUIContent("B", "Bottom"),
new GUIContent("R", "Right"),
new GUIContent("T", "Top")
};
protected static GUIContent[] s_CullingTypeLabels =
{
new GUIContent("Off"),
new GUIContent("Front"),
new GUIContent("Back")
};
static TMP_BaseHDRPLitShaderGUI()
{
// Keep track of how many undo/redo events happened.
Undo.undoRedoPerformed += () => s_UndoRedoCount += 1;
}
bool m_IsNewGUI = true;
float m_DragAndDropMinY;
protected MaterialEditor m_Editor;
protected Material m_Material;
protected MaterialProperty[] m_Properties;
void PrepareGUI()
{
m_IsNewGUI = false;
ShaderUtilities.GetShaderPropertyIDs();
// New GUI just got constructed. This happens in response to a selection,
// but also after undo/redo events.
if (s_LastSeenUndoRedoCount != s_UndoRedoCount)
{
// There's been at least one undo/redo since the last time this GUI got constructed.
// Maybe the undo/redo was for this material? Assume that is was.
TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material as Material);
}
s_LastSeenUndoRedoCount = s_UndoRedoCount;
}
protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
m_Editor = materialEditor;
m_Material = materialEditor.target as Material;
this.m_Properties = properties;
if (m_IsNewGUI)
{
PrepareGUI();
}
DoDragAndDropBegin();
EditorGUI.BeginChangeCheck();
DoGUI();
if (EditorGUI.EndChangeCheck())
{
TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material);
}
DoDragAndDropEnd();
}
/// <summary>Override this method to create the specific shader GUI.</summary>
protected abstract void DoGUI();
static string[] s_PanelStateLabel = new string[] { "\t- <i>Click to collapse</i> -", "\t- <i>Click to expand</i> -" };
protected bool BeginPanel(string panel, bool expanded)
{
EditorGUI.indentLevel = 0;
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
r.x += 20;
r.width += 6;
bool enabled = GUI.enabled;
GUI.enabled = true;
expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelTitle);
r.width -= 30;
EditorGUI.LabelField(r, new GUIContent(expanded ? s_PanelStateLabel[0] : s_PanelStateLabel[1]), TMP_UIStyleManager.rightLabel);
GUI.enabled = enabled;
EditorGUI.indentLevel += 1;
EditorGUI.BeginDisabledGroup(false);
return expanded;
}
protected bool BeginPanel(string panel, ShaderFeature feature, bool expanded, bool readState = true)
{
EditorGUI.indentLevel = 0;
if (readState)
{
feature.ReadState(m_Material);
}
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
GUILayout.BeginHorizontal();
Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 20, GUILayout.Width(20f)));
bool active = EditorGUI.Toggle(r, feature.Active);
if (EditorGUI.EndChangeCheck())
{
m_Editor.RegisterPropertyChangeUndo(feature.undoLabel);
feature.SetActive(active, m_Material);
}
r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
r.width += 6;
bool enabled = GUI.enabled;
GUI.enabled = true;
expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelTitle);
r.width -= 10;
EditorGUI.LabelField(r, new GUIContent(expanded ? s_PanelStateLabel[0] : s_PanelStateLabel[1]), TMP_UIStyleManager.rightLabel);
GUI.enabled = enabled;
GUILayout.EndHorizontal();
EditorGUI.indentLevel += 1;
EditorGUI.BeginDisabledGroup(!active);
return expanded;
}
protected void EndPanel()
{
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel -= 1;
EditorGUILayout.EndVertical();
}
MaterialProperty BeginProperty(string name)
{
MaterialProperty property = FindProperty(name, m_Properties);
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = property.hasMixedValue;
m_Editor.BeginAnimatedCheck(Rect.zero, property);
return property;
}
bool EndProperty()
{
m_Editor.EndAnimatedCheck();
EditorGUI.showMixedValue = false;
return EditorGUI.EndChangeCheck();
}
protected void DoPopup(string name, string label, GUIContent[] options)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
int index = EditorGUILayout.Popup(s_TempLabel, (int)property.floatValue, options);
if (EndProperty())
{
property.floatValue = index;
}
}
protected void DoCubeMap(string name, string label)
{
DoTexture(name, label, typeof(Cubemap));
}
protected void DoTexture2D(string name, string label, bool withTilingOffset = false, string[] speedNames = null)
{
DoTexture(name, label, typeof(Texture2D), withTilingOffset, speedNames);
}
void DoTexture(string name, string label, System.Type type, bool withTilingOffset = false, string[] speedNames = null)
{
float objFieldSize = 60f;
bool smallLayout = EditorGUIUtility.currentViewWidth <= 440f && (withTilingOffset || speedNames != null);
float controlHeight = smallLayout ? objFieldSize * 2 : objFieldSize;
MaterialProperty property = FindProperty(name, m_Properties);
m_Editor.BeginAnimatedCheck(Rect.zero, property);
Rect rect = EditorGUILayout.GetControlRect(true, controlHeight);
float totalWidth = rect.width;
rect.width = EditorGUIUtility.labelWidth + objFieldSize;
rect.height = objFieldSize;
s_TempLabel.text = label;
EditorGUI.BeginChangeCheck();
Object tex = EditorGUI.ObjectField(rect, s_TempLabel, property.textureValue, type, false);
if (EditorGUI.EndChangeCheck())
{
property.textureValue = tex as Texture;
}
float additionalHeight = controlHeight - objFieldSize;
float xOffset = smallLayout ? rect.width - objFieldSize : rect.width;
rect.y += additionalHeight;
rect.x += xOffset;
rect.width = totalWidth - xOffset;
rect.height = EditorGUIUtility.singleLineHeight;
if (withTilingOffset)
{
DoTilingOffset(rect, property);
rect.y += (rect.height + 2f) * 2f;
}
m_Editor.EndAnimatedCheck();
if (speedNames != null)
{
DoUVSpeed(rect, speedNames);
}
}
void DoTilingOffset(Rect rect, MaterialProperty property)
{
float labelWidth = EditorGUIUtility.labelWidth;
int indentLevel = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
EditorGUIUtility.labelWidth = Mathf.Min(40f, rect.width * 0.40f);
Vector4 vector = property.textureScaleAndOffset;
bool changed = false;
float[] values = s_TempFloats[2];
s_TempLabel.text = "Tiling";
Rect vectorRect = EditorGUI.PrefixLabel(rect, s_TempLabel);
values[0] = vector.x;
values[1] = vector.y;
EditorGUI.BeginChangeCheck();
EditorGUI.MultiFloatField(vectorRect, s_XywhVectorLabels, values);
if (EditorGUI.EndChangeCheck())
{
vector.x = values[0];
vector.y = values[1];
changed = true;
}
rect.y += rect.height + 2f;
s_TempLabel.text = "Offset";
vectorRect = EditorGUI.PrefixLabel(rect, s_TempLabel);
values[0] = vector.z;
values[1] = vector.w;
EditorGUI.BeginChangeCheck();
EditorGUI.MultiFloatField(vectorRect, s_XywhVectorLabels, values);
if (EditorGUI.EndChangeCheck())
{
vector.z = values[0];
vector.w = values[1];
changed = true;
}
if (changed)
{
property.textureScaleAndOffset = vector;
}
EditorGUIUtility.labelWidth = labelWidth;
EditorGUI.indentLevel = indentLevel;
}
void DoUVSpeed(Rect rect, string[] names)
{
float labelWidth = EditorGUIUtility.labelWidth;
int indentLevel = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
EditorGUIUtility.labelWidth = Mathf.Min(40f, rect.width * 0.40f);
s_TempLabel.text = "Speed";
rect = EditorGUI.PrefixLabel(rect, s_TempLabel);
EditorGUIUtility.labelWidth = 10f;
rect.width = rect.width * 0.5f - 2f;
if (names.Length == 1)
{
DoFloat2(rect, names[0]);
}
else
{
DoFloat(rect, names[0], "X");
rect.x += rect.width + 4f;
DoFloat(rect, names[1], "Y");
}
EditorGUIUtility.labelWidth = labelWidth;
EditorGUI.indentLevel = indentLevel;
}
protected void DoToggle(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
bool value = EditorGUILayout.Toggle(s_TempLabel, property.floatValue == 1f);
if (EndProperty())
{
property.floatValue = value ? 1f : 0f;
}
}
protected void DoFloat(string name, string label)
{
MaterialProperty property = BeginProperty(name);
Rect rect = EditorGUILayout.GetControlRect();
rect.width = EditorGUIUtility.labelWidth + 55f;
s_TempLabel.text = label;
float value = EditorGUI.FloatField(rect, s_TempLabel, property.floatValue);
if (EndProperty())
{
property.floatValue = value;
}
}
protected void DoColor(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Color value = EditorGUI.ColorField(EditorGUILayout.GetControlRect(), s_TempLabel, property.colorValue, false, true, true);
if (EndProperty())
{
property.colorValue = value;
}
}
void DoFloat(Rect rect, string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
float value = EditorGUI.FloatField(rect, s_TempLabel, property.floatValue);
if (EndProperty())
{
property.floatValue = value;
}
}
void DoFloat2(Rect rect, string name)
{
MaterialProperty property = BeginProperty(name);
float x = EditorGUI.FloatField(rect, "X", property.vectorValue.x);
rect.x += rect.width + 4f;
float y = EditorGUI.FloatField(rect, "Y", property.vectorValue.y);
if (EndProperty())
{
property.vectorValue = new Vector2(x, y);
}
}
protected void DoOffset(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Vector2 value = EditorGUI.Vector2Field(EditorGUILayout.GetControlRect(), s_TempLabel, property.vectorValue);
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoSlider(string name, string label)
{
MaterialProperty property = BeginProperty(name);
Vector2 range = property.rangeLimits;
s_TempLabel.text = label;
float value = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, property.floatValue, range.x, range.y);
if (EndProperty())
{
property.floatValue = value;
}
}
protected void DoSlider(string name, Vector2 range, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
float value = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, property.floatValue, range.x, range.y);
if (EndProperty())
{
property.floatValue = value;
}
}
protected void DoSlider(string propertyName, string propertyField, string label)
{
MaterialProperty property = BeginProperty(propertyName);
Vector2 range = property.rangeLimits;
s_TempLabel.text = label;
Vector4 value = property.vectorValue;
switch (propertyField)
{
case "X":
value.x = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.x, range.x, range.y);
break;
case "Y":
value.y = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.y, range.x, range.y);
break;
case "Z":
value.z = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.z, range.x, range.y);
break;
case "W":
value.w = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.w, range.x, range.y);
break;
}
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoSlider(string propertyName, string propertyField, Vector2 range, string label)
{
MaterialProperty property = BeginProperty(propertyName);
s_TempLabel.text = label;
Vector4 value = property.vectorValue;
switch (propertyField)
{
case "X":
value.x = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.x, range.x, range.y);
break;
case "Y":
value.y = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.y, range.x, range.y);
break;
case "Z":
value.z = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.z, range.x, range.y);
break;
case "W":
value.w = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.w, range.x, range.y);
break;
}
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoVector2(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Vector4 value = EditorGUILayout.Vector3Field(s_TempLabel, property.vectorValue);
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoVector3(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Vector4 value = EditorGUILayout.Vector3Field(s_TempLabel, property.vectorValue);
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoVector(string name, string label, GUIContent[] subLabels)
{
MaterialProperty property = BeginProperty(name);
Rect rect = EditorGUILayout.GetControlRect();
s_TempLabel.text = label;
rect = EditorGUI.PrefixLabel(rect, s_TempLabel);
Vector4 vector = property.vectorValue;
float[] values = s_TempFloats[subLabels.Length];
for (int i = 0; i < subLabels.Length; i++)
{
values[i] = vector[i];
}
EditorGUI.MultiFloatField(rect, subLabels, values);
if (EndProperty())
{
for (int i = 0; i < subLabels.Length; i++)
{
vector[i] = values[i];
}
property.vectorValue = vector;
}
}
void DoDragAndDropBegin()
{
m_DragAndDropMinY = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)).y;
}
void DoDragAndDropEnd()
{
Rect rect = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));
Event evt = Event.current;
if (evt.type == EventType.DragUpdated)
{
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
evt.Use();
}
else if (
evt.type == EventType.DragPerform &&
Rect.MinMaxRect(rect.xMin, m_DragAndDropMinY, rect.xMax, rect.yMax).Contains(evt.mousePosition)
)
{
DragAndDrop.AcceptDrag();
evt.Use();
Material droppedMaterial = DragAndDrop.objectReferences[0] as Material;
if (droppedMaterial && droppedMaterial != m_Material)
{
PerformDrop(droppedMaterial);
}
}
}
void PerformDrop(Material droppedMaterial)
{
Texture droppedTex = droppedMaterial.GetTexture(ShaderUtilities.ID_MainTex);
if (!droppedTex)
{
return;
}
Texture currentTex = m_Material.GetTexture(ShaderUtilities.ID_MainTex);
TMP_FontAsset requiredFontAsset = null;
if (droppedTex != currentTex)
{
requiredFontAsset = TMP_EditorUtility.FindMatchingFontAsset(droppedMaterial);
if (!requiredFontAsset)
{
return;
}
}
foreach (GameObject o in Selection.gameObjects)
{
if (requiredFontAsset)
{
TMP_Text textComponent = o.GetComponent<TMP_Text>();
if (textComponent)
{
Undo.RecordObject(textComponent, "Font Asset Change");
textComponent.font = requiredFontAsset;
}
}
TMPro_EventManager.ON_DRAG_AND_DROP_MATERIAL_CHANGED(o, m_Material, droppedMaterial);
EditorUtility.SetDirty(o);
}
}
}
}
#endif

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e3795795b029fde4395e6953ce72b5a6
timeCreated: 1469844810
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,681 @@
#if HDRP_10_7_OR_NEWER
using UnityEngine;
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
namespace TMPro.EditorUtilities
{
/// <summary>Base class for TextMesh Pro shader GUIs.</summary>
#if HDRP_11_OR_NEWER
internal abstract class TMP_BaseHDRPUnlitShaderGUI : UnlitShaderGraphGUI
#else
internal abstract class TMP_BaseHDRPUnlitShaderGUI : HDUnlitGUI
#endif
{
/// <summary>Representation of a #pragma shader_feature.</summary>
/// <description>It is assumed that the first feature option is for no keyword (underscores).</description>
protected class ShaderFeature
{
public string undoLabel;
public GUIContent label;
/// <summary>The keyword labels, for display. Include the no-keyword as the first option.</summary>
public GUIContent[] keywordLabels;
/// <summary>The shader keywords. Exclude the no-keyword option.</summary>
public string[] keywords;
int m_State;
public bool Active
{
get { return m_State >= 0; }
}
public int State
{
get { return m_State; }
}
public void ReadState(Material material)
{
for (int i = 0; i < keywords.Length; i++)
{
if (material.IsKeywordEnabled(keywords[i]))
{
m_State = i;
return;
}
}
m_State = -1;
}
public void SetActive(bool active, Material material)
{
m_State = active ? 0 : -1;
SetStateKeywords(material);
}
public void DoPopup(MaterialEditor editor, Material material)
{
EditorGUI.BeginChangeCheck();
int selection = EditorGUILayout.Popup(label, m_State + 1, keywordLabels);
if (EditorGUI.EndChangeCheck())
{
m_State = selection - 1;
editor.RegisterPropertyChangeUndo(undoLabel);
SetStateKeywords(material);
}
}
void SetStateKeywords(Material material)
{
for (int i = 0; i < keywords.Length; i++)
{
if (i == m_State)
{
material.EnableKeyword(keywords[i]);
}
else
{
material.DisableKeyword(keywords[i]);
}
}
}
}
static GUIContent s_TempLabel = new GUIContent();
protected static bool s_DebugExtended;
static int s_UndoRedoCount, s_LastSeenUndoRedoCount;
static float[][] s_TempFloats =
{
null, new float[1], new float[2], new float[3], new float[4]
};
protected static GUIContent[] s_XywhVectorLabels =
{
new GUIContent("X"),
new GUIContent("Y"),
new GUIContent("W", "Width"),
new GUIContent("H", "Height")
};
protected static GUIContent[] s_LbrtVectorLabels =
{
new GUIContent("L", "Left"),
new GUIContent("B", "Bottom"),
new GUIContent("R", "Right"),
new GUIContent("T", "Top")
};
protected static GUIContent[] s_CullingTypeLabels =
{
new GUIContent("Off"),
new GUIContent("Front"),
new GUIContent("Back")
};
static TMP_BaseHDRPUnlitShaderGUI()
{
// Keep track of how many undo/redo events happened.
Undo.undoRedoPerformed += () => s_UndoRedoCount += 1;
}
bool m_IsNewGUI = true;
float m_DragAndDropMinY;
protected MaterialEditor m_Editor;
protected Material m_Material;
protected MaterialProperty[] m_Properties;
void PrepareGUI()
{
m_IsNewGUI = false;
ShaderUtilities.GetShaderPropertyIDs();
// New GUI just got constructed. This happens in response to a selection,
// but also after undo/redo events.
if (s_LastSeenUndoRedoCount != s_UndoRedoCount)
{
// There's been at least one undo/redo since the last time this GUI got constructed.
// Maybe the undo/redo was for this material? Assume that is was.
TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material as Material);
}
s_LastSeenUndoRedoCount = s_UndoRedoCount;
}
protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
m_Editor = materialEditor;
m_Material = materialEditor.target as Material;
this.m_Properties = properties;
if (m_IsNewGUI)
{
PrepareGUI();
}
DoDragAndDropBegin();
EditorGUI.BeginChangeCheck();
DoGUI();
if (EditorGUI.EndChangeCheck())
{
TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material);
}
DoDragAndDropEnd();
}
/// <summary>Override this method to create the specific shader GUI.</summary>
protected abstract void DoGUI();
static string[] s_PanelStateLabel = new string[] { "\t- <i>Click to collapse</i> -", "\t- <i>Click to expand</i> -" };
protected bool BeginPanel(string panel, bool expanded)
{
EditorGUI.indentLevel = 0;
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
r.x += 20;
r.width += 6;
bool enabled = GUI.enabled;
GUI.enabled = true;
expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelTitle);
r.width -= 30;
EditorGUI.LabelField(r, new GUIContent(expanded ? s_PanelStateLabel[0] : s_PanelStateLabel[1]), TMP_UIStyleManager.rightLabel);
GUI.enabled = enabled;
EditorGUI.indentLevel += 1;
EditorGUI.BeginDisabledGroup(false);
return expanded;
}
protected bool BeginPanel(string panel, ShaderFeature feature, bool expanded, bool readState = true)
{
EditorGUI.indentLevel = 0;
if (readState)
{
feature.ReadState(m_Material);
}
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
GUILayout.BeginHorizontal();
Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 20, GUILayout.Width(20f)));
bool active = EditorGUI.Toggle(r, feature.Active);
if (EditorGUI.EndChangeCheck())
{
m_Editor.RegisterPropertyChangeUndo(feature.undoLabel);
feature.SetActive(active, m_Material);
}
r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
r.width += 6;
bool enabled = GUI.enabled;
GUI.enabled = true;
expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelTitle);
r.width -= 10;
EditorGUI.LabelField(r, new GUIContent(expanded ? s_PanelStateLabel[0] : s_PanelStateLabel[1]), TMP_UIStyleManager.rightLabel);
GUI.enabled = enabled;
GUILayout.EndHorizontal();
EditorGUI.indentLevel += 1;
EditorGUI.BeginDisabledGroup(!active);
return expanded;
}
protected void EndPanel()
{
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel -= 1;
EditorGUILayout.EndVertical();
}
MaterialProperty BeginProperty(string name)
{
MaterialProperty property = FindProperty(name, m_Properties);
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = property.hasMixedValue;
m_Editor.BeginAnimatedCheck(Rect.zero, property);
return property;
}
bool EndProperty()
{
m_Editor.EndAnimatedCheck();
EditorGUI.showMixedValue = false;
return EditorGUI.EndChangeCheck();
}
protected void DoPopup(string name, string label, GUIContent[] options)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
int index = EditorGUILayout.Popup(s_TempLabel, (int)property.floatValue, options);
if (EndProperty())
{
property.floatValue = index;
}
}
protected void DoCubeMap(string name, string label)
{
DoTexture(name, label, typeof(Cubemap));
}
protected void DoTexture2D(string name, string label, bool withTilingOffset = false, string[] speedNames = null)
{
DoTexture(name, label, typeof(Texture2D), withTilingOffset, speedNames);
}
void DoTexture(string name, string label, System.Type type, bool withTilingOffset = false, string[] speedNames = null)
{
float objFieldSize = 60f;
bool smallLayout = EditorGUIUtility.currentViewWidth <= 440f && (withTilingOffset || speedNames != null);
float controlHeight = smallLayout ? objFieldSize * 2 : objFieldSize;
MaterialProperty property = FindProperty(name, m_Properties);
m_Editor.BeginAnimatedCheck(Rect.zero, property);
Rect rect = EditorGUILayout.GetControlRect(true, controlHeight);
float totalWidth = rect.width;
rect.width = EditorGUIUtility.labelWidth + objFieldSize;
rect.height = objFieldSize;
s_TempLabel.text = label;
EditorGUI.BeginChangeCheck();
Object tex = EditorGUI.ObjectField(rect, s_TempLabel, property.textureValue, type, false);
if (EditorGUI.EndChangeCheck())
{
property.textureValue = tex as Texture;
}
float additionalHeight = controlHeight - objFieldSize;
float xOffset = smallLayout ? rect.width - objFieldSize : rect.width;
rect.y += additionalHeight;
rect.x += xOffset;
rect.width = totalWidth - xOffset;
rect.height = EditorGUIUtility.singleLineHeight;
if (withTilingOffset)
{
DoTilingOffset(rect, property);
rect.y += (rect.height + 2f) * 2f;
}
m_Editor.EndAnimatedCheck();
if (speedNames != null)
{
DoUVSpeed(rect, speedNames);
}
}
void DoTilingOffset(Rect rect, MaterialProperty property)
{
float labelWidth = EditorGUIUtility.labelWidth;
int indentLevel = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
EditorGUIUtility.labelWidth = Mathf.Min(40f, rect.width * 0.40f);
Vector4 vector = property.textureScaleAndOffset;
bool changed = false;
float[] values = s_TempFloats[2];
s_TempLabel.text = "Tiling";
Rect vectorRect = EditorGUI.PrefixLabel(rect, s_TempLabel);
values[0] = vector.x;
values[1] = vector.y;
EditorGUI.BeginChangeCheck();
EditorGUI.MultiFloatField(vectorRect, s_XywhVectorLabels, values);
if (EditorGUI.EndChangeCheck())
{
vector.x = values[0];
vector.y = values[1];
changed = true;
}
rect.y += rect.height + 2f;
s_TempLabel.text = "Offset";
vectorRect = EditorGUI.PrefixLabel(rect, s_TempLabel);
values[0] = vector.z;
values[1] = vector.w;
EditorGUI.BeginChangeCheck();
EditorGUI.MultiFloatField(vectorRect, s_XywhVectorLabels, values);
if (EditorGUI.EndChangeCheck())
{
vector.z = values[0];
vector.w = values[1];
changed = true;
}
if (changed)
{
property.textureScaleAndOffset = vector;
}
EditorGUIUtility.labelWidth = labelWidth;
EditorGUI.indentLevel = indentLevel;
}
void DoUVSpeed(Rect rect, string[] names)
{
float labelWidth = EditorGUIUtility.labelWidth;
int indentLevel = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
EditorGUIUtility.labelWidth = Mathf.Min(40f, rect.width * 0.40f);
s_TempLabel.text = "Speed";
rect = EditorGUI.PrefixLabel(rect, s_TempLabel);
EditorGUIUtility.labelWidth = 10f;
rect.width = rect.width * 0.5f - 2f;
if (names.Length == 1)
{
DoFloat2(rect, names[0]);
}
else
{
DoFloat(rect, names[0], "X");
rect.x += rect.width + 4f;
DoFloat(rect, names[1], "Y");
}
EditorGUIUtility.labelWidth = labelWidth;
EditorGUI.indentLevel = indentLevel;
}
protected void DoToggle(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
bool value = EditorGUILayout.Toggle(s_TempLabel, property.floatValue == 1f);
if (EndProperty())
{
property.floatValue = value ? 1f : 0f;
}
}
protected void DoFloat(string name, string label)
{
MaterialProperty property = BeginProperty(name);
Rect rect = EditorGUILayout.GetControlRect();
rect.width = EditorGUIUtility.labelWidth + 55f;
s_TempLabel.text = label;
float value = EditorGUI.FloatField(rect, s_TempLabel, property.floatValue);
if (EndProperty())
{
property.floatValue = value;
}
}
protected void DoColor(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Color value = EditorGUI.ColorField(EditorGUILayout.GetControlRect(), s_TempLabel, property.colorValue, false, true, true);
if (EndProperty())
{
property.colorValue = value;
}
}
void DoFloat(Rect rect, string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
float value = EditorGUI.FloatField(rect, s_TempLabel, property.floatValue);
if (EndProperty())
{
property.floatValue = value;
}
}
void DoFloat2(Rect rect, string name)
{
MaterialProperty property = BeginProperty(name);
float x = EditorGUI.FloatField(rect, "X", property.vectorValue.x);
rect.x += rect.width + 4f;
float y = EditorGUI.FloatField(rect, "Y", property.vectorValue.y);
if (EndProperty())
{
property.vectorValue = new Vector2(x, y);
}
}
protected void DoOffset(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Vector2 value = EditorGUI.Vector2Field(EditorGUILayout.GetControlRect(), s_TempLabel, property.vectorValue);
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoSlider(string name, string label)
{
MaterialProperty property = BeginProperty(name);
Vector2 range = property.rangeLimits;
s_TempLabel.text = label;
float value = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, property.floatValue, range.x, range.y);
if (EndProperty())
{
property.floatValue = value;
}
}
protected void DoSlider(string name, Vector2 range, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
float value = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, property.floatValue, range.x, range.y);
if (EndProperty())
{
property.floatValue = value;
}
}
protected void DoSlider(string propertyName, string propertyField, string label)
{
MaterialProperty property = BeginProperty(propertyName);
Vector2 range = property.rangeLimits;
s_TempLabel.text = label;
Vector4 value = property.vectorValue;
switch (propertyField)
{
case "X":
value.x = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.x, range.x, range.y);
break;
case "Y":
value.y = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.y, range.x, range.y);
break;
case "Z":
value.z = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.z, range.x, range.y);
break;
case "W":
value.w = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.w, range.x, range.y);
break;
}
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoSlider(string propertyName, string propertyField, Vector2 range, string label)
{
MaterialProperty property = BeginProperty(propertyName);
s_TempLabel.text = label;
Vector4 value = property.vectorValue;
switch (propertyField)
{
case "X":
value.x = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.x, range.x, range.y);
break;
case "Y":
value.y = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.y, range.x, range.y);
break;
case "Z":
value.z = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.z, range.x, range.y);
break;
case "W":
value.w = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.w, range.x, range.y);
break;
}
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoVector2(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Vector4 value = EditorGUILayout.Vector3Field(s_TempLabel, property.vectorValue);
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoVector3(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Vector4 value = EditorGUILayout.Vector3Field(s_TempLabel, property.vectorValue);
if (EndProperty())
{
property.vectorValue = value;
}
}
protected void DoVector(string name, string label, GUIContent[] subLabels)
{
MaterialProperty property = BeginProperty(name);
Rect rect = EditorGUILayout.GetControlRect();
s_TempLabel.text = label;
rect = EditorGUI.PrefixLabel(rect, s_TempLabel);
Vector4 vector = property.vectorValue;
float[] values = s_TempFloats[subLabels.Length];
for (int i = 0; i < subLabels.Length; i++)
{
values[i] = vector[i];
}
EditorGUI.MultiFloatField(rect, subLabels, values);
if (EndProperty())
{
for (int i = 0; i < subLabels.Length; i++)
{
vector[i] = values[i];
}
property.vectorValue = vector;
}
}
void DoDragAndDropBegin()
{
m_DragAndDropMinY = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)).y;
}
void DoDragAndDropEnd()
{
Rect rect = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));
Event evt = Event.current;
if (evt.type == EventType.DragUpdated)
{
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
evt.Use();
}
else if (
evt.type == EventType.DragPerform &&
Rect.MinMaxRect(rect.xMin, m_DragAndDropMinY, rect.xMax, rect.yMax).Contains(evt.mousePosition)
)
{
DragAndDrop.AcceptDrag();
evt.Use();
Material droppedMaterial = DragAndDrop.objectReferences[0] as Material;
if (droppedMaterial && droppedMaterial != m_Material)
{
PerformDrop(droppedMaterial);
}
}
}
void PerformDrop(Material droppedMaterial)
{
Texture droppedTex = droppedMaterial.GetTexture(ShaderUtilities.ID_MainTex);
if (!droppedTex)
{
return;
}
Texture currentTex = m_Material.GetTexture(ShaderUtilities.ID_MainTex);
TMP_FontAsset requiredFontAsset = null;
if (droppedTex != currentTex)
{
requiredFontAsset = TMP_EditorUtility.FindMatchingFontAsset(droppedMaterial);
if (!requiredFontAsset)
{
return;
}
}
foreach (GameObject o in Selection.gameObjects)
{
if (requiredFontAsset)
{
TMP_Text textComponent = o.GetComponent<TMP_Text>();
if (textComponent)
{
Undo.RecordObject(textComponent, "Font Asset Change");
textComponent.font = requiredFontAsset;
}
}
TMPro_EventManager.ON_DRAG_AND_DROP_MATERIAL_CHANGED(o, m_Material, droppedMaterial);
EditorUtility.SetDirty(o);
}
}
}
}
#endif

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 645409e9544820042937871953f20509
timeCreated: 1469844810
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,631 @@
#if HDRP_10_7_OR_NEWER
using UnityEngine;
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
namespace TMPro.EditorUtilities
{
internal class TMP_SDF_HDRPLitShaderGUI : TMP_BaseHDRPLitShaderGUI
{
static ShaderFeature s_OutlineFeature, s_UnderlayFeature, s_BevelFeature, s_GlowFeature, s_MaskFeature;
static bool s_Face = true, s_Outline = true, s_Outline2 = true, s_Outline3 = true, s_Underlay = true, s_Lighting = true, s_Glow, s_Bevel, s_Light, s_Bump, s_Env;
static string[]
s_FaceUVSpeedName = { "_FaceUVSpeed" },
s_FaceUvSpeedNames = { "_FaceUVSpeedX", "_FaceUVSpeedY" },
s_OutlineUvSpeedNames = { "_OutlineUVSpeedX", "_OutlineUVSpeedY" },
s_OutlineUvSpeedName = { "_OutlineUVSpeed" };
/// <summary>
///
/// </summary>
static TMP_SDF_HDRPLitShaderGUI()
{
s_OutlineFeature = new ShaderFeature()
{
undoLabel = "Outline",
keywords = new[] { "OUTLINE_ON" }
};
s_UnderlayFeature = new ShaderFeature()
{
undoLabel = "Underlay",
keywords = new[] { "UNDERLAY_ON", "UNDERLAY_INNER" },
label = new GUIContent("Underlay Type"),
keywordLabels = new[]
{
new GUIContent("None"), new GUIContent("Normal"), new GUIContent("Inner")
}
};
s_BevelFeature = new ShaderFeature()
{
undoLabel = "Bevel",
keywords = new[] { "BEVEL_ON" }
};
s_GlowFeature = new ShaderFeature()
{
undoLabel = "Glow",
keywords = new[] { "GLOW_ON" }
};
s_MaskFeature = new ShaderFeature()
{
undoLabel = "Mask",
keywords = new[] { "MASK_HARD", "MASK_SOFT" },
label = new GUIContent("Mask"),
keywordLabels = new[]
{
new GUIContent("Mask Off"), new GUIContent("Mask Hard"), new GUIContent("Mask Soft")
}
};
}
/// <summary>
///
/// </summary>
public TMP_SDF_HDRPLitShaderGUI()
{
// Remove the ShaderGraphUIBlock to avoid having duplicated properties in the UI.
uiBlocks.RemoveAll(b => b is ShaderGraphUIBlock);
}
protected override void DoGUI()
{
s_Face = BeginPanel("Face", s_Face);
if (s_Face)
{
DoFacePanel();
}
EndPanel();
// Outline panels
DoOutlinePanels();
// Underlay panel
s_Underlay = BeginPanel("Underlay", s_Underlay);
if (s_Underlay)
{
DoUnderlayPanel();
}
EndPanel();
// Lighting panel
DrawLightingPanel();
/*
if (m_Material.HasProperty(ShaderUtilities.ID_GlowColor))
{
s_Glow = BeginPanel("Glow", s_GlowFeature, s_Glow);
if (s_Glow)
{
DoGlowPanel();
}
EndPanel();
}
*/
s_DebugExtended = BeginPanel("Debug Settings", s_DebugExtended);
if (s_DebugExtended)
{
DoDebugPanelSRP();
}
EndPanel();
EditorGUILayout.Space();
EditorGUILayout.Space();
// Draw HDRP panels
uiBlocks.OnGUI(m_Editor, m_Properties);
#if HDRP_12_OR_NEWER
ValidateMaterial(m_Material);
#else
SetupMaterialKeywordsAndPass(m_Material);
#endif
}
void DoFacePanel()
{
EditorGUI.indentLevel += 1;
DoColor("_FaceColor", "Color");
if (m_Material.HasProperty(ShaderUtilities.ID_FaceTex))
{
if (m_Material.HasProperty("_FaceUVSpeedX"))
{
DoTexture2D("_FaceTex", "Texture", true, s_FaceUvSpeedNames);
}
else if (m_Material.HasProperty("_FaceUVSpeed"))
{
DoTexture2D("_FaceTex", "Texture", true, s_FaceUVSpeedName);
}
else
{
DoTexture2D("_FaceTex", "Texture", true);
}
}
if (m_Material.HasProperty("_Softness"))
{
DoSlider("_Softness", "X", new Vector2(0, 1), "Softness");
}
if (m_Material.HasProperty("_OutlineSoftness"))
{
DoSlider("_OutlineSoftness", "Softness");
}
if (m_Material.HasProperty(ShaderUtilities.ID_FaceDilate))
{
DoSlider("_FaceDilate", "Dilate");
if (m_Material.HasProperty(ShaderUtilities.ID_Shininess))
{
DoSlider("_FaceShininess", "Gloss");
}
}
if (m_Material.HasProperty(ShaderUtilities.ID_IsoPerimeter))
{
DoSlider("_IsoPerimeter", "X", new Vector2(-1, 1), "Dilate");
}
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoOutlinePanels()
{
s_Outline = BeginPanel("Outline 1", s_Outline);
if (s_Outline)
DoOutlinePanelWithTexture(1, "Y", "Color");
EndPanel();
s_Outline2 = BeginPanel("Outline 2", s_Outline2);
if (s_Outline2)
DoOutlinePanel(2, "Z", "Color");
EndPanel();
s_Outline3 = BeginPanel("Outline 3", s_Outline3);
if (s_Outline3)
DoOutlinePanel(3, "W", "Color");
EndPanel();
}
void DoOutlinePanel(int outlineID, string propertyField, string label)
{
EditorGUI.indentLevel += 1;
DoColor("_OutlineColor" + outlineID, label);
if (outlineID != 3)
DoOffset("_OutlineOffset" + outlineID, "Offset");
else
{
if (m_Material.GetFloat(ShaderUtilities.ID_OutlineMode) == 0)
DoOffset("_OutlineOffset" + outlineID, "Offset");
}
DoSlider("_Softness", propertyField, new Vector2(0, 1), "Softness");
DoSlider("_IsoPerimeter", propertyField, new Vector2(-1, 1), "Dilate");
if (outlineID == 3)
{
DoToggle("_OutlineMode", "Outline Mode");
}
if (m_Material.HasProperty("_OutlineShininess"))
{
//DoSlider("_OutlineShininess", "Gloss");
}
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoOutlinePanelWithTexture(int outlineID, string propertyField, string label)
{
EditorGUI.indentLevel += 1;
DoColor("_OutlineColor" + outlineID, label);
if (m_Material.HasProperty(ShaderUtilities.ID_OutlineTex))
{
if (m_Material.HasProperty("_OutlineUVSpeedX"))
{
DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedNames);
}
else if (m_Material.HasProperty("_OutlineUVSpeed"))
{
DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedName);
}
else
{
DoTexture2D("_OutlineTex", "Texture", true);
}
}
DoOffset("_OutlineOffset" + outlineID, "Offset");
DoSlider("_Softness", propertyField, new Vector2(0, 1), "Softness");
DoSlider("_IsoPerimeter", propertyField, new Vector2(-1, 1), "Dilate");
if (m_Material.HasProperty("_OutlineShininess"))
{
//DoSlider("_OutlineShininess", "Gloss");
}
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoUnderlayPanel()
{
EditorGUI.indentLevel += 1;
if (m_Material.HasProperty(ShaderUtilities.ID_IsoPerimeter))
{
DoColor("_UnderlayColor", "Color");
DoSlider("_UnderlayOffset", "X", new Vector2(-1, 1), "Offset X");
DoSlider("_UnderlayOffset", "Y", new Vector2(-1, 1), "Offset Y");
DoSlider("_UnderlayDilate", new Vector2(-1, 1), "Dilate");
DoSlider("_UnderlaySoftness", new Vector2(0, 1), "Softness");
}
else
{
s_UnderlayFeature.DoPopup(m_Editor, m_Material);
DoColor("_UnderlayColor", "Color");
DoSlider("_UnderlayOffsetX", "Offset X");
DoSlider("_UnderlayOffsetY", "Offset Y");
DoSlider("_UnderlayDilate", "Dilate");
DoSlider("_UnderlaySoftness", "Softness");
}
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
static GUIContent[] s_BevelTypeLabels =
{
new GUIContent("Outer Bevel"),
new GUIContent("Inner Bevel")
};
void DrawLightingPanel()
{
s_Lighting = BeginPanel("Lighting", s_Lighting);
if (s_Lighting)
{
s_Bevel = BeginPanel("Bevel", s_Bevel);
if (s_Bevel)
{
DoBevelPanel();
}
EndPanel();
s_Light = BeginPanel("Local Lighting", s_Light);
if (s_Light)
{
DoLocalLightingPanel();
}
EndPanel();
/*
s_Bump = BeginPanel("Bump Map", s_Bump);
if (s_Bump)
{
DoBumpMapPanel();
}
EndPanel();
s_Env = BeginPanel("Environment Map", s_Env);
if (s_Env)
{
DoEnvMapPanel();
}
EndPanel();
*/
}
EndPanel();
}
void DoBevelPanel()
{
EditorGUI.indentLevel += 1;
DoPopup("_BevelType", "Type", s_BevelTypeLabels);
DoSlider("_BevelAmount", "Amount");
DoSlider("_BevelOffset", "Offset");
DoSlider("_BevelWidth", "Width");
DoSlider("_BevelRoundness", "Roundness");
DoSlider("_BevelClamp", "Clamp");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoLocalLightingPanel()
{
EditorGUI.indentLevel += 1;
DoSlider("_LightAngle", "Light Angle");
DoColor("_SpecularColor", "Specular Color");
DoSlider("_SpecularPower", "Specular Power");
DoSlider("_Reflectivity", "Reflectivity Power");
DoSlider("_Diffuse", "Diffuse Shadow");
DoSlider("_Ambient", "Ambient Shadow");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoSurfaceLightingPanel()
{
EditorGUI.indentLevel += 1;
DoColor("_SpecColor", "Specular Color");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoBumpMapPanel()
{
EditorGUI.indentLevel += 1;
DoTexture2D("_BumpMap", "Texture");
DoSlider("_BumpFace", "Face");
DoSlider("_BumpOutline", "Outline");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoEnvMapPanel()
{
EditorGUI.indentLevel += 1;
DoColor("_ReflectFaceColor", "Face Color");
DoColor("_ReflectOutlineColor", "Outline Color");
DoCubeMap("_Cube", "Texture");
DoVector3("_EnvMatrixRotation", "Rotation");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoGlowPanel()
{
EditorGUI.indentLevel += 1;
DoColor("_GlowColor", "Color");
DoSlider("_GlowOffset", "Offset");
DoSlider("_GlowInner", "Inner");
DoSlider("_GlowOuter", "Outer");
DoSlider("_GlowPower", "Power");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoDebugPanel()
{
EditorGUI.indentLevel += 1;
DoTexture2D("_MainTex", "Font Atlas");
DoFloat("_GradientScale", "Gradient Scale");
DoFloat("_TextureWidth", "Texture Width");
DoFloat("_TextureHeight", "Texture Height");
EditorGUILayout.Space();
DoFloat("_ScaleX", "Scale X");
DoFloat("_ScaleY", "Scale Y");
if (m_Material.HasProperty(ShaderUtilities.ID_Sharpness))
DoSlider("_Sharpness", "Sharpness");
DoSlider("_PerspectiveFilter", "Perspective Filter");
EditorGUILayout.Space();
DoFloat("_VertexOffsetX", "Offset X");
DoFloat("_VertexOffsetY", "Offset Y");
if (m_Material.HasProperty(ShaderUtilities.ID_MaskCoord))
{
EditorGUILayout.Space();
s_MaskFeature.ReadState(m_Material);
s_MaskFeature.DoPopup(m_Editor, m_Material);
if (s_MaskFeature.Active)
{
DoMaskSubgroup();
}
EditorGUILayout.Space();
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
else if (m_Material.HasProperty("_MaskTex"))
{
DoMaskTexSubgroup();
}
else if (m_Material.HasProperty(ShaderUtilities.ID_MaskSoftnessX))
{
EditorGUILayout.Space();
DoFloat("_MaskSoftnessX", "Softness X");
DoFloat("_MaskSoftnessY", "Softness Y");
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
if (m_Material.HasProperty(ShaderUtilities.ID_StencilID))
{
EditorGUILayout.Space();
DoFloat("_Stencil", "Stencil ID");
DoFloat("_StencilComp", "Stencil Comp");
}
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
bool useRatios = EditorGUILayout.Toggle("Use Ratios", !m_Material.IsKeywordEnabled("RATIOS_OFF"));
if (EditorGUI.EndChangeCheck())
{
m_Editor.RegisterPropertyChangeUndo("Use Ratios");
if (useRatios)
{
m_Material.DisableKeyword("RATIOS_OFF");
}
else
{
m_Material.EnableKeyword("RATIOS_OFF");
}
}
if (m_Material.HasProperty(ShaderUtilities.ShaderTag_CullMode))
{
EditorGUILayout.Space();
DoPopup("_CullMode", "Cull Mode", s_CullingTypeLabels);
}
EditorGUILayout.Space();
EditorGUI.BeginDisabledGroup(true);
DoFloat("_ScaleRatioA", "Scale Ratio A");
DoFloat("_ScaleRatioB", "Scale Ratio B");
DoFloat("_ScaleRatioC", "Scale Ratio C");
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoDebugPanelSRP()
{
EditorGUI.indentLevel += 1;
DoTexture2D("_MainTex", "Font Atlas");
DoFloat("_GradientScale", "Gradient Scale");
//DoFloat("_TextureWidth", "Texture Width");
//DoFloat("_TextureHeight", "Texture Height");
EditorGUILayout.Space();
/*
DoFloat("_ScaleX", "Scale X");
DoFloat("_ScaleY", "Scale Y");
if (m_Material.HasProperty(ShaderUtilities.ID_Sharpness))
DoSlider("_Sharpness", "Sharpness");
DoSlider("_PerspectiveFilter", "Perspective Filter");
EditorGUILayout.Space();
DoFloat("_VertexOffsetX", "Offset X");
DoFloat("_VertexOffsetY", "Offset Y");
if (m_Material.HasProperty(ShaderUtilities.ID_MaskCoord))
{
EditorGUILayout.Space();
s_MaskFeature.ReadState(m_Material);
s_MaskFeature.DoPopup(m_Editor, m_Material);
if (s_MaskFeature.Active)
{
DoMaskSubgroup();
}
EditorGUILayout.Space();
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
else if (m_Material.HasProperty("_MaskTex"))
{
DoMaskTexSubgroup();
}
else if (m_Material.HasProperty(ShaderUtilities.ID_MaskSoftnessX))
{
EditorGUILayout.Space();
DoFloat("_MaskSoftnessX", "Softness X");
DoFloat("_MaskSoftnessY", "Softness Y");
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
if (m_Material.HasProperty(ShaderUtilities.ID_StencilID))
{
EditorGUILayout.Space();
DoFloat("_Stencil", "Stencil ID");
DoFloat("_StencilComp", "Stencil Comp");
}
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
bool useRatios = EditorGUILayout.Toggle("Use Ratios", !m_Material.IsKeywordEnabled("RATIOS_OFF"));
if (EditorGUI.EndChangeCheck())
{
m_Editor.RegisterPropertyChangeUndo("Use Ratios");
if (useRatios)
{
m_Material.DisableKeyword("RATIOS_OFF");
}
else
{
m_Material.EnableKeyword("RATIOS_OFF");
}
}
*/
if (m_Material.HasProperty(ShaderUtilities.ShaderTag_CullMode))
{
EditorGUILayout.Space();
DoPopup("_CullMode", "Cull Mode", s_CullingTypeLabels);
}
EditorGUILayout.Space();
/*
EditorGUI.BeginDisabledGroup(true);
DoFloat("_ScaleRatioA", "Scale Ratio A");
DoFloat("_ScaleRatioB", "Scale Ratio B");
DoFloat("_ScaleRatioC", "Scale Ratio C");
EditorGUI.EndDisabledGroup();
*/
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoMaskSubgroup()
{
DoVector("_MaskCoord", "Mask Bounds", s_XywhVectorLabels);
if (Selection.activeGameObject != null)
{
Renderer renderer = Selection.activeGameObject.GetComponent<Renderer>();
if (renderer != null)
{
Rect rect = EditorGUILayout.GetControlRect();
rect.x += EditorGUIUtility.labelWidth;
rect.width -= EditorGUIUtility.labelWidth;
if (GUI.Button(rect, "Match Renderer Bounds"))
{
FindProperty("_MaskCoord", m_Properties).vectorValue = new Vector4(
0,
0,
Mathf.Round(renderer.bounds.extents.x * 1000) / 1000,
Mathf.Round(renderer.bounds.extents.y * 1000) / 1000
);
}
}
}
if (s_MaskFeature.State == 1)
{
DoFloat("_MaskSoftnessX", "Softness X");
DoFloat("_MaskSoftnessY", "Softness Y");
}
}
void DoMaskTexSubgroup()
{
EditorGUILayout.Space();
DoTexture2D("_MaskTex", "Mask Texture");
DoToggle("_MaskInverse", "Inverse Mask");
DoColor("_MaskEdgeColor", "Edge Color");
DoSlider("_MaskEdgeSoftness", "Edge Softness");
DoSlider("_MaskWipeControl", "Wipe Position");
DoFloat("_MaskSoftnessX", "Softness X");
DoFloat("_MaskSoftnessY", "Softness Y");
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
// protected override void SetupMaterialKeywordsAndPassInternal(Material material)
// {
// BaseLitGUI.SetupBaseLitKeywords(material);
// BaseLitGUI.SetupBaseLitMaterialPass(material);
// }
}
}
#endif

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 85016528879d5d644981050d1d0a4368
timeCreated: 1469844718
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,642 @@
#if HDRP_10_7_OR_NEWER
using UnityEngine;
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
namespace TMPro.EditorUtilities
{
internal class TMP_SDF_HDRPUnlitShaderGUI : TMP_BaseHDRPUnlitShaderGUI
{
#if !HDRP_11_OR_NEWER
const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit;
private readonly MaterialUIBlockList uiBlocks = new MaterialUIBlockList
{
new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: surfaceOptionFeatures),
new ShaderGraphUIBlock(MaterialUIBlock.Expandable.ShaderGraph, ShaderGraphUIBlock.Features.Unlit),
new AdvancedOptionsUIBlock(MaterialUIBlock.Expandable.Advance, ~AdvancedOptionsUIBlock.Features.SpecularOcclusion)
};
#endif
static ShaderFeature s_OutlineFeature, s_UnderlayFeature, s_BevelFeature, s_GlowFeature, s_MaskFeature;
static bool s_Face = true, s_Outline = true, s_Outline2 = true, s_Outline3 = true, s_Underlay = true, s_Lighting = true, s_Glow, s_Bevel, s_Light, s_Bump, s_Env;
static string[]
s_FaceUVSpeedName = { "_FaceUVSpeed" },
s_FaceUvSpeedNames = { "_FaceUVSpeedX", "_FaceUVSpeedY" },
s_OutlineUvSpeedNames = { "_OutlineUVSpeedX", "_OutlineUVSpeedY" },
s_OutlineUvSpeedName = { "_OutlineUVSpeed" };
/// <summary>
///
/// </summary>
static TMP_SDF_HDRPUnlitShaderGUI()
{
s_OutlineFeature = new ShaderFeature()
{
undoLabel = "Outline",
keywords = new[] { "OUTLINE_ON" }
};
s_UnderlayFeature = new ShaderFeature()
{
undoLabel = "Underlay",
keywords = new[] { "UNDERLAY_ON", "UNDERLAY_INNER" },
label = new GUIContent("Underlay Type"),
keywordLabels = new[]
{
new GUIContent("None"), new GUIContent("Normal"), new GUIContent("Inner")
}
};
s_BevelFeature = new ShaderFeature()
{
undoLabel = "Bevel",
keywords = new[] { "BEVEL_ON" }
};
s_GlowFeature = new ShaderFeature()
{
undoLabel = "Glow",
keywords = new[] { "GLOW_ON" }
};
s_MaskFeature = new ShaderFeature()
{
undoLabel = "Mask",
keywords = new[] { "MASK_HARD", "MASK_SOFT" },
label = new GUIContent("Mask"),
keywordLabels = new[]
{
new GUIContent("Mask Off"), new GUIContent("Mask Hard"), new GUIContent("Mask Soft")
}
};
}
/// <summary>
///
/// </summary>
public TMP_SDF_HDRPUnlitShaderGUI()
{
// Remove the ShaderGraphUIBlock to avoid having duplicated properties in the UI.
uiBlocks.RemoveAll(b => b is ShaderGraphUIBlock);
}
protected override void DoGUI()
{
s_Face = BeginPanel("Face", s_Face);
if (s_Face)
{
DoFacePanel();
}
EndPanel();
// Outline panels
DoOutlinePanels();
// Underlay panel
s_Underlay = BeginPanel("Underlay", s_Underlay);
if (s_Underlay)
{
DoUnderlayPanel();
}
EndPanel();
// Lighting panel
DrawLightingPanel();
/*
if (m_Material.HasProperty(ShaderUtilities.ID_GlowColor))
{
s_Glow = BeginPanel("Glow", s_GlowFeature, s_Glow);
if (s_Glow)
{
DoGlowPanel();
}
EndPanel();
}
*/
s_DebugExtended = BeginPanel("Debug Settings", s_DebugExtended);
if (s_DebugExtended)
{
DoDebugPanelSRP();
}
EndPanel();
EditorGUILayout.Space();
EditorGUILayout.Space();
// Draw HDRP panels
uiBlocks.OnGUI(m_Editor, m_Properties);
#if HDRP_12_OR_NEWER
ValidateMaterial(m_Material);
#else
SetupMaterialKeywordsAndPass(m_Material);
#endif
}
void DoFacePanel()
{
EditorGUI.indentLevel += 1;
DoColor("_FaceColor", "Color");
if (m_Material.HasProperty(ShaderUtilities.ID_FaceTex))
{
if (m_Material.HasProperty("_FaceUVSpeedX"))
{
DoTexture2D("_FaceTex", "Texture", true, s_FaceUvSpeedNames);
}
else if (m_Material.HasProperty("_FaceUVSpeed"))
{
DoTexture2D("_FaceTex", "Texture", true, s_FaceUVSpeedName);
}
else
{
DoTexture2D("_FaceTex", "Texture", true);
}
}
if (m_Material.HasProperty("_Softness"))
{
DoSlider("_Softness", "X", new Vector2(0, 1), "Softness");
}
if (m_Material.HasProperty("_OutlineSoftness"))
{
DoSlider("_OutlineSoftness", "Softness");
}
if (m_Material.HasProperty(ShaderUtilities.ID_FaceDilate))
{
DoSlider("_FaceDilate", "Dilate");
if (m_Material.HasProperty(ShaderUtilities.ID_Shininess))
{
DoSlider("_FaceShininess", "Gloss");
}
}
if (m_Material.HasProperty(ShaderUtilities.ID_IsoPerimeter))
{
DoSlider("_IsoPerimeter", "X", new Vector2(-1, 1), "Dilate");
}
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoOutlinePanels()
{
s_Outline = BeginPanel("Outline 1", s_Outline);
if (s_Outline)
DoOutlinePanelWithTexture(1, "Y", "Color");
EndPanel();
s_Outline2 = BeginPanel("Outline 2", s_Outline2);
if (s_Outline2)
DoOutlinePanel(2, "Z", "Color");
EndPanel();
s_Outline3 = BeginPanel("Outline 3", s_Outline3);
if (s_Outline3)
DoOutlinePanel(3, "W", "Color");
EndPanel();
}
void DoOutlinePanel(int outlineID, string propertyField, string label)
{
EditorGUI.indentLevel += 1;
DoColor("_OutlineColor" + outlineID, label);
if (outlineID != 3)
DoOffset("_OutlineOffset" + outlineID, "Offset");
else
{
if (m_Material.GetFloat(ShaderUtilities.ID_OutlineMode) == 0)
DoOffset("_OutlineOffset" + outlineID, "Offset");
}
DoSlider("_Softness", propertyField, new Vector2(0, 1), "Softness");
DoSlider("_IsoPerimeter", propertyField, new Vector2(-1, 1), "Dilate");
if (outlineID == 3)
{
DoToggle("_OutlineMode", "Outline Mode");
}
if (m_Material.HasProperty("_OutlineShininess"))
{
//DoSlider("_OutlineShininess", "Gloss");
}
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoOutlinePanelWithTexture(int outlineID, string propertyField, string label)
{
EditorGUI.indentLevel += 1;
DoColor("_OutlineColor" + outlineID, label);
if (m_Material.HasProperty(ShaderUtilities.ID_OutlineTex))
{
if (m_Material.HasProperty("_OutlineUVSpeedX"))
{
DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedNames);
}
else if (m_Material.HasProperty("_OutlineUVSpeed"))
{
DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedName);
}
else
{
DoTexture2D("_OutlineTex", "Texture", true);
}
}
DoOffset("_OutlineOffset" + outlineID, "Offset");
DoSlider("_Softness", propertyField, new Vector2(0, 1), "Softness");
DoSlider("_IsoPerimeter", propertyField, new Vector2(-1, 1), "Dilate");
if (m_Material.HasProperty("_OutlineShininess"))
{
//DoSlider("_OutlineShininess", "Gloss");
}
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoUnderlayPanel()
{
EditorGUI.indentLevel += 1;
if (m_Material.HasProperty(ShaderUtilities.ID_IsoPerimeter))
{
DoColor("_UnderlayColor", "Color");
DoSlider("_UnderlayOffset", "X", new Vector2(-1, 1), "Offset X");
DoSlider("_UnderlayOffset", "Y", new Vector2(-1, 1), "Offset Y");
DoSlider("_UnderlayDilate", new Vector2(-1, 1), "Dilate");
DoSlider("_UnderlaySoftness", new Vector2(0, 1), "Softness");
}
else
{
s_UnderlayFeature.DoPopup(m_Editor, m_Material);
DoColor("_UnderlayColor", "Color");
DoSlider("_UnderlayOffsetX", "Offset X");
DoSlider("_UnderlayOffsetY", "Offset Y");
DoSlider("_UnderlayDilate", "Dilate");
DoSlider("_UnderlaySoftness", "Softness");
}
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
static GUIContent[] s_BevelTypeLabels =
{
new GUIContent("Outer Bevel"),
new GUIContent("Inner Bevel")
};
void DrawLightingPanel()
{
s_Lighting = BeginPanel("Lighting", s_Lighting);
if (s_Lighting)
{
s_Bevel = BeginPanel("Bevel", s_Bevel);
if (s_Bevel)
{
DoBevelPanel();
}
EndPanel();
s_Light = BeginPanel("Local Lighting", s_Light);
if (s_Light)
{
DoLocalLightingPanel();
}
EndPanel();
/*
s_Bump = BeginPanel("Bump Map", s_Bump);
if (s_Bump)
{
DoBumpMapPanel();
}
EndPanel();
s_Env = BeginPanel("Environment Map", s_Env);
if (s_Env)
{
DoEnvMapPanel();
}
EndPanel();
*/
}
EndPanel();
}
void DoBevelPanel()
{
EditorGUI.indentLevel += 1;
DoPopup("_BevelType", "Type", s_BevelTypeLabels);
DoSlider("_BevelAmount", "Amount");
DoSlider("_BevelOffset", "Offset");
DoSlider("_BevelWidth", "Width");
DoSlider("_BevelRoundness", "Roundness");
DoSlider("_BevelClamp", "Clamp");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoLocalLightingPanel()
{
EditorGUI.indentLevel += 1;
DoSlider("_LightAngle", "Light Angle");
DoColor("_SpecularColor", "Specular Color");
DoSlider("_SpecularPower", "Specular Power");
DoSlider("_Reflectivity", "Reflectivity Power");
DoSlider("_Diffuse", "Diffuse Shadow");
DoSlider("_Ambient", "Ambient Shadow");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoSurfaceLightingPanel()
{
EditorGUI.indentLevel += 1;
DoColor("_SpecColor", "Specular Color");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoBumpMapPanel()
{
EditorGUI.indentLevel += 1;
DoTexture2D("_BumpMap", "Texture");
DoSlider("_BumpFace", "Face");
DoSlider("_BumpOutline", "Outline");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoEnvMapPanel()
{
EditorGUI.indentLevel += 1;
DoColor("_ReflectFaceColor", "Face Color");
DoColor("_ReflectOutlineColor", "Outline Color");
DoCubeMap("_Cube", "Texture");
DoVector3("_EnvMatrixRotation", "Rotation");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoGlowPanel()
{
EditorGUI.indentLevel += 1;
DoColor("_GlowColor", "Color");
DoSlider("_GlowOffset", "Offset");
DoSlider("_GlowInner", "Inner");
DoSlider("_GlowOuter", "Outer");
DoSlider("_GlowPower", "Power");
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoDebugPanel()
{
EditorGUI.indentLevel += 1;
DoTexture2D("_MainTex", "Font Atlas");
DoFloat("_GradientScale", "Gradient Scale");
DoFloat("_TextureWidth", "Texture Width");
DoFloat("_TextureHeight", "Texture Height");
EditorGUILayout.Space();
DoFloat("_ScaleX", "Scale X");
DoFloat("_ScaleY", "Scale Y");
if (m_Material.HasProperty(ShaderUtilities.ID_Sharpness))
DoSlider("_Sharpness", "Sharpness");
DoSlider("_PerspectiveFilter", "Perspective Filter");
EditorGUILayout.Space();
DoFloat("_VertexOffsetX", "Offset X");
DoFloat("_VertexOffsetY", "Offset Y");
if (m_Material.HasProperty(ShaderUtilities.ID_MaskCoord))
{
EditorGUILayout.Space();
s_MaskFeature.ReadState(m_Material);
s_MaskFeature.DoPopup(m_Editor, m_Material);
if (s_MaskFeature.Active)
{
DoMaskSubgroup();
}
EditorGUILayout.Space();
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
else if (m_Material.HasProperty("_MaskTex"))
{
DoMaskTexSubgroup();
}
else if (m_Material.HasProperty(ShaderUtilities.ID_MaskSoftnessX))
{
EditorGUILayout.Space();
DoFloat("_MaskSoftnessX", "Softness X");
DoFloat("_MaskSoftnessY", "Softness Y");
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
if (m_Material.HasProperty(ShaderUtilities.ID_StencilID))
{
EditorGUILayout.Space();
DoFloat("_Stencil", "Stencil ID");
DoFloat("_StencilComp", "Stencil Comp");
}
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
bool useRatios = EditorGUILayout.Toggle("Use Ratios", !m_Material.IsKeywordEnabled("RATIOS_OFF"));
if (EditorGUI.EndChangeCheck())
{
m_Editor.RegisterPropertyChangeUndo("Use Ratios");
if (useRatios)
{
m_Material.DisableKeyword("RATIOS_OFF");
}
else
{
m_Material.EnableKeyword("RATIOS_OFF");
}
}
if (m_Material.HasProperty(ShaderUtilities.ShaderTag_CullMode))
{
EditorGUILayout.Space();
DoPopup("_CullMode", "Cull Mode", s_CullingTypeLabels);
}
EditorGUILayout.Space();
EditorGUI.BeginDisabledGroup(true);
DoFloat("_ScaleRatioA", "Scale Ratio A");
DoFloat("_ScaleRatioB", "Scale Ratio B");
DoFloat("_ScaleRatioC", "Scale Ratio C");
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoDebugPanelSRP()
{
EditorGUI.indentLevel += 1;
DoTexture2D("_MainTex", "Font Atlas");
DoFloat("_GradientScale", "Gradient Scale");
//DoFloat("_TextureWidth", "Texture Width");
//DoFloat("_TextureHeight", "Texture Height");
EditorGUILayout.Space();
/*
DoFloat("_ScaleX", "Scale X");
DoFloat("_ScaleY", "Scale Y");
if (m_Material.HasProperty(ShaderUtilities.ID_Sharpness))
DoSlider("_Sharpness", "Sharpness");
DoSlider("_PerspectiveFilter", "Perspective Filter");
EditorGUILayout.Space();
DoFloat("_VertexOffsetX", "Offset X");
DoFloat("_VertexOffsetY", "Offset Y");
if (m_Material.HasProperty(ShaderUtilities.ID_MaskCoord))
{
EditorGUILayout.Space();
s_MaskFeature.ReadState(m_Material);
s_MaskFeature.DoPopup(m_Editor, m_Material);
if (s_MaskFeature.Active)
{
DoMaskSubgroup();
}
EditorGUILayout.Space();
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
else if (m_Material.HasProperty("_MaskTex"))
{
DoMaskTexSubgroup();
}
else if (m_Material.HasProperty(ShaderUtilities.ID_MaskSoftnessX))
{
EditorGUILayout.Space();
DoFloat("_MaskSoftnessX", "Softness X");
DoFloat("_MaskSoftnessY", "Softness Y");
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
if (m_Material.HasProperty(ShaderUtilities.ID_StencilID))
{
EditorGUILayout.Space();
DoFloat("_Stencil", "Stencil ID");
DoFloat("_StencilComp", "Stencil Comp");
}
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
bool useRatios = EditorGUILayout.Toggle("Use Ratios", !m_Material.IsKeywordEnabled("RATIOS_OFF"));
if (EditorGUI.EndChangeCheck())
{
m_Editor.RegisterPropertyChangeUndo("Use Ratios");
if (useRatios)
{
m_Material.DisableKeyword("RATIOS_OFF");
}
else
{
m_Material.EnableKeyword("RATIOS_OFF");
}
}
*/
if (m_Material.HasProperty(ShaderUtilities.ShaderTag_CullMode))
{
EditorGUILayout.Space();
DoPopup("_CullMode", "Cull Mode", s_CullingTypeLabels);
}
EditorGUILayout.Space();
/*
EditorGUI.BeginDisabledGroup(true);
DoFloat("_ScaleRatioA", "Scale Ratio A");
DoFloat("_ScaleRatioB", "Scale Ratio B");
DoFloat("_ScaleRatioC", "Scale Ratio C");
EditorGUI.EndDisabledGroup();
*/
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
void DoMaskSubgroup()
{
DoVector("_MaskCoord", "Mask Bounds", s_XywhVectorLabels);
if (Selection.activeGameObject != null)
{
Renderer renderer = Selection.activeGameObject.GetComponent<Renderer>();
if (renderer != null)
{
Rect rect = EditorGUILayout.GetControlRect();
rect.x += EditorGUIUtility.labelWidth;
rect.width -= EditorGUIUtility.labelWidth;
if (GUI.Button(rect, "Match Renderer Bounds"))
{
FindProperty("_MaskCoord", m_Properties).vectorValue = new Vector4(
0,
0,
Mathf.Round(renderer.bounds.extents.x * 1000) / 1000,
Mathf.Round(renderer.bounds.extents.y * 1000) / 1000
);
}
}
}
if (s_MaskFeature.State == 1)
{
DoFloat("_MaskSoftnessX", "Softness X");
DoFloat("_MaskSoftnessY", "Softness Y");
}
}
void DoMaskTexSubgroup()
{
EditorGUILayout.Space();
DoTexture2D("_MaskTex", "Mask Texture");
DoToggle("_MaskInverse", "Inverse Mask");
DoColor("_MaskEdgeColor", "Edge Color");
DoSlider("_MaskEdgeSoftness", "Edge Softness");
DoSlider("_MaskWipeControl", "Wipe Position");
DoFloat("_MaskSoftnessX", "Softness X");
DoFloat("_MaskSoftnessY", "Softness Y");
DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
}
// protected override void SetupMaterialKeywordsAndPassInternal(Material material)
// {
// BaseLitGUI.SetupBaseLitKeywords(material);
// BaseLitGUI.SetupBaseLitMaterialPass(material);
// }
}
}
#endif

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bad96c2cfa78a124cb8ec890d2386dfe
timeCreated: 1469844718
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: