feat: Initial commit
This commit is contained in:
8
Assets/TextMesh Pro/Scripts/Editor.meta
Normal file
8
Assets/TextMesh Pro/Scripts/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 651f9a260a3765242b8026f1d4db06e4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/TextMesh Pro/Scripts/Editor/GlobalSuppressions.cs
Normal file
30
Assets/TextMesh Pro/Scripts/Editor/GlobalSuppressions.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Performance", "UNT0026")]
|
||||
[assembly: SuppressMessage("Performance", "UNT0035")]
|
||||
[assembly: SuppressMessage("Style", "IDE0017")]
|
||||
[assembly: SuppressMessage("Style", "IDE0018")]
|
||||
[assembly: SuppressMessage("Style", "IDE0031")]
|
||||
[assembly: SuppressMessage("Style", "IDE0034")]
|
||||
[assembly: SuppressMessage("Style", "IDE0044")]
|
||||
[assembly: SuppressMessage("Style", "IDE0051")]
|
||||
[assembly: SuppressMessage("Style", "IDE0052")]
|
||||
[assembly: SuppressMessage("Style", "IDE0054")]
|
||||
[assembly: SuppressMessage("Style", "IDE0057")]
|
||||
[assembly: SuppressMessage("Style", "IDE0059")]
|
||||
[assembly: SuppressMessage("Style", "IDE0060")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063")]
|
||||
[assembly: SuppressMessage("Style", "IDE0066")]
|
||||
[assembly: SuppressMessage("Style", "IDE0074")]
|
||||
[assembly: SuppressMessage("Style", "IDE0075")]
|
||||
[assembly: SuppressMessage("Style", "IDE0090")]
|
||||
[assembly: SuppressMessage("Style", "IDE0180")]
|
||||
[assembly: SuppressMessage("Style", "IDE0251")]
|
||||
[assembly: SuppressMessage("Style", "IDE1005")]
|
||||
[assembly: SuppressMessage("Style", "IDE1006")]
|
||||
[assembly: SuppressMessage("Correctness", "UNT0008", Scope = "member", Target = "~M:TMPro.EditorUtilities.TMP_EditorPanel.OnEnable")]
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e8aa96a139a7414cb4d2031a22588db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/TextMesh Pro/Scripts/Editor/HDRP.meta
Normal file
8
Assets/TextMesh Pro/Scripts/Editor/HDRP.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eecc124dc0b994047aac97ccf8c8ed0a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3795795b029fde4395e6953ce72b5a6
|
||||
timeCreated: 1469844810
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 645409e9544820042937871953f20509
|
||||
timeCreated: 1469844810
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85016528879d5d644981050d1d0a4368
|
||||
timeCreated: 1469844718
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bad96c2cfa78a124cb8ec890d2386dfe
|
||||
timeCreated: 1469844718
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/TextMesh Pro/Scripts/Editor/PropertyDrawers.meta
Normal file
8
Assets/TextMesh Pro/Scripts/Editor/PropertyDrawers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea7c31b5b377c314db28ad3fabbbd38d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(TMP_Dropdown.OptionDataList), true)]
|
||||
class DropdownOptionListDrawer : PropertyDrawer
|
||||
{
|
||||
private ReorderableList m_ReorderableList;
|
||||
|
||||
private void Init(SerializedProperty property)
|
||||
{
|
||||
if (m_ReorderableList != null)
|
||||
return;
|
||||
|
||||
SerializedProperty array = property.FindPropertyRelative("m_Options");
|
||||
|
||||
m_ReorderableList = new ReorderableList(property.serializedObject, array);
|
||||
m_ReorderableList.drawElementCallback = DrawOptionData;
|
||||
m_ReorderableList.drawHeaderCallback = DrawHeader;
|
||||
m_ReorderableList.elementHeight += 40;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
Init(property);
|
||||
|
||||
m_ReorderableList.DoList(position);
|
||||
}
|
||||
|
||||
private void DrawHeader(Rect rect)
|
||||
{
|
||||
GUI.Label(rect, "Options");
|
||||
}
|
||||
|
||||
private void DrawOptionData(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
SerializedProperty itemData = m_ReorderableList.serializedProperty.GetArrayElementAtIndex(index);
|
||||
SerializedProperty itemText = itemData.FindPropertyRelative("m_Text");
|
||||
SerializedProperty itemImage = itemData.FindPropertyRelative("m_Image");
|
||||
SerializedProperty itemColor = itemData.FindPropertyRelative("m_Color");
|
||||
|
||||
RectOffset offset = new RectOffset(0, 0, -1, -3);
|
||||
rect = offset.Add(rect);
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
EditorGUI.PropertyField(rect, itemText, GUIContent.none);
|
||||
rect.y += EditorGUIUtility.singleLineHeight + 2;
|
||||
EditorGUI.PropertyField(rect, itemImage, GUIContent.none);
|
||||
rect.y += EditorGUIUtility.singleLineHeight + 2;
|
||||
EditorGUI.PropertyField(rect, itemColor, GUIContent.none);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
Init(property);
|
||||
|
||||
return m_ReorderableList.GetHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 705d3db7bce31a7439cc4c95cde5b04f
|
||||
timeCreated: 1464818008
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,273 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
[CustomPropertyDrawer(typeof(TextAlignmentOptions))]
|
||||
public class TMP_TextAlignmentDrawer : PropertyDrawer
|
||||
{
|
||||
const int k_AlignmentButtonWidth = 24;
|
||||
const int k_AlignmentButtonHeight = 20;
|
||||
const int k_WideViewWidth = 504;
|
||||
const int k_ControlsSpacing = 6;
|
||||
const int k_GroupWidth = k_AlignmentButtonWidth * 6;
|
||||
static readonly int k_TextAlignmentHash = "DoTextAligmentControl".GetHashCode();
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUIUtility.currentViewWidth > k_WideViewWidth ? k_AlignmentButtonHeight : k_AlignmentButtonHeight * 2 + 3;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var id = GUIUtility.GetControlID(k_TextAlignmentHash, FocusType.Keyboard, position);
|
||||
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
{
|
||||
var controlArea = EditorGUI.PrefixLabel(position, id, label);
|
||||
|
||||
var horizontalAligment = new Rect(controlArea.x, controlArea.y, k_GroupWidth, k_AlignmentButtonHeight);
|
||||
var verticalAligment = new Rect(!(EditorGUIUtility.currentViewWidth > k_WideViewWidth) ? controlArea.x : horizontalAligment.xMax + k_ControlsSpacing, !(EditorGUIUtility.currentViewWidth > k_WideViewWidth) ? controlArea.y + k_AlignmentButtonHeight + 3 : controlArea.y, k_GroupWidth, k_AlignmentButtonHeight);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
var selectedHorizontal = DoHorizontalAligmentControl(horizontalAligment, property);
|
||||
var selectedVertical = DoVerticalAligmentControl(verticalAligment, property);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
var value = (0x1 << selectedHorizontal) | (0x100 << selectedVertical);
|
||||
property.intValue = value;
|
||||
}
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
static int DoHorizontalAligmentControl(Rect position, SerializedProperty alignment)
|
||||
{
|
||||
var selected = TMP_EditorUtility.GetHorizontalAlignmentGridValue(alignment.intValue);
|
||||
|
||||
var values = new bool[6];
|
||||
|
||||
values[selected] = true;
|
||||
|
||||
if (alignment.hasMultipleDifferentValues)
|
||||
{
|
||||
foreach (var obj in alignment.serializedObject.targetObjects)
|
||||
{
|
||||
var text = obj as TMP_Text;
|
||||
if (text != null)
|
||||
{
|
||||
values[TMP_EditorUtility.GetHorizontalAlignmentGridValue((int)text.alignment)] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
position.width = k_AlignmentButtonWidth;
|
||||
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
var oldValue = values[i];
|
||||
var newValue = TMP_EditorUtility.EditorToggle(position, oldValue, TMP_UIStyleManager.alignContentA[i], i == 0 ? TMP_UIStyleManager.alignmentButtonLeft : (i == 5 ? TMP_UIStyleManager.alignmentButtonRight : TMP_UIStyleManager.alignmentButtonMid));
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
selected = i;
|
||||
}
|
||||
position.x += position.width;
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
static int DoVerticalAligmentControl(Rect position, SerializedProperty alignment)
|
||||
{
|
||||
var selected = TMP_EditorUtility.GetVerticalAlignmentGridValue(alignment.intValue);
|
||||
|
||||
var values = new bool[6];
|
||||
|
||||
values[selected] = true;
|
||||
|
||||
if (alignment.hasMultipleDifferentValues)
|
||||
{
|
||||
foreach (var obj in alignment.serializedObject.targetObjects)
|
||||
{
|
||||
var text = obj as TMP_Text;
|
||||
if (text != null)
|
||||
{
|
||||
values[TMP_EditorUtility.GetVerticalAlignmentGridValue((int)text.alignment)] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
position.width = k_AlignmentButtonWidth;
|
||||
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
var oldValue = values[i];
|
||||
var newValue = TMP_EditorUtility.EditorToggle(position, oldValue, TMP_UIStyleManager.alignContentB[i], i == 0 ? TMP_UIStyleManager.alignmentButtonLeft : (i == 5 ? TMP_UIStyleManager.alignmentButtonRight : TMP_UIStyleManager.alignmentButtonMid));
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
selected = i;
|
||||
}
|
||||
position.x += position.width;
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(HorizontalAlignmentOptions))]
|
||||
public class TMP_HorizontalAlignmentDrawer : PropertyDrawer
|
||||
{
|
||||
const int k_AlignmentButtonWidth = 24;
|
||||
const int k_AlignmentButtonHeight = 20;
|
||||
const int k_WideViewWidth = 504;
|
||||
const int k_ControlsSpacing = 6;
|
||||
const int k_GroupWidth = k_AlignmentButtonWidth * 6;
|
||||
static readonly int k_TextAlignmentHash = "DoTextAligmentControl".GetHashCode();
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUIUtility.currentViewWidth > k_WideViewWidth ? k_AlignmentButtonHeight : k_AlignmentButtonHeight * 2 + 3;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var id = GUIUtility.GetControlID(k_TextAlignmentHash, FocusType.Keyboard, position);
|
||||
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
{
|
||||
var controlArea = EditorGUI.PrefixLabel(position, id, label);
|
||||
|
||||
var horizontalAligment = new Rect(controlArea.x, controlArea.y, k_GroupWidth, k_AlignmentButtonHeight);
|
||||
//var verticalAligment = new Rect(!(EditorGUIUtility.currentViewWidth > k_WideViewWidth) ? controlArea.x : horizontalAligment.xMax + k_ControlsSpacing, !(EditorGUIUtility.currentViewWidth > k_WideViewWidth) ? controlArea.y + k_AlignmentButtonHeight + 3 : controlArea.y, k_GroupWidth, k_AlignmentButtonHeight);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
var selectedHorizontal = DoHorizontalAligmentControl(horizontalAligment, property);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
var value = 0x1 << selectedHorizontal;
|
||||
property.intValue = value;
|
||||
}
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
static int DoHorizontalAligmentControl(Rect position, SerializedProperty alignment)
|
||||
{
|
||||
var selected = TMP_EditorUtility.GetHorizontalAlignmentGridValue(alignment.intValue);
|
||||
|
||||
var values = new bool[6];
|
||||
|
||||
values[selected] = true;
|
||||
|
||||
if (alignment.hasMultipleDifferentValues)
|
||||
{
|
||||
foreach (var obj in alignment.serializedObject.targetObjects)
|
||||
{
|
||||
var text = obj as TMP_Text;
|
||||
if (text != null)
|
||||
{
|
||||
values[TMP_EditorUtility.GetHorizontalAlignmentGridValue((int)text.horizontalAlignment)] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
position.width = k_AlignmentButtonWidth;
|
||||
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
var oldValue = values[i];
|
||||
var newValue = TMP_EditorUtility.EditorToggle(position, oldValue, TMP_UIStyleManager.alignContentA[i], i == 0 ? TMP_UIStyleManager.alignmentButtonLeft : (i == 5 ? TMP_UIStyleManager.alignmentButtonRight : TMP_UIStyleManager.alignmentButtonMid));
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
selected = i;
|
||||
}
|
||||
position.x += position.width;
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[CustomPropertyDrawer(typeof(VerticalAlignmentOptions))]
|
||||
public class TMP_VerticalAlignmentDrawer : PropertyDrawer
|
||||
{
|
||||
const int k_AlignmentButtonWidth = 24;
|
||||
const int k_AlignmentButtonHeight = 20;
|
||||
const int k_WideViewWidth = 504;
|
||||
const int k_ControlsSpacing = 6;
|
||||
const int k_GroupWidth = k_AlignmentButtonWidth * 6;
|
||||
static readonly int k_TextAlignmentHash = "DoTextAligmentControl".GetHashCode();
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUIUtility.currentViewWidth > k_WideViewWidth ? k_AlignmentButtonHeight : k_AlignmentButtonHeight * 2 + 3;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var id = GUIUtility.GetControlID(k_TextAlignmentHash, FocusType.Keyboard, position);
|
||||
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
{
|
||||
var controlArea = EditorGUI.PrefixLabel(position, id, label);
|
||||
|
||||
var horizontalAligment = new Rect(controlArea.x, controlArea.y, k_GroupWidth, k_AlignmentButtonHeight);
|
||||
var verticalAligment = new Rect(!(EditorGUIUtility.currentViewWidth > k_WideViewWidth) ? controlArea.x : horizontalAligment.xMax + k_ControlsSpacing, !(EditorGUIUtility.currentViewWidth > k_WideViewWidth) ? controlArea.y + k_AlignmentButtonHeight + 3 : controlArea.y, k_GroupWidth, k_AlignmentButtonHeight);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
//var selectedHorizontal = DoHorizontalAligmentControl(horizontalAligment, property);
|
||||
var selectedVertical = DoVerticalAligmentControl(verticalAligment, property);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
var value = 0x100 << selectedVertical;
|
||||
property.intValue = value;
|
||||
}
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
static int DoVerticalAligmentControl(Rect position, SerializedProperty alignment)
|
||||
{
|
||||
var selected = TMP_EditorUtility.GetVerticalAlignmentGridValue(alignment.intValue);
|
||||
|
||||
var values = new bool[6];
|
||||
|
||||
values[selected] = true;
|
||||
|
||||
if (alignment.hasMultipleDifferentValues)
|
||||
{
|
||||
foreach (var obj in alignment.serializedObject.targetObjects)
|
||||
{
|
||||
var text = obj as TMP_Text;
|
||||
if (text != null)
|
||||
{
|
||||
values[TMP_EditorUtility.GetVerticalAlignmentGridValue((int)text.verticalAlignment)] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
position.width = k_AlignmentButtonWidth;
|
||||
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
var oldValue = values[i];
|
||||
var newValue = TMP_EditorUtility.EditorToggle(position, oldValue, TMP_UIStyleManager.alignContentB[i], i == 0 ? TMP_UIStyleManager.alignmentButtonLeft : (i == 5 ? TMP_UIStyleManager.alignmentButtonRight : TMP_UIStyleManager.alignmentButtonMid));
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
selected = i;
|
||||
}
|
||||
position.x += position.width;
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea87c857d2c45f64ebe967330244a515
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1390
Assets/TextMesh Pro/Scripts/Editor/TMP_BaseEditorPanel.cs
Normal file
1390
Assets/TextMesh Pro/Scripts/Editor/TMP_BaseEditorPanel.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53dc282e104b7b3499778bb50cb28216
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
699
Assets/TextMesh Pro/Scripts/Editor/TMP_BaseShaderGUI.cs
Normal file
699
Assets/TextMesh Pro/Scripts/Editor/TMP_BaseShaderGUI.cs
Normal file
@@ -0,0 +1,699 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.Text;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
/// <summary>Base class for TextMesh Pro shader GUIs.</summary>
|
||||
public abstract class TMP_BaseShaderGUI : ShaderGUI
|
||||
{
|
||||
/// <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_BaseShaderGUI()
|
||||
{
|
||||
// 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;
|
||||
private int m_ShaderID;
|
||||
|
||||
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.
|
||||
TextEventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material);
|
||||
}
|
||||
|
||||
s_LastSeenUndoRedoCount = s_UndoRedoCount;
|
||||
}
|
||||
|
||||
public override void OnGUI(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())
|
||||
{
|
||||
TextEventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material);
|
||||
}
|
||||
|
||||
DoDragAndDropEnd();
|
||||
}
|
||||
|
||||
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
|
||||
{
|
||||
base.AssignNewShaderToMaterial(material, oldShader, newShader);
|
||||
|
||||
TextEventManager.ON_MATERIAL_PROPERTY_CHANGED(true, material);
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
public 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 <= 330f && (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;
|
||||
}
|
||||
|
||||
protected 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;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNewShader()
|
||||
{
|
||||
if (m_Material == null)
|
||||
return false;
|
||||
|
||||
int currentShaderID = m_Material.shader.GetInstanceID();
|
||||
|
||||
if (m_ShaderID == currentShaderID)
|
||||
return false;
|
||||
|
||||
m_ShaderID = currentShaderID;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if (evt.type == EventType.DragExited)
|
||||
{
|
||||
if (IsNewShader())
|
||||
TextEventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material);
|
||||
}
|
||||
}
|
||||
|
||||
void PerformDrop(Material droppedMaterial)
|
||||
{
|
||||
Texture droppedTex = droppedMaterial.GetTexture(ShaderUtilities.ID_MainTex);
|
||||
if (!droppedTex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Texture currentTex = m_Material.GetTexture(ShaderUtilities.ID_MainTex);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
TextEventManager.ON_DRAG_AND_DROP_MATERIAL_CHANGED(o, m_Material, droppedMaterial);
|
||||
EditorUtility.SetDirty(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/TextMesh Pro/Scripts/Editor/TMP_BaseShaderGUI.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Editor/TMP_BaseShaderGUI.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b568c26a0e77b24ea4badb24f550576
|
||||
timeCreated: 1469844810
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Assets/TextMesh Pro/Scripts/Editor/TMP_BitmapShaderGUI.cs
Normal file
93
Assets/TextMesh Pro/Scripts/Editor/TMP_BitmapShaderGUI.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
public class TMP_BitmapShaderGUI : TMP_BaseShaderGUI
|
||||
{
|
||||
static bool s_Face = true;
|
||||
|
||||
protected override void DoGUI()
|
||||
{
|
||||
s_Face = BeginPanel("Face", s_Face);
|
||||
if (s_Face)
|
||||
{
|
||||
DoFacePanel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
|
||||
s_DebugExtended = BeginPanel("Debug Settings", s_DebugExtended);
|
||||
if (s_DebugExtended)
|
||||
{
|
||||
DoDebugPanel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
}
|
||||
|
||||
void DoFacePanel()
|
||||
{
|
||||
EditorGUI.indentLevel += 1;
|
||||
if (m_Material.HasProperty(ShaderUtilities.ID_FaceTex))
|
||||
{
|
||||
DoColor("_FaceColor", "Color");
|
||||
DoTexture2D("_FaceTex", "Texture", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoColor("_Color", "Color");
|
||||
DoSlider("_DiffusePower", "Diffuse Power");
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel -= 1;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
void DoDebugPanel()
|
||||
{
|
||||
EditorGUI.indentLevel += 1;
|
||||
DoTexture2D("_MainTex", "Font Atlas");
|
||||
if (m_Material.HasProperty(ShaderUtilities.ID_VertexOffsetX))
|
||||
{
|
||||
if (m_Material.HasProperty(ShaderUtilities.ID_Padding))
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
DoFloat("_Padding", "Padding");
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
DoFloat("_VertexOffsetX", "Offset X");
|
||||
DoFloat("_VertexOffsetY", "Offset Y");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
if (m_Material.HasProperty(ShaderUtilities.ShaderTag_CullMode))
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
DoPopup("_CullMode", "Cull Mode", s_CullingTypeLabels);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUI.indentLevel -= 1;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df3965f86289f794a967b4a8c6cfc6cb
|
||||
timeCreated: 1469998850
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.Text;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
public static class TMP_ColorGradientAssetMenu
|
||||
{
|
||||
[MenuItem("Assets/Create/TextMeshPro/Text Color Gradient", false, 250)]
|
||||
internal static void CreateColorGradient(MenuCommand context)
|
||||
{
|
||||
string filePath;
|
||||
|
||||
if (Selection.assetGUIDs.Length == 0)
|
||||
filePath = "Assets/New Text Color Gradient.asset";
|
||||
else
|
||||
filePath = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
|
||||
|
||||
if (Directory.Exists(filePath))
|
||||
{
|
||||
filePath += "/New Text Color Gradient.asset";
|
||||
}
|
||||
else
|
||||
{
|
||||
filePath = Path.GetDirectoryName(filePath) + "/New Text Color Gradient.asset";
|
||||
}
|
||||
|
||||
filePath = AssetDatabase.GenerateUniqueAssetPath(filePath);
|
||||
|
||||
// Create new Color Gradient Asset.
|
||||
TextColorGradient colorGradient = ScriptableObject.CreateInstance<TextColorGradient>();
|
||||
|
||||
// Create Asset
|
||||
AssetDatabase.CreateAsset(colorGradient, filePath);
|
||||
|
||||
//EditorUtility.SetDirty(colorGradient);
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(colorGradient));
|
||||
|
||||
EditorUtility.FocusProjectWindow();
|
||||
EditorGUIUtility.PingObject(colorGradient);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7364ac159f2f5cc4dae5a5b262583afa
|
||||
timeCreated: 1468187791
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Assets/TextMesh Pro/Scripts/Editor/TMP_DropdownEditor.cs
Normal file
60
Assets/TextMesh Pro/Scripts/Editor/TMP_DropdownEditor.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
[CustomEditor(typeof(TMP_Dropdown), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class DropdownEditor : SelectableEditor
|
||||
{
|
||||
SerializedProperty m_Template;
|
||||
SerializedProperty m_CaptionText;
|
||||
SerializedProperty m_CaptionImage;
|
||||
SerializedProperty m_Placeholder;
|
||||
SerializedProperty m_ItemText;
|
||||
SerializedProperty m_ItemImage;
|
||||
SerializedProperty m_OnSelectionChanged;
|
||||
SerializedProperty m_Value;
|
||||
SerializedProperty m_MultiSelect;
|
||||
SerializedProperty m_AlphaFadeSpeed;
|
||||
SerializedProperty m_Options;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Template = serializedObject.FindProperty("m_Template");
|
||||
m_CaptionText = serializedObject.FindProperty("m_CaptionText");
|
||||
m_CaptionImage = serializedObject.FindProperty("m_CaptionImage");
|
||||
m_Placeholder = serializedObject.FindProperty("m_Placeholder");
|
||||
m_ItemText = serializedObject.FindProperty("m_ItemText");
|
||||
m_ItemImage = serializedObject.FindProperty("m_ItemImage");
|
||||
m_OnSelectionChanged = serializedObject.FindProperty("m_OnValueChanged");
|
||||
m_Value = serializedObject.FindProperty("m_Value");
|
||||
m_MultiSelect = serializedObject.FindProperty("m_MultiSelect");
|
||||
m_AlphaFadeSpeed = serializedObject.FindProperty("m_AlphaFadeSpeed");
|
||||
m_Options = serializedObject.FindProperty("m_Options");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(m_Template);
|
||||
EditorGUILayout.PropertyField(m_CaptionText);
|
||||
EditorGUILayout.PropertyField(m_CaptionImage);
|
||||
EditorGUILayout.PropertyField(m_Placeholder);
|
||||
EditorGUILayout.PropertyField(m_ItemText);
|
||||
EditorGUILayout.PropertyField(m_ItemImage);
|
||||
EditorGUILayout.PropertyField(m_Value);
|
||||
EditorGUILayout.PropertyField(m_MultiSelect);
|
||||
EditorGUILayout.PropertyField(m_AlphaFadeSpeed);
|
||||
EditorGUILayout.PropertyField(m_Options);
|
||||
EditorGUILayout.PropertyField(m_OnSelectionChanged);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2a8381dd0e0f344d8b8a5e83bd20b2b
|
||||
timeCreated: 1446377461
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
96
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorCoroutine.cs
Normal file
96
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorCoroutine.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple implementation of coroutine working in the Unity Editor.
|
||||
/// </summary>
|
||||
public class TMP_EditorCoroutine
|
||||
{
|
||||
//private static Dictionary<int, EditorCoroutine> s_ActiveCoroutines;
|
||||
|
||||
readonly IEnumerator coroutine;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="routine"></param>
|
||||
TMP_EditorCoroutine(IEnumerator routine)
|
||||
{
|
||||
this.coroutine = routine;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Starts a new EditorCoroutine.
|
||||
/// </summary>
|
||||
/// <param name="newCoroutine">Coroutine</param>
|
||||
/// <returns>new EditorCoroutine</returns>
|
||||
public static TMP_EditorCoroutine StartCoroutine(IEnumerator routine)
|
||||
{
|
||||
TMP_EditorCoroutine coroutine = new TMP_EditorCoroutine(routine);
|
||||
coroutine.Start();
|
||||
|
||||
// Add coroutine to tracking list
|
||||
//if (s_ActiveCoroutines == null)
|
||||
// s_ActiveCoroutines = new Dictionary<int, EditorCoroutine>();
|
||||
|
||||
// Add new instance of editor coroutine to dictionary.
|
||||
//s_ActiveCoroutines.Add(coroutine.GetHashCode(), coroutine);
|
||||
|
||||
return coroutine;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Clear delegate list
|
||||
/// </summary>
|
||||
//public static void StopAllEditorCoroutines()
|
||||
//{
|
||||
// EditorApplication.update = null;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Register callback for editor updates
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
EditorApplication.update += EditorUpdate;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unregister callback for editor updates.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
if (EditorApplication.update != null)
|
||||
EditorApplication.update -= EditorUpdate;
|
||||
|
||||
//s_ActiveCoroutines.Remove(this.GetHashCode());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delegate function called on editor updates.
|
||||
/// </summary>
|
||||
void EditorUpdate()
|
||||
{
|
||||
// Stop editor coroutine if it does not continue.
|
||||
if (coroutine.MoveNext() == false)
|
||||
Stop();
|
||||
|
||||
// Process the different types of EditorCoroutines.
|
||||
if (coroutine.Current != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0dddddc28f728c42a1fed80ba8f95cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
205
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorPanel.cs
Normal file
205
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorPanel.cs
Normal file
@@ -0,0 +1,205 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.Text;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
[CustomEditor(typeof(TextMeshPro), true), CanEditMultipleObjects]
|
||||
public class TMP_EditorPanel : TMP_BaseEditorPanel
|
||||
{
|
||||
static readonly GUIContent k_SortingLayerLabel = new GUIContent("Sorting Layer", "Name of the Renderer's sorting layer.");
|
||||
static readonly GUIContent k_OrderInLayerLabel = new GUIContent("Order in Layer", "Renderer's order within a sorting layer.");
|
||||
static readonly GUIContent k_OrthographicLabel = new GUIContent("Orthographic Mode", "Should be enabled when using an orthographic camera. Instructs the shader to not perform any perspective correction.");
|
||||
static readonly GUIContent k_VolumetricLabel = new GUIContent("Volumetric Setup", "Use cubes rather than quads to render the text. Allows for volumetric rendering when combined with a compatible shader.");
|
||||
|
||||
private static string[] k_SortingLayerNames;
|
||||
bool IsPreset;
|
||||
|
||||
SerializedProperty m_IsVolumetricTextProp;
|
||||
SerializedProperty m_IsOrthographicProp;
|
||||
Object[] m_Renderers;
|
||||
|
||||
SerializedObject m_RendererSerializedObject;
|
||||
SerializedProperty m_RendererSortingLayerProp;
|
||||
SerializedProperty m_RendererSortingLayerIDProp;
|
||||
SerializedProperty m_RendererSortingOrderProp;
|
||||
|
||||
SerializedProperty m_TextSortingLayerProp;
|
||||
SerializedProperty m_TextSortingLayerIDProp;
|
||||
SerializedProperty m_TextSortingOrderProp;
|
||||
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
// Determine if the inspected object is a Preset
|
||||
IsPreset = (int)(target as Component).gameObject.hideFlags == 93;
|
||||
|
||||
m_IsOrthographicProp = serializedObject.FindProperty("m_isOrthographic");
|
||||
|
||||
m_IsVolumetricTextProp = serializedObject.FindProperty("m_isVolumetricText");
|
||||
|
||||
m_Renderers = new Object[targets.Length];
|
||||
for (int i = 0; i < m_Renderers.Length; i++)
|
||||
m_Renderers[i] = (targets[i] as TextMeshPro)?.GetComponent<Renderer>();
|
||||
|
||||
m_RendererSerializedObject = new SerializedObject(m_Renderers);
|
||||
m_RendererSortingLayerProp = m_RendererSerializedObject.FindProperty("m_SortingLayer");
|
||||
m_RendererSortingLayerIDProp = m_RendererSerializedObject.FindProperty("m_SortingLayerID");
|
||||
m_RendererSortingOrderProp = m_RendererSerializedObject.FindProperty("m_SortingOrder");
|
||||
|
||||
m_TextSortingLayerProp = serializedObject.FindProperty("_SortingLayer");
|
||||
m_TextSortingLayerIDProp = serializedObject.FindProperty("_SortingLayerID");
|
||||
m_TextSortingOrderProp = serializedObject.FindProperty("_SortingOrder");
|
||||
|
||||
// Populate Sorting Layer Names
|
||||
k_SortingLayerNames = SortingLayerHelper.sortingLayerNames;
|
||||
}
|
||||
|
||||
protected override void DrawExtraSettings()
|
||||
{
|
||||
Rect rect = EditorGUILayout.GetControlRect(false, 24);
|
||||
|
||||
if (GUI.Button(rect, new GUIContent("<b>Extra Settings</b>"), TMP_UIStyleManager.sectionHeader))
|
||||
Foldout.extraSettings = !Foldout.extraSettings;
|
||||
|
||||
GUI.Label(rect, (Foldout.extraSettings ? "" : k_UiStateLabel[1]), TMP_UIStyleManager.rightLabel);
|
||||
|
||||
if (Foldout.extraSettings)
|
||||
{
|
||||
//EditorGUI.indentLevel += 1;
|
||||
|
||||
DrawMargins();
|
||||
|
||||
DrawSortingLayer();
|
||||
|
||||
DrawGeometrySorting();
|
||||
|
||||
DrawIsTextObjectScaleStatic();
|
||||
|
||||
DrawOrthographicMode();
|
||||
|
||||
DrawRichText();
|
||||
|
||||
DrawParsing();
|
||||
|
||||
DrawSpriteAsset();
|
||||
|
||||
DrawStyleSheet();
|
||||
|
||||
//DrawVolumetricSetup();
|
||||
|
||||
DrawKerning();
|
||||
|
||||
DrawPadding();
|
||||
|
||||
//EditorGUI.indentLevel -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSortingLayer()
|
||||
{
|
||||
m_RendererSerializedObject.Update();
|
||||
|
||||
Rect rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
// Special handling for Presets where the sorting layer, id and order is serialized with the text object instead of on the MeshRenderer.
|
||||
SerializedProperty sortingLayerProp = IsPreset ? m_TextSortingLayerProp : m_RendererSortingLayerProp;
|
||||
SerializedProperty sortingLayerIDProp = IsPreset ? m_TextSortingLayerIDProp : m_RendererSortingLayerIDProp;
|
||||
|
||||
EditorGUI.BeginProperty(rect, k_SortingLayerLabel, sortingLayerIDProp);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
int currentLayerIndex = SortingLayerHelper.GetSortingLayerIndexFromSortingLayerID(sortingLayerIDProp.intValue);
|
||||
int newLayerIndex = EditorGUI.Popup(rect, k_SortingLayerLabel, currentLayerIndex, k_SortingLayerNames);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
sortingLayerIDProp.intValue = SortingLayer.NameToID(k_SortingLayerNames[newLayerIndex]);
|
||||
sortingLayerProp.intValue = SortingLayer.GetLayerValueFromName(k_SortingLayerNames[newLayerIndex]);
|
||||
m_HavePropertiesChanged = true;
|
||||
|
||||
// Sync Sorting Layer ID change on potential sub text object.
|
||||
TextMeshPro textComponent = m_TextComponent as TextMeshPro;
|
||||
textComponent.UpdateSubMeshSortingLayerID(sortingLayerIDProp.intValue);
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
|
||||
// Sorting Order
|
||||
SerializedProperty sortingOrderLayerProp = IsPreset ? m_TextSortingOrderProp : m_RendererSortingOrderProp;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(sortingOrderLayerProp, k_OrderInLayerLabel);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_HavePropertiesChanged = true;
|
||||
|
||||
TextMeshPro textComponent = m_TextComponent as TextMeshPro;
|
||||
textComponent.UpdateSubMeshSortingOrder(sortingOrderLayerProp.intValue);
|
||||
}
|
||||
|
||||
m_RendererSerializedObject.ApplyModifiedProperties();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
private void DrawOrthographicMode()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_IsOrthographicProp, k_OrthographicLabel);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
m_HavePropertiesChanged = true;
|
||||
}
|
||||
|
||||
protected void DrawVolumetricSetup()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_IsVolumetricTextProp, k_VolumetricLabel);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_HavePropertiesChanged = true;
|
||||
m_TextComponent.textInfo.ResetVertexLayout(m_IsVolumetricTextProp.boolValue);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
// Method to handle multi object selection
|
||||
protected override bool IsMixSelectionTypes()
|
||||
{
|
||||
GameObject[] objects = Selection.gameObjects;
|
||||
if (objects.Length > 1)
|
||||
{
|
||||
for (int i = 0; i < objects.Length; i++)
|
||||
{
|
||||
if (objects[i].GetComponent<TextMeshPro>() == null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnUndoRedo()
|
||||
{
|
||||
int undoEventId = Undo.GetCurrentGroup();
|
||||
int lastUndoEventId = s_EventId;
|
||||
|
||||
if (undoEventId != lastUndoEventId)
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
//Debug.Log("Undo & Redo Performed detected in Editor Panel. Event ID:" + Undo.GetCurrentGroup());
|
||||
TextEventManager.ON_TEXTMESHPRO_PROPERTY_CHANGED(true, targets[i] as TextMeshPro);
|
||||
s_EventId = undoEventId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
10
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorPanel.cs.meta
Normal file
10
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorPanel.cs.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87553b56a6d8da547b76fc3c75a5a6f0
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
128
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorPanelUI.cs
Normal file
128
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorPanelUI.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.Text;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
[CustomEditor(typeof(TextMeshProUGUI), true), CanEditMultipleObjects]
|
||||
public class TMP_EditorPanelUI : TMP_BaseEditorPanel
|
||||
{
|
||||
static readonly GUIContent k_RaycastTargetLabel = new GUIContent("Raycast Target", "Whether the text blocks raycasts from the Graphic Raycaster.");
|
||||
static readonly GUIContent k_MaskableLabel = new GUIContent("Maskable", "Determines if the text object will be affected by UI Mask.");
|
||||
|
||||
SerializedProperty m_RaycastTargetProp;
|
||||
private SerializedProperty m_MaskableProp;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_RaycastTargetProp = serializedObject.FindProperty("m_RaycastTarget");
|
||||
m_MaskableProp = serializedObject.FindProperty("m_Maskable");
|
||||
}
|
||||
|
||||
protected override void DrawExtraSettings()
|
||||
{
|
||||
Rect rect = EditorGUILayout.GetControlRect(false, 24);
|
||||
|
||||
if (GUI.Button(rect, new GUIContent("<b>Extra Settings</b>"), TMP_UIStyleManager.sectionHeader))
|
||||
Foldout.extraSettings = !Foldout.extraSettings;
|
||||
|
||||
GUI.Label(rect, (Foldout.extraSettings ? k_UiStateLabel[0] : k_UiStateLabel[1]), TMP_UIStyleManager.rightLabel);
|
||||
if (Foldout.extraSettings)
|
||||
{
|
||||
//EditorGUI.indentLevel += 1;
|
||||
|
||||
DrawMargins();
|
||||
|
||||
DrawGeometrySorting();
|
||||
|
||||
DrawIsTextObjectScaleStatic();
|
||||
|
||||
DrawRichText();
|
||||
|
||||
DrawRaycastTarget();
|
||||
|
||||
DrawMaskable();
|
||||
|
||||
DrawParsing();
|
||||
|
||||
DrawSpriteAsset();
|
||||
|
||||
DrawStyleSheet();
|
||||
|
||||
DrawKerning();
|
||||
|
||||
DrawPadding();
|
||||
|
||||
//EditorGUI.indentLevel -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawRaycastTarget()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_RaycastTargetProp, k_RaycastTargetLabel);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
// Change needs to propagate to the child sub objects.
|
||||
Graphic[] graphicComponents = m_TextComponent.GetComponentsInChildren<Graphic>();
|
||||
for (int i = 1; i < graphicComponents.Length; i++)
|
||||
graphicComponents[i].raycastTarget = m_RaycastTargetProp.boolValue;
|
||||
|
||||
m_HavePropertiesChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawMaskable()
|
||||
{
|
||||
if (m_MaskableProp == null)
|
||||
return;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_MaskableProp, k_MaskableLabel);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_TextComponent.maskable = m_MaskableProp.boolValue;
|
||||
|
||||
// Change needs to propagate to the child sub objects.
|
||||
MaskableGraphic[] maskableGraphics = m_TextComponent.GetComponentsInChildren<MaskableGraphic>();
|
||||
for (int i = 1; i < maskableGraphics.Length; i++)
|
||||
maskableGraphics[i].maskable = m_MaskableProp.boolValue;
|
||||
|
||||
m_HavePropertiesChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Method to handle multi object selection
|
||||
protected override bool IsMixSelectionTypes()
|
||||
{
|
||||
GameObject[] objects = Selection.gameObjects;
|
||||
if (objects.Length > 1)
|
||||
{
|
||||
for (int i = 0; i < objects.Length; i++)
|
||||
{
|
||||
if (objects[i].GetComponent<TextMeshProUGUI>() == null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected override void OnUndoRedo()
|
||||
{
|
||||
int undoEventId = Undo.GetCurrentGroup();
|
||||
int lastUndoEventId = s_EventId;
|
||||
|
||||
if (undoEventId != lastUndoEventId)
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
//Debug.Log("Undo & Redo Performed detected in Editor Panel. Event ID:" + Undo.GetCurrentGroup());
|
||||
TextEventManager.ON_TEXTMESHPRO_UGUI_PROPERTY_CHANGED(true, targets[i] as TextMeshProUGUI);
|
||||
s_EventId = undoEventId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorPanelUI.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorPanelUI.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 115c3ac795553ef46a889d1af5ff4f10
|
||||
timeCreated: 1443571501
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
448
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorUtility.cs
Normal file
448
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorUtility.cs
Normal file
@@ -0,0 +1,448 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.Text;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
public static class TMP_EditorUtility
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the relative path of the package.
|
||||
/// </summary>
|
||||
public static string packageRelativePath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_PackagePath))
|
||||
m_PackagePath = GetPackageRelativePath();
|
||||
|
||||
return m_PackagePath;
|
||||
}
|
||||
}
|
||||
[SerializeField]
|
||||
private static string m_PackagePath;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the fully qualified path of the package.
|
||||
/// </summary>
|
||||
public static string packageFullPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_PackageFullPath))
|
||||
m_PackageFullPath = GetPackageFullPath();
|
||||
|
||||
return m_PackageFullPath;
|
||||
}
|
||||
}
|
||||
[SerializeField]
|
||||
private static string m_PackageFullPath;
|
||||
|
||||
// Static Fields Related to locating the TextMesh Pro Asset
|
||||
private static string folderPath = "Not Found";
|
||||
|
||||
private static EditorWindow Gameview;
|
||||
private static bool isInitialized = false;
|
||||
|
||||
private static void GetGameview()
|
||||
{
|
||||
System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
|
||||
System.Type type = assembly.GetType("UnityEditor.GameView");
|
||||
Gameview = EditorWindow.GetWindow(type);
|
||||
}
|
||||
|
||||
|
||||
internal static void RepaintAll()
|
||||
{
|
||||
if (isInitialized == false)
|
||||
{
|
||||
GetGameview();
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
SceneView.RepaintAll();
|
||||
Gameview.Repaint();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create and return a new asset in a smart location based on the current selection and then select it.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// Name of the new asset. Do not include the .asset extension.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The new asset.
|
||||
/// </returns>
|
||||
internal static T CreateAsset<T>(string name) where T : ScriptableObject
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
|
||||
if (path.Length == 0)
|
||||
{
|
||||
// no asset selected, place in asset root
|
||||
path = "Assets/" + name + ".asset";
|
||||
}
|
||||
else if (Directory.Exists(path))
|
||||
{
|
||||
// place in currently selected directory
|
||||
path += "/" + name + ".asset";
|
||||
}
|
||||
else {
|
||||
// place in current selection's containing directory
|
||||
path = Path.GetDirectoryName(path) + "/" + name + ".asset";
|
||||
}
|
||||
T asset = ScriptableObject.CreateInstance<T>();
|
||||
AssetDatabase.CreateAsset(asset, AssetDatabase.GenerateUniqueAssetPath(path));
|
||||
EditorUtility.FocusProjectWindow();
|
||||
Selection.activeObject = asset;
|
||||
return asset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Function used to find all materials which reference a font atlas so we can update all their references.
|
||||
internal static Material[] FindMaterialReferences(FontAsset fontAsset)
|
||||
{
|
||||
List<Material> refs = new List<Material>();
|
||||
Material mat = fontAsset.material;
|
||||
refs.Add(mat);
|
||||
|
||||
// Get materials matching the search pattern.
|
||||
string searchPattern = "t:Material" + " " + fontAsset.name.Split(new char[] { ' ' })[0];
|
||||
string[] materialAssetGUIDs = AssetDatabase.FindAssets(searchPattern);
|
||||
|
||||
for (int i = 0; i < materialAssetGUIDs.Length; i++)
|
||||
{
|
||||
string materialPath = AssetDatabase.GUIDToAssetPath(materialAssetGUIDs[i]);
|
||||
Material targetMaterial = AssetDatabase.LoadAssetAtPath<Material>(materialPath);
|
||||
|
||||
if (targetMaterial.HasProperty(ShaderUtilities.ID_MainTex) && targetMaterial.GetTexture(ShaderUtilities.ID_MainTex) != null && mat.GetTexture(ShaderUtilities.ID_MainTex) != null && targetMaterial.GetTexture(ShaderUtilities.ID_MainTex).GetInstanceID() == mat.GetTexture(ShaderUtilities.ID_MainTex).GetInstanceID())
|
||||
{
|
||||
if (!refs.Contains(targetMaterial))
|
||||
refs.Add(targetMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Find a more efficient method to unload resources.
|
||||
//Resources.UnloadAsset(targetMaterial.GetTexture(ShaderUtilities.ID_MainTex));
|
||||
}
|
||||
}
|
||||
|
||||
return refs.ToArray();
|
||||
}
|
||||
|
||||
|
||||
// Function used to find the Font Asset which matches the given Material Preset and Font Atlas Texture.
|
||||
internal static FontAsset FindMatchingFontAsset(Material mat)
|
||||
{
|
||||
if (mat.GetTexture(ShaderUtilities.ID_MainTex) == null) return null;
|
||||
|
||||
// Find the dependent assets of this material.
|
||||
string[] dependentAssets = AssetDatabase.GetDependencies(AssetDatabase.GetAssetPath(mat), false);
|
||||
|
||||
for (int i = 0; i < dependentAssets.Length; i++)
|
||||
{
|
||||
FontAsset fontAsset = AssetDatabase.LoadAssetAtPath<FontAsset>(dependentAssets[i]);
|
||||
if (fontAsset != null)
|
||||
return fontAsset;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static string GetPackageRelativePath()
|
||||
{
|
||||
// Check for potential UPM package
|
||||
string packagePath = Path.GetFullPath("Packages/com.unity.textmeshpro");
|
||||
if (Directory.Exists(packagePath))
|
||||
{
|
||||
return "Packages/com.unity.textmeshpro";
|
||||
}
|
||||
|
||||
packagePath = Path.GetFullPath("Assets/..");
|
||||
if (Directory.Exists(packagePath))
|
||||
{
|
||||
// Search default location for development package
|
||||
if (Directory.Exists(packagePath + "/Assets/Packages/com.unity.TextMeshPro/Editor Resources"))
|
||||
{
|
||||
return "Assets/Packages/com.unity.TextMeshPro";
|
||||
}
|
||||
|
||||
// Search for default location of normal TextMesh Pro AssetStore package
|
||||
if (Directory.Exists(packagePath + "/Assets/TextMesh Pro/Editor Resources"))
|
||||
{
|
||||
return "Assets/TextMesh Pro";
|
||||
}
|
||||
|
||||
// Search for potential alternative locations in the user project
|
||||
string[] matchingPaths = Directory.GetDirectories(packagePath, "TextMesh Pro", SearchOption.AllDirectories);
|
||||
packagePath = ValidateLocation(matchingPaths, packagePath);
|
||||
if (packagePath != null) return packagePath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetPackageFullPath()
|
||||
{
|
||||
// Check for potential UPM package
|
||||
string packagePath = Path.GetFullPath("Packages/com.unity.textmeshpro");
|
||||
if (Directory.Exists(packagePath))
|
||||
{
|
||||
return packagePath;
|
||||
}
|
||||
|
||||
packagePath = Path.GetFullPath("Assets/..");
|
||||
if (Directory.Exists(packagePath))
|
||||
{
|
||||
// Search default location for development package
|
||||
if (Directory.Exists(packagePath + "/Assets/Packages/com.unity.TextMeshPro/Editor Resources"))
|
||||
{
|
||||
return packagePath + "/Assets/Packages/com.unity.TextMeshPro";
|
||||
}
|
||||
|
||||
// Search for default location of normal TextMesh Pro AssetStore package
|
||||
if (Directory.Exists(packagePath + "/Assets/TextMesh Pro/Editor Resources"))
|
||||
{
|
||||
return packagePath + "/Assets/TextMesh Pro";
|
||||
}
|
||||
|
||||
// Search for potential alternative locations in the user project
|
||||
string[] matchingPaths = Directory.GetDirectories(packagePath, "TextMesh Pro", SearchOption.AllDirectories);
|
||||
string path = ValidateLocation(matchingPaths, packagePath);
|
||||
if (path != null) return packagePath + path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method to validate the location of the asset folder by making sure the GUISkins folder exists.
|
||||
/// </summary>
|
||||
/// <param name="paths"></param>
|
||||
/// <returns></returns>
|
||||
private static string ValidateLocation(string[] paths, string projectPath)
|
||||
{
|
||||
for (int i = 0; i < paths.Length; i++)
|
||||
{
|
||||
// Check if any of the matching directories contain a GUISkins directory.
|
||||
if (Directory.Exists(paths[i] + "/Editor Resources"))
|
||||
{
|
||||
folderPath = paths[i].Replace(projectPath, "");
|
||||
folderPath = folderPath.TrimStart('\\', '/');
|
||||
return folderPath;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function which returns a string containing a sequence of Decimal character ranges.
|
||||
/// </summary>
|
||||
/// <param name="characterSet"></param>
|
||||
/// <returns></returns>
|
||||
internal static string GetDecimalCharacterSequence(int[] characterSet)
|
||||
{
|
||||
if (characterSet == null || characterSet.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
string characterSequence = string.Empty;
|
||||
int count = characterSet.Length;
|
||||
int first = characterSet[0];
|
||||
int last = first;
|
||||
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
if (characterSet[i - 1] + 1 == characterSet[i])
|
||||
{
|
||||
last = characterSet[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (first == last)
|
||||
characterSequence += first + ",";
|
||||
else
|
||||
characterSequence += first + "-" + last + ",";
|
||||
|
||||
first = last = characterSet[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// handle the final group
|
||||
if (first == last)
|
||||
characterSequence += first;
|
||||
else
|
||||
characterSequence += first + "-" + last;
|
||||
|
||||
return characterSequence;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function which returns a string containing a sequence of Unicode (Hex) character ranges.
|
||||
/// </summary>
|
||||
/// <param name="characterSet"></param>
|
||||
/// <returns></returns>
|
||||
internal static string GetUnicodeCharacterSequence(int[] characterSet)
|
||||
{
|
||||
if (characterSet == null || characterSet.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
string characterSequence = string.Empty;
|
||||
int count = characterSet.Length;
|
||||
int first = characterSet[0];
|
||||
int last = first;
|
||||
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
if (characterSet[i - 1] + 1 == characterSet[i])
|
||||
{
|
||||
last = characterSet[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (first == last)
|
||||
characterSequence += first.ToString("X2") + ",";
|
||||
else
|
||||
characterSequence += first.ToString("X2") + "-" + last.ToString("X2") + ",";
|
||||
|
||||
first = last = characterSet[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// handle the final group
|
||||
if (first == last)
|
||||
characterSequence += first.ToString("X2");
|
||||
else
|
||||
characterSequence += first.ToString("X2") + "-" + last.ToString("X2");
|
||||
|
||||
return characterSequence;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="rect"></param>
|
||||
/// <param name="thickness"></param>
|
||||
/// <param name="color"></param>
|
||||
internal static void DrawBox(Rect rect, float thickness, Color color)
|
||||
{
|
||||
EditorGUI.DrawRect(new Rect(rect.x - thickness, rect.y + thickness, rect.width + thickness * 2, thickness), color);
|
||||
EditorGUI.DrawRect(new Rect(rect.x - thickness, rect.y + thickness, thickness, rect.height - thickness * 2), color);
|
||||
EditorGUI.DrawRect(new Rect(rect.x - thickness, rect.y + rect.height - thickness * 2, rect.width + thickness * 2, thickness), color);
|
||||
EditorGUI.DrawRect(new Rect(rect.x + rect.width, rect.y + thickness, thickness, rect.height - thickness * 2), color);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to return the horizontal alignment grid value.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
internal static int GetHorizontalAlignmentGridValue(int value)
|
||||
{
|
||||
if ((value & 0x1) == 0x1)
|
||||
return 0;
|
||||
else if ((value & 0x2) == 0x2)
|
||||
return 1;
|
||||
else if ((value & 0x4) == 0x4)
|
||||
return 2;
|
||||
else if ((value & 0x8) == 0x8)
|
||||
return 3;
|
||||
else if ((value & 0x10) == 0x10)
|
||||
return 4;
|
||||
else if ((value & 0x20) == 0x20)
|
||||
return 5;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to return the vertical alignment grid value.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
internal static int GetVerticalAlignmentGridValue(int value)
|
||||
{
|
||||
if ((value & 0x100) == 0x100)
|
||||
return 0;
|
||||
if ((value & 0x200) == 0x200)
|
||||
return 1;
|
||||
if ((value & 0x400) == 0x400)
|
||||
return 2;
|
||||
if ((value & 0x800) == 0x800)
|
||||
return 3;
|
||||
if ((value & 0x1000) == 0x1000)
|
||||
return 4;
|
||||
if ((value & 0x2000) == 0x2000)
|
||||
return 5;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal static void DrawColorProperty(Rect rect, SerializedProperty property)
|
||||
{
|
||||
int oldIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
if (EditorGUIUtility.wideMode)
|
||||
{
|
||||
EditorGUI.PropertyField(new Rect(rect.x, rect.y, 50f, rect.height), property, GUIContent.none);
|
||||
rect.x += 50f;
|
||||
rect.width = Mathf.Min(100f, rect.width - 55f);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.height /= 2f;
|
||||
rect.width = Mathf.Min(100f, rect.width - 5f);
|
||||
EditorGUI.PropertyField(rect, property, GUIContent.none);
|
||||
rect.y += rect.height;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string colorString = EditorGUI.TextField(rect, string.Format("#{0}", ColorUtility.ToHtmlStringRGBA(property.colorValue)));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Color color;
|
||||
if (ColorUtility.TryParseHtmlString(colorString, out color))
|
||||
{
|
||||
property.colorValue = color;
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel = oldIndent;
|
||||
}
|
||||
|
||||
internal static bool EditorToggle(Rect position, bool value, GUIContent content, GUIStyle style)
|
||||
{
|
||||
var id = GUIUtility.GetControlID(content, FocusType.Keyboard, position);
|
||||
var evt = Event.current;
|
||||
|
||||
// Toggle selected toggle on space or return key
|
||||
if (GUIUtility.keyboardControl == id && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter))
|
||||
{
|
||||
value = !value;
|
||||
evt.Use();
|
||||
GUI.changed = true;
|
||||
}
|
||||
|
||||
if (evt.type == EventType.MouseDown && position.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUIUtility.keyboardControl = id;
|
||||
EditorGUIUtility.editingTextField = false;
|
||||
HandleUtility.Repaint();
|
||||
}
|
||||
|
||||
return GUI.Toggle(position, id, value, content, style);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
10
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorUtility.cs.meta
Normal file
10
Assets/TextMesh Pro/Scripts/Editor/TMP_EditorUtility.cs.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c86041acbae1bb4a823635abfeb5c5d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
267
Assets/TextMesh Pro/Scripts/Editor/TMP_FontAsset_CreationMenu.cs
Normal file
267
Assets/TextMesh Pro/Scripts/Editor/TMP_FontAsset_CreationMenu.cs
Normal file
@@ -0,0 +1,267 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
using UnityEngine.TextCore.Text;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public static class TMP_FontAsset_CreationMenu
|
||||
{
|
||||
[MenuItem("Assets/Create/TextMeshPro/Font Asset Variant", false, 105)]
|
||||
public static void CreateFontAssetVariant()
|
||||
{
|
||||
Object target = Selection.activeObject;
|
||||
|
||||
// Make sure the selection is a font file
|
||||
if (target == null || target.GetType() != typeof(FontAsset))
|
||||
{
|
||||
Debug.LogWarning("A Font file must first be selected in order to create a Font Asset.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure TMP Essential Resources have been imported in the user project.
|
||||
if (TMP_Settings.instance == null)
|
||||
{
|
||||
Debug.Log("Unable to create font asset. Please import the TMP Essential Resources.");
|
||||
return;
|
||||
}
|
||||
|
||||
FontAsset sourceFontAsset = (FontAsset)target;
|
||||
|
||||
string sourceFontFilePath = AssetDatabase.GetAssetPath(target);
|
||||
|
||||
string folderPath = Path.GetDirectoryName(sourceFontFilePath);
|
||||
string assetName = Path.GetFileNameWithoutExtension(sourceFontFilePath);
|
||||
|
||||
string newAssetFilePathWithName = AssetDatabase.GenerateUniqueAssetPath(folderPath + "/" + assetName + " - Variant.asset");
|
||||
|
||||
// Set Texture and Material reference to the source font asset.
|
||||
FontAsset fontAsset = ScriptableObject.Instantiate<FontAsset>(sourceFontAsset);
|
||||
AssetDatabase.CreateAsset(fontAsset, newAssetFilePathWithName);
|
||||
|
||||
fontAsset.atlasPopulationMode = UnityEngine.TextCore.Text.AtlasPopulationMode.Static;
|
||||
|
||||
// Initialize array for the font atlas textures.
|
||||
fontAsset.atlasTextures = sourceFontAsset.atlasTextures;
|
||||
fontAsset.material = sourceFontAsset.material;
|
||||
|
||||
// Not sure if this is still necessary in newer versions of Unity.
|
||||
EditorUtility.SetDirty(fontAsset);
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
[MenuItem("Assets/Create/TextMeshPro/Font Asset Fallback", false, 105)]
|
||||
public static void CreateFallbackFontAsset()
|
||||
{
|
||||
Object target = Selection.activeObject;
|
||||
|
||||
// Make sure the selection is a font file
|
||||
if (target == null || target.GetType() != typeof(TMP_FontAsset))
|
||||
{
|
||||
Debug.LogWarning("A Font file must first be selected in order to create a Font Asset.");
|
||||
return;
|
||||
}
|
||||
|
||||
TMP_FontAsset sourceFontAsset = (TMP_FontAsset)target;
|
||||
|
||||
string sourceFontFilePath = AssetDatabase.GetAssetPath(target);
|
||||
|
||||
string folderPath = Path.GetDirectoryName(sourceFontFilePath);
|
||||
string assetName = Path.GetFileNameWithoutExtension(sourceFontFilePath);
|
||||
|
||||
string newAssetFilePathWithName = AssetDatabase.GenerateUniqueAssetPath(folderPath + "/" + assetName + " - Fallback.asset");
|
||||
|
||||
//// Create new TM Font Asset.
|
||||
TMP_FontAsset fontAsset = ScriptableObject.CreateInstance<TMP_FontAsset>();
|
||||
AssetDatabase.CreateAsset(fontAsset, newAssetFilePathWithName);
|
||||
|
||||
fontAsset.version = "1.1.0";
|
||||
|
||||
fontAsset.faceInfo = sourceFontAsset.faceInfo;
|
||||
|
||||
fontAsset.m_SourceFontFileGUID = sourceFontAsset.m_SourceFontFileGUID;
|
||||
fontAsset.m_SourceFontFile_EditorRef = sourceFontAsset.m_SourceFontFile_EditorRef;
|
||||
fontAsset.atlasPopulationMode = TMP_FontAsset.AtlasPopulationMode.Dynamic;
|
||||
|
||||
int atlasWidth = fontAsset.atlasWidth = sourceFontAsset.atlasWidth;
|
||||
int atlasHeight = fontAsset.atlasHeight = sourceFontAsset.atlasHeight;
|
||||
int atlasPadding = fontAsset.atlasPadding = sourceFontAsset.atlasPadding;
|
||||
fontAsset.atlasRenderMode = sourceFontAsset.atlasRenderMode;
|
||||
|
||||
// Initialize array for the font atlas textures.
|
||||
fontAsset.atlasTextures = new Texture2D[1];
|
||||
|
||||
// Create and add font atlas texture
|
||||
Texture2D texture = new Texture2D(atlasWidth, atlasHeight, TextureFormat.Alpha8, false);
|
||||
Color32[] colors = new Color32[atlasWidth * atlasHeight];
|
||||
texture.SetPixels32(colors);
|
||||
|
||||
texture.name = assetName + " Atlas";
|
||||
fontAsset.atlasTextures[0] = texture;
|
||||
AssetDatabase.AddObjectToAsset(texture, fontAsset);
|
||||
|
||||
// Add free rectangle of the size of the texture.
|
||||
int packingModifier = ((GlyphRasterModes)fontAsset.atlasRenderMode & GlyphRasterModes.RASTER_MODE_BITMAP) == GlyphRasterModes.RASTER_MODE_BITMAP ? 0 : 1;
|
||||
fontAsset.m_FreeGlyphRects = new List<GlyphRect>() { new GlyphRect(0, 0, atlasWidth - packingModifier, atlasHeight - packingModifier) };
|
||||
fontAsset.m_UsedGlyphRects = new List<GlyphRect>();
|
||||
|
||||
// Create new Material and Add it as Sub-Asset
|
||||
Material tmp_material = new Material(sourceFontAsset.material);
|
||||
|
||||
tmp_material.name = texture.name + " Material";
|
||||
tmp_material.SetTexture(ShaderUtilities.ID_MainTex, texture);
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_TextureWidth, atlasWidth);
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_TextureHeight, atlasHeight);
|
||||
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_GradientScale, atlasPadding + packingModifier);
|
||||
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_WeightNormal, fontAsset.normalStyle);
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_WeightBold, fontAsset.boldStyle);
|
||||
|
||||
fontAsset.material = tmp_material;
|
||||
|
||||
AssetDatabase.AddObjectToAsset(tmp_material, fontAsset);
|
||||
|
||||
// Add Font Asset Creation Settings
|
||||
// TODO
|
||||
|
||||
// Not sure if this is still necessary in newer versions of Unity.
|
||||
EditorUtility.SetDirty(fontAsset);
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
*/
|
||||
|
||||
//[MenuItem("Assets/Create/TextMeshPro/Font Asset #%F12", true)]
|
||||
//public static bool CreateFontAssetMenuValidation()
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
[MenuItem("Assets/Create/TextMeshPro/Font Asset #%F12", false, 100)]
|
||||
public static void CreateFontAsset()
|
||||
{
|
||||
Object[] targets = Selection.objects;
|
||||
|
||||
if (targets == null)
|
||||
{
|
||||
Debug.LogWarning("A Font file must first be selected in order to create a Font Asset.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure TMP Essential Resources have been imported in the user project.
|
||||
if (TMP_Settings.instance == null)
|
||||
{
|
||||
Debug.Log("Unable to create font asset. Please import the TMP Essential Resources.");
|
||||
|
||||
// Show Window to Import TMP Essential Resources
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
Object target = targets[i];
|
||||
|
||||
// Make sure the selection is a font file
|
||||
if (target == null || target.GetType() != typeof(Font))
|
||||
{
|
||||
Debug.LogWarning("Selected Object [" + target.name + "] is not a Font file. A Font file must be selected in order to create a Font Asset.", target);
|
||||
continue;
|
||||
}
|
||||
|
||||
CreateFontAssetFromSelectedObject(target);
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateFontAssetFromSelectedObject(Object target)
|
||||
{
|
||||
Font font = (Font)target;
|
||||
|
||||
string sourceFontFilePath = AssetDatabase.GetAssetPath(target);
|
||||
|
||||
string folderPath = Path.GetDirectoryName(sourceFontFilePath);
|
||||
string assetName = Path.GetFileNameWithoutExtension(sourceFontFilePath);
|
||||
|
||||
string newAssetFilePathWithName = AssetDatabase.GenerateUniqueAssetPath(folderPath + "/" + assetName + " SDF.asset");
|
||||
|
||||
// Initialize FontEngine
|
||||
FontEngine.InitializeFontEngine();
|
||||
|
||||
// Load Font Face
|
||||
if (FontEngine.LoadFontFace(font, 90) != FontEngineError.Success)
|
||||
{
|
||||
Debug.LogWarning("Unable to load font face for [" + font.name + "]. Make sure \"Include Font Data\" is enabled in the Font Import Settings.", font);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new Font Asset
|
||||
FontAsset fontAsset = ScriptableObject.CreateInstance<FontAsset>();
|
||||
AssetDatabase.CreateAsset(fontAsset, newAssetFilePathWithName);
|
||||
|
||||
fontAsset.version = "1.1.0";
|
||||
fontAsset.faceInfo = FontEngine.GetFaceInfo();
|
||||
|
||||
// Set font reference and GUID
|
||||
fontAsset.sourceFontFile = font;
|
||||
fontAsset.m_SourceFontFileGUID = AssetDatabase.AssetPathToGUID(sourceFontFilePath);
|
||||
fontAsset.m_SourceFontFile_EditorRef = font;
|
||||
|
||||
fontAsset.atlasPopulationMode = UnityEngine.TextCore.Text.AtlasPopulationMode.Dynamic;
|
||||
fontAsset.clearDynamicDataOnBuild = TMP_Settings.clearDynamicDataOnBuild;
|
||||
|
||||
// Default atlas resolution is 1024 x 1024.
|
||||
int atlasWidth = fontAsset.atlasWidth = 1024;
|
||||
int atlasHeight = fontAsset.atlasHeight = 1024;
|
||||
int atlasPadding = fontAsset.atlasPadding = 9;
|
||||
fontAsset.atlasRenderMode = GlyphRenderMode.SDFAA;
|
||||
|
||||
// Initialize array for the font atlas textures.
|
||||
fontAsset.atlasTextures = new Texture2D[1];
|
||||
|
||||
// Create atlas texture of size zero.
|
||||
Texture2D texture = new Texture2D(0, 0, TextureFormat.Alpha8, false);
|
||||
|
||||
texture.name = assetName + " Atlas";
|
||||
fontAsset.atlasTextures[0] = texture;
|
||||
AssetDatabase.AddObjectToAsset(texture, fontAsset);
|
||||
|
||||
// Add free rectangle of the size of the texture.
|
||||
int packingModifier = ((GlyphRasterModes)fontAsset.atlasRenderMode & GlyphRasterModes.RASTER_MODE_BITMAP) == GlyphRasterModes.RASTER_MODE_BITMAP ? 0 : 1;
|
||||
fontAsset.freeGlyphRects = new List<GlyphRect>() { new GlyphRect(0, 0, atlasWidth - packingModifier, atlasHeight - packingModifier) };
|
||||
fontAsset.usedGlyphRects = new List<GlyphRect>();
|
||||
|
||||
// Create new Material and Add it as Sub-Asset
|
||||
Shader default_Shader = Shader.Find("TextMeshPro/Distance Field");
|
||||
Material tmp_material = new Material(default_Shader);
|
||||
|
||||
tmp_material.name = texture.name + " Material";
|
||||
tmp_material.SetTexture(ShaderUtilities.ID_MainTex, texture);
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_TextureWidth, atlasWidth);
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_TextureHeight, atlasHeight);
|
||||
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_GradientScale, atlasPadding + packingModifier);
|
||||
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_WeightNormal, fontAsset.regularStyleWeight);
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_WeightBold, fontAsset.boldStyleWeight);
|
||||
|
||||
fontAsset.material = tmp_material;
|
||||
|
||||
AssetDatabase.AddObjectToAsset(tmp_material, fontAsset);
|
||||
|
||||
// Add Font Asset Creation Settings
|
||||
fontAsset.fontAssetCreationEditorSettings = new FontAssetCreationEditorSettings(fontAsset.m_SourceFontFileGUID, fontAsset.faceInfo.pointSize, 0, atlasPadding, 0, 1024, 1024, 7, string.Empty, (int)GlyphRenderMode.SDFAA);
|
||||
|
||||
// Not sure if this is still necessary in newer versions of Unity.
|
||||
//EditorUtility.SetDirty(fontAsset);
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f85302336d038c4da80ea264d185657
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
296
Assets/TextMesh Pro/Scripts/Editor/TMP_InputFieldEditor.cs
Normal file
296
Assets/TextMesh Pro/Scripts/Editor/TMP_InputFieldEditor.cs
Normal file
@@ -0,0 +1,296 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEditor.AnimatedValues;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(TMP_InputField), true)]
|
||||
public class TMP_InputFieldEditor : SelectableEditor
|
||||
{
|
||||
private struct m_foldout
|
||||
{ // Track Inspector foldout panel states, globally.
|
||||
public static bool textInput = true;
|
||||
public static bool fontSettings = true;
|
||||
public static bool extraSettings = true;
|
||||
//public static bool shadowSetting = false;
|
||||
//public static bool materialEditor = true;
|
||||
}
|
||||
|
||||
SerializedProperty m_TextViewport;
|
||||
SerializedProperty m_TextComponent;
|
||||
SerializedProperty m_Text;
|
||||
SerializedProperty m_ContentType;
|
||||
SerializedProperty m_LineType;
|
||||
SerializedProperty m_LineLimit;
|
||||
SerializedProperty m_InputType;
|
||||
SerializedProperty m_CharacterValidation;
|
||||
SerializedProperty m_InputValidator;
|
||||
SerializedProperty m_RegexValue;
|
||||
SerializedProperty m_KeyboardType;
|
||||
SerializedProperty m_CharacterLimit;
|
||||
SerializedProperty m_CaretBlinkRate;
|
||||
SerializedProperty m_CaretWidth;
|
||||
SerializedProperty m_CaretColor;
|
||||
SerializedProperty m_CustomCaretColor;
|
||||
SerializedProperty m_SelectionColor;
|
||||
SerializedProperty m_HideMobileKeyboard;
|
||||
SerializedProperty m_HideMobileInput;
|
||||
SerializedProperty m_Placeholder;
|
||||
SerializedProperty m_VerticalScrollbar;
|
||||
SerializedProperty m_ScrollbarScrollSensitivity;
|
||||
SerializedProperty m_OnValueChanged;
|
||||
SerializedProperty m_OnEndEdit;
|
||||
SerializedProperty m_OnSelect;
|
||||
SerializedProperty m_OnDeselect;
|
||||
SerializedProperty m_ReadOnly;
|
||||
SerializedProperty m_RichText;
|
||||
SerializedProperty m_RichTextEditingAllowed;
|
||||
SerializedProperty m_ResetOnDeActivation;
|
||||
SerializedProperty m_KeepTextSelectionVisible;
|
||||
SerializedProperty m_RestoreOriginalTextOnEscape;
|
||||
SerializedProperty m_ShouldActivateOnSelect;
|
||||
|
||||
SerializedProperty m_OnFocusSelectAll;
|
||||
SerializedProperty m_GlobalPointSize;
|
||||
SerializedProperty m_GlobalFontAsset;
|
||||
|
||||
AnimBool m_CustomColor;
|
||||
|
||||
//TMP_InputValidator m_ValidationScript;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
m_TextViewport = serializedObject.FindProperty("m_TextViewport");
|
||||
m_TextComponent = serializedObject.FindProperty("m_TextComponent");
|
||||
m_Text = serializedObject.FindProperty("m_Text");
|
||||
m_ContentType = serializedObject.FindProperty("m_ContentType");
|
||||
m_LineType = serializedObject.FindProperty("m_LineType");
|
||||
m_LineLimit = serializedObject.FindProperty("m_LineLimit");
|
||||
m_InputType = serializedObject.FindProperty("m_InputType");
|
||||
m_CharacterValidation = serializedObject.FindProperty("m_CharacterValidation");
|
||||
m_InputValidator = serializedObject.FindProperty("m_InputValidator");
|
||||
m_RegexValue = serializedObject.FindProperty("m_RegexValue");
|
||||
m_KeyboardType = serializedObject.FindProperty("m_KeyboardType");
|
||||
m_CharacterLimit = serializedObject.FindProperty("m_CharacterLimit");
|
||||
m_CaretBlinkRate = serializedObject.FindProperty("m_CaretBlinkRate");
|
||||
m_CaretWidth = serializedObject.FindProperty("m_CaretWidth");
|
||||
m_CaretColor = serializedObject.FindProperty("m_CaretColor");
|
||||
m_CustomCaretColor = serializedObject.FindProperty("m_CustomCaretColor");
|
||||
m_SelectionColor = serializedObject.FindProperty("m_SelectionColor");
|
||||
|
||||
m_HideMobileKeyboard = serializedObject.FindProperty("m_HideSoftKeyboard");
|
||||
m_HideMobileInput = serializedObject.FindProperty("m_HideMobileInput");
|
||||
|
||||
m_Placeholder = serializedObject.FindProperty("m_Placeholder");
|
||||
m_VerticalScrollbar = serializedObject.FindProperty("m_VerticalScrollbar");
|
||||
m_ScrollbarScrollSensitivity = serializedObject.FindProperty("m_ScrollSensitivity");
|
||||
|
||||
m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
|
||||
m_OnEndEdit = serializedObject.FindProperty("m_OnEndEdit");
|
||||
m_OnSelect = serializedObject.FindProperty("m_OnSelect");
|
||||
m_OnDeselect = serializedObject.FindProperty("m_OnDeselect");
|
||||
m_ReadOnly = serializedObject.FindProperty("m_ReadOnly");
|
||||
m_RichText = serializedObject.FindProperty("m_RichText");
|
||||
m_RichTextEditingAllowed = serializedObject.FindProperty("m_isRichTextEditingAllowed");
|
||||
m_ResetOnDeActivation = serializedObject.FindProperty("m_ResetOnDeActivation");
|
||||
m_KeepTextSelectionVisible = serializedObject.FindProperty("m_KeepTextSelectionVisible");
|
||||
m_RestoreOriginalTextOnEscape = serializedObject.FindProperty("m_RestoreOriginalTextOnEscape");
|
||||
|
||||
m_OnFocusSelectAll = serializedObject.FindProperty("m_OnFocusSelectAll");
|
||||
m_ShouldActivateOnSelect = serializedObject.FindProperty("m_ShouldActivateOnSelect");
|
||||
|
||||
m_GlobalPointSize = serializedObject.FindProperty("m_GlobalPointSize");
|
||||
m_GlobalFontAsset = serializedObject.FindProperty("m_GlobalFontAsset");
|
||||
|
||||
m_CustomColor = new AnimBool(m_CustomCaretColor.boolValue);
|
||||
m_CustomColor.valueChanged.AddListener(Repaint);
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
m_CustomColor.valueChanged.RemoveListener(Repaint);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
base.OnInspectorGUI();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(m_TextViewport);
|
||||
|
||||
EditorGUILayout.PropertyField(m_TextComponent);
|
||||
|
||||
TextMeshProUGUI text = null;
|
||||
if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null)
|
||||
{
|
||||
text = m_TextComponent.objectReferenceValue as TextMeshProUGUI;
|
||||
//if (text.supportRichText)
|
||||
//{
|
||||
// EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning);
|
||||
//}
|
||||
}
|
||||
|
||||
EditorGUI.BeginDisabledGroup(m_TextComponent == null || m_TextComponent.objectReferenceValue == null);
|
||||
|
||||
// TEXT INPUT BOX
|
||||
EditorGUILayout.PropertyField(m_Text);
|
||||
|
||||
// INPUT FIELD SETTINGS
|
||||
#region INPUT FIELD SETTINGS
|
||||
|
||||
m_foldout.fontSettings = EditorGUILayout.Foldout(m_foldout.fontSettings, "Input Field Settings", true, TMP_UIStyleManager.boldFoldout);
|
||||
|
||||
if (m_foldout.fontSettings)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_GlobalFontAsset, new GUIContent("Font Asset", "Set the Font Asset for both Placeholder and Input Field text object."));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
TMP_InputField inputField = target as TMP_InputField;
|
||||
inputField.SetGlobalFontAsset(m_GlobalFontAsset.objectReferenceValue as FontAsset);
|
||||
}
|
||||
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_GlobalPointSize, new GUIContent("Point Size", "Set the point size of both Placeholder and Input Field text object."));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
TMP_InputField inputField = target as TMP_InputField;
|
||||
inputField.SetGlobalPointSize(m_GlobalPointSize.floatValue);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_CharacterLimit);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(m_ContentType);
|
||||
if (!m_ContentType.hasMultipleDifferentValues)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Standard ||
|
||||
m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Autocorrected ||
|
||||
m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_LineType);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
if (m_LineType.enumValueIndex == (int)TMP_InputField.LineType.SingleLine)
|
||||
text.textWrappingMode = TextWrappingModes.PreserveWhitespaceNoWrap;
|
||||
else
|
||||
{
|
||||
text.textWrappingMode = TextWrappingModes.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_LineType.enumValueIndex != (int)TMP_InputField.LineType.SingleLine)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_LineLimit);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_InputType);
|
||||
EditorGUILayout.PropertyField(m_KeyboardType);
|
||||
EditorGUILayout.PropertyField(m_CharacterValidation);
|
||||
if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.Regex)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_RegexValue);
|
||||
}
|
||||
else if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.CustomValidator)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_InputValidator);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(m_Placeholder);
|
||||
EditorGUILayout.PropertyField(m_VerticalScrollbar);
|
||||
|
||||
if (m_VerticalScrollbar.objectReferenceValue != null)
|
||||
EditorGUILayout.PropertyField(m_ScrollbarScrollSensitivity);
|
||||
|
||||
EditorGUILayout.PropertyField(m_CaretBlinkRate);
|
||||
EditorGUILayout.PropertyField(m_CaretWidth);
|
||||
|
||||
EditorGUILayout.PropertyField(m_CustomCaretColor);
|
||||
|
||||
m_CustomColor.target = m_CustomCaretColor.boolValue;
|
||||
|
||||
if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded))
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_CaretColor);
|
||||
}
|
||||
EditorGUILayout.EndFadeGroup();
|
||||
|
||||
EditorGUILayout.PropertyField(m_SelectionColor);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
// CONTROL SETTINGS
|
||||
#region CONTROL SETTINGS
|
||||
m_foldout.extraSettings = EditorGUILayout.Foldout(m_foldout.extraSettings, "Control Settings", true, TMP_UIStyleManager.boldFoldout);
|
||||
|
||||
if (m_foldout.extraSettings)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
EditorGUILayout.PropertyField(m_OnFocusSelectAll, new GUIContent("OnFocus - Select All", "Should all the text be selected when the Input Field is selected?"));
|
||||
EditorGUILayout.PropertyField(m_ResetOnDeActivation, new GUIContent("Reset On Deactivation", "Should the Text and Caret position be reset when Input Field looses focus and is Deactivated?"));
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
GUI.enabled = !m_ResetOnDeActivation.boolValue;
|
||||
EditorGUILayout.PropertyField(m_KeepTextSelectionVisible, new GUIContent("Keep Text Selection Visible", "Should the text selection remain visible when the input field looses focus and is deactivated?"));
|
||||
GUI.enabled = true;
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUILayout.PropertyField(m_RestoreOriginalTextOnEscape, new GUIContent("Restore On ESC Key", "Should the original text be restored when pressing ESC?"));
|
||||
EditorGUILayout.PropertyField(m_ShouldActivateOnSelect, new GUIContent("Should Activate On Select", "Determines if the Input Field will be activated when selected."));
|
||||
EditorGUILayout.PropertyField(m_HideMobileKeyboard, new GUIContent("Hide Soft Keyboard", "Controls the visibility of the mobile virtual keyboard."));
|
||||
EditorGUILayout.PropertyField(m_HideMobileInput, new GUIContent("Hide Mobile Input", "Controls the visibility of the editable text field above the mobile virtual keyboard."));
|
||||
EditorGUILayout.PropertyField(m_ReadOnly);
|
||||
EditorGUILayout.PropertyField(m_RichText);
|
||||
EditorGUILayout.PropertyField(m_RichTextEditingAllowed, new GUIContent("Allow Rich Text Editing"));
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(m_OnValueChanged);
|
||||
EditorGUILayout.PropertyField(m_OnEndEdit);
|
||||
EditorGUILayout.PropertyField(m_OnSelect);
|
||||
EditorGUILayout.PropertyField(m_OnDeselect);
|
||||
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93f8eb123b3a5584788171226e3095ff
|
||||
timeCreated: 1457861621
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
282
Assets/TextMesh Pro/Scripts/Editor/TMP_MarkupTagUpdateUtility.cs
Normal file
282
Assets/TextMesh Pro/Scripts/Editor/TMP_MarkupTagUpdateUtility.cs
Normal file
@@ -0,0 +1,282 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
internal class TMP_MarkupTagUpdateUtility
|
||||
{
|
||||
struct MarkupTagDescriptor
|
||||
{
|
||||
public string name;
|
||||
public string tag;
|
||||
public string description;
|
||||
|
||||
public MarkupTagDescriptor(string name, string tag, string description)
|
||||
{
|
||||
this.name = name;
|
||||
this.tag = tag;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public MarkupTagDescriptor(string name)
|
||||
{
|
||||
this.name = name;
|
||||
this.tag = null;
|
||||
this.description = null;
|
||||
}
|
||||
|
||||
public static MarkupTagDescriptor linefeed = new MarkupTagDescriptor("\n");
|
||||
}
|
||||
|
||||
private static MarkupTagDescriptor[] m_MarkupTags =
|
||||
{
|
||||
new MarkupTagDescriptor("BOLD", "b", "// <b>"),
|
||||
new MarkupTagDescriptor("SLASH_BOLD", "/b", "// </b>"),
|
||||
new MarkupTagDescriptor("ITALIC", "i", "// <i>"),
|
||||
new MarkupTagDescriptor("SLASH_ITALIC", "/i", "// </i>"),
|
||||
new MarkupTagDescriptor("UNDERLINE", "u", "// <u>"),
|
||||
new MarkupTagDescriptor("SLASH_UNDERLINE", "/u", "// </u>"),
|
||||
new MarkupTagDescriptor("STRIKETHROUGH", "s", "// <s>"),
|
||||
new MarkupTagDescriptor("SLASH_STRIKETHROUGH", "/s", "// </s>"),
|
||||
new MarkupTagDescriptor("SUBSCRIPT", "sub", "// <sub>"),
|
||||
new MarkupTagDescriptor("SLASH_SUBSCRIPT", "/sub", "// </sub>"),
|
||||
new MarkupTagDescriptor("SUPERSCRIPT", "sup", "// <sup>"),
|
||||
new MarkupTagDescriptor("SLASH_SUPERSCRIPT", "/sup", "// </sup>"),
|
||||
new MarkupTagDescriptor("MARK", "mark", "// <mark>"),
|
||||
new MarkupTagDescriptor("SLASH_MARK", "/mark", "// </mark>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("COLOR", "color", "// <color>"),
|
||||
new MarkupTagDescriptor("SLASH_COLOR", "/color", "// </color>"),
|
||||
new MarkupTagDescriptor("ALPHA", "alpha", "// <alpha>"),
|
||||
new MarkupTagDescriptor("SLASH_ALPHA", "/alpha", "// </alpha>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("FONT", "font", "// <font=\"Name of Font Asset\"> or <font family=\"Arial\" style=\"Regular\">" ),
|
||||
new MarkupTagDescriptor("SLASH_FONT", "/font", "// </font>"),
|
||||
new MarkupTagDescriptor("MATERIAL", "material", "// <material=\"Name of Material Preset\"> or as attribute <font=\"Name of font asset\" material=\"Name of material\">"),
|
||||
new MarkupTagDescriptor("SLASH_MATERIAL", "/material", "// </material>"),
|
||||
new MarkupTagDescriptor("SIZE", "size", "// <size>"),
|
||||
new MarkupTagDescriptor("SLASH_SIZE", "/size", "// </size>"),
|
||||
new MarkupTagDescriptor("FONT_WEIGHT", "font-weight", "// <font-weight>"),
|
||||
new MarkupTagDescriptor("SLASH_FONT_WEIGHT", "/font-weight", "// </font-weight>"),
|
||||
new MarkupTagDescriptor("SCALE", "scale", "// <scale>"),
|
||||
new MarkupTagDescriptor("SLASH_SCALE", "/scale", "// </scale>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("SPRITE", "sprite", "// <sprite>"),
|
||||
new MarkupTagDescriptor("STYLE", "style", "// <style>"),
|
||||
new MarkupTagDescriptor("SLASH_STYLE", "/style", "// </style>"),
|
||||
new MarkupTagDescriptor("GRADIENT", "gradient", "// <gradient>"),
|
||||
new MarkupTagDescriptor("SLASH_GRADIENT", "/gradient", "// </gradient>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("A", "a", "// <a>"),
|
||||
new MarkupTagDescriptor("SLASH_A", "/a", "// </a>"),
|
||||
new MarkupTagDescriptor("LINK", "link", "// <link>"),
|
||||
new MarkupTagDescriptor("SLASH_LINK", "/link", "// </link>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("POSITION", "pos", "// <pos>"),
|
||||
new MarkupTagDescriptor("SLASH_POSITION", "/pos", "// </pos>"),
|
||||
new MarkupTagDescriptor("VERTICAL_OFFSET", "voffset","// <voffset>"),
|
||||
new MarkupTagDescriptor("SLASH_VERTICAL_OFFSET", "/voffset", "// </voffset>"),
|
||||
new MarkupTagDescriptor("ROTATE", "rotate", "// <rotate>"),
|
||||
new MarkupTagDescriptor("SLASH_ROTATE", "/rotate", "// </rotate>"),
|
||||
new MarkupTagDescriptor("TRANSFORM", "transform","// <transform=\"position, rotation, scale\">"),
|
||||
new MarkupTagDescriptor("SLASH_TRANSFORM", "/transform", "// </transform>"),
|
||||
new MarkupTagDescriptor("SPACE", "space", "// <space>"),
|
||||
new MarkupTagDescriptor("SLASH_SPACE", "/space", "// </space>"),
|
||||
new MarkupTagDescriptor("CHARACTER_SPACE", "cspace", "// <cspace>"),
|
||||
new MarkupTagDescriptor("SLASH_CHARACTER_SPACE", "/cspace", "// </cspace>"),
|
||||
new MarkupTagDescriptor("MONOSPACE", "mspace", "// <mspace>"),
|
||||
new MarkupTagDescriptor("SLASH_MONOSPACE", "/mspace", "// </mspace>"),
|
||||
new MarkupTagDescriptor("CHARACTER_SPACING", "character-spacing", "// <character-spacing>"),
|
||||
new MarkupTagDescriptor("SLASH_CHARACTER_SPACING", "/character-spacing", "// </character-spacing>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("ALIGN", "align", "// <align>"),
|
||||
new MarkupTagDescriptor("SLASH_ALIGN", "/align", "// </align>"),
|
||||
new MarkupTagDescriptor("WIDTH", "width", "// <width>"),
|
||||
new MarkupTagDescriptor("SLASH_WIDTH", "/width", "// </width>"),
|
||||
new MarkupTagDescriptor("MARGIN", "margin", "// <margin>"),
|
||||
new MarkupTagDescriptor("SLASH_MARGIN", "/margin", "// </margin>"),
|
||||
new MarkupTagDescriptor("MARGIN_LEFT", "margin-left", "// <margin-left>"),
|
||||
new MarkupTagDescriptor("MARGIN_RIGHT", "margin-right", "// <margin-right>"),
|
||||
new MarkupTagDescriptor("INDENT", "indent", "// <indent>"),
|
||||
new MarkupTagDescriptor("SLASH_INDENT", "/indent", "// </indent>"),
|
||||
new MarkupTagDescriptor("LINE_INDENT", "line-indent", "// <line-indent>"),
|
||||
new MarkupTagDescriptor("SLASH_LINE_INDENT", "/line-indent", "// </line-indent>"),
|
||||
new MarkupTagDescriptor("LINE_HEIGHT", "line-height", "// <line-height>"),
|
||||
new MarkupTagDescriptor("SLASH_LINE_HEIGHT", "/line-height", "// </line-height>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("NO_BREAK", "nobr", "// <nobr>"),
|
||||
new MarkupTagDescriptor("SLASH_NO_BREAK", "/nobr", "// </nobr>"),
|
||||
new MarkupTagDescriptor("NO_PARSE", "noparse","// <noparse>"),
|
||||
new MarkupTagDescriptor("SLASH_NO_PARSE", "/noparse", "// </noparse>"),
|
||||
new MarkupTagDescriptor("PAGE", "page", "// <page>"),
|
||||
new MarkupTagDescriptor("SLASH_PAGE", "/page", "// </page>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("ACTION", "action", "// <action>"),
|
||||
new MarkupTagDescriptor("SLASH_ACTION", "/action", "// </action>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("CLASS", "class", "// <class>"),
|
||||
new MarkupTagDescriptor("TABLE", "table", "// <table>"),
|
||||
new MarkupTagDescriptor("SLASH_TABLE", "/table", "// </table>"),
|
||||
new MarkupTagDescriptor("TH", "th", "// <th>"),
|
||||
new MarkupTagDescriptor("SLASH_TH", "/th", "// </th>"),
|
||||
new MarkupTagDescriptor("TR", "tr", "// <tr>"),
|
||||
new MarkupTagDescriptor("SLASH_TR", "/tr", "// </tr>"),
|
||||
new MarkupTagDescriptor("TD", "td", "// <td>"),
|
||||
new MarkupTagDescriptor("SLASH_TD", "/td", "// </td>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("// Text Styles"),
|
||||
new MarkupTagDescriptor("LOWERCASE", "lowercase", "// <lowercase>"),
|
||||
new MarkupTagDescriptor("SLASH_LOWERCASE", "/lowercase", "// </lowercase>"),
|
||||
new MarkupTagDescriptor("ALLCAPS", "allcaps", "// <allcaps>"),
|
||||
new MarkupTagDescriptor("SLASH_ALLCAPS", "/allcaps", "// </allcaps>"),
|
||||
new MarkupTagDescriptor("UPPERCASE", "uppercase", "// <uppercase>"),
|
||||
new MarkupTagDescriptor("SLASH_UPPERCASE", "/uppercase", "// </uppercase>"),
|
||||
new MarkupTagDescriptor("SMALLCAPS", "smallcaps", "// <smallcaps>"),
|
||||
new MarkupTagDescriptor("SLASH_SMALLCAPS", "/smallcaps", "// </smallcaps>"),
|
||||
new MarkupTagDescriptor("CAPITALIZE", "capitalize", "// <capitalize>"),
|
||||
new MarkupTagDescriptor("SLASH_CAPITALIZE", "/capitalize", "// </capitalize>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("// Font Features"),
|
||||
new MarkupTagDescriptor("LIGA", "liga", "// <liga>"),
|
||||
new MarkupTagDescriptor("SLASH_LIGA", "/liga", "// </liga>"),
|
||||
new MarkupTagDescriptor("FRAC", "frac", "// <frac>"),
|
||||
new MarkupTagDescriptor("SLASH_FRAC", "/frac", "// </frac>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("// Attributes"),
|
||||
new MarkupTagDescriptor("NAME", "name", "// <sprite name=\"Name of Sprite\">"),
|
||||
new MarkupTagDescriptor("INDEX", "index", "// <sprite index=7>"),
|
||||
new MarkupTagDescriptor("TINT", "tint", "// <tint=bool>"),
|
||||
new MarkupTagDescriptor("ANIM", "anim", "// <anim=\"first frame, last frame, frame rate\">"),
|
||||
new MarkupTagDescriptor("HREF", "href", "// <a href=\"url\">text to be displayed.</a>"),
|
||||
new MarkupTagDescriptor("ANGLE", "angle", "// <i angle=\"40\">Italic Slant Angle</i>"),
|
||||
new MarkupTagDescriptor("FAMILY", "family", "// <font family=\"Arial\">"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("// Named Colors"),
|
||||
new MarkupTagDescriptor("RED", "red",""),
|
||||
new MarkupTagDescriptor("GREEN", "green", ""),
|
||||
new MarkupTagDescriptor("BLUE", "blue", ""),
|
||||
new MarkupTagDescriptor("WHITE", "white", ""),
|
||||
new MarkupTagDescriptor("BLACK", "black", ""),
|
||||
new MarkupTagDescriptor("CYAN", "cyna", ""),
|
||||
new MarkupTagDescriptor("MAGENTA", "magenta", ""),
|
||||
new MarkupTagDescriptor("YELLOW", "yellow", ""),
|
||||
new MarkupTagDescriptor("ORANGE", "orange", ""),
|
||||
new MarkupTagDescriptor("PURPLE", "purple", ""),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("// Unicode Characters"),
|
||||
new MarkupTagDescriptor("BR", "br", "// <br> Line Feed (LF) \\u0A"),
|
||||
new MarkupTagDescriptor("ZWSP", "zwsp", "// <zwsp> Zero Width Space \\u200B"),
|
||||
new MarkupTagDescriptor("NBSP", "nbsp", "// <nbsp> Non Breaking Space \\u00A0"),
|
||||
new MarkupTagDescriptor("SHY", "shy", "// <shy> Soft Hyphen \\u00AD"),
|
||||
new MarkupTagDescriptor("ZWJ", "zwj", "// <zwj> Zero Width Joiner \\u200D"),
|
||||
new MarkupTagDescriptor("WJ", "wj", "// <wj> Word Joiner \\u2060"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("// Alignment"),
|
||||
new MarkupTagDescriptor("LEFT", "left", "// <align=left>"),
|
||||
new MarkupTagDescriptor("RIGHT", "right", "// <align=right>"),
|
||||
new MarkupTagDescriptor("CENTER", "center", "// <align=center>"),
|
||||
new MarkupTagDescriptor("JUSTIFIED", "justified", "// <align=justified>"),
|
||||
new MarkupTagDescriptor("FLUSH", "flush", "// <align=flush>"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("// Prefix and Unit suffix"),
|
||||
new MarkupTagDescriptor("NONE", "none", ""),
|
||||
new MarkupTagDescriptor("PLUS", "+", ""),
|
||||
new MarkupTagDescriptor("MINUS", "-", ""),
|
||||
new MarkupTagDescriptor("PX", "px", ""),
|
||||
new MarkupTagDescriptor("PLUS_PX", "+px", ""),
|
||||
new MarkupTagDescriptor("MINUS_PX", "-px", ""),
|
||||
new MarkupTagDescriptor("EM", "em", ""),
|
||||
new MarkupTagDescriptor("PLUS_EM", "+em", ""),
|
||||
new MarkupTagDescriptor("MINUS_EM", "-em", ""),
|
||||
new MarkupTagDescriptor("PCT", "pct", ""),
|
||||
new MarkupTagDescriptor("PLUS_PCT", "+pct", ""),
|
||||
new MarkupTagDescriptor("MINUS_PCT", "-pct", ""),
|
||||
new MarkupTagDescriptor("PERCENTAGE", "%", ""),
|
||||
new MarkupTagDescriptor("PLUS_PERCENTAGE", "+%", ""),
|
||||
new MarkupTagDescriptor("MINUS_PERCENTAGE", "-%", ""),
|
||||
new MarkupTagDescriptor("HASH", "#", "// #"),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("TRUE", "true", ""),
|
||||
new MarkupTagDescriptor("FALSE", "false", ""),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("INVALID", "invalid", ""),
|
||||
MarkupTagDescriptor.linefeed,
|
||||
|
||||
new MarkupTagDescriptor("NORMAL", "normal", "// <style=\"Normal\">"),
|
||||
new MarkupTagDescriptor("DEFAULT", "default", "// <font=\"Default\">"),
|
||||
};
|
||||
|
||||
|
||||
[MenuItem("Window/TextMeshPro/Internal/Update Markup Tag Hash Codes", false, 2200, true)]
|
||||
static void UpdateMarkupTagHashCodes()
|
||||
{
|
||||
Dictionary<int, MarkupTagDescriptor> markupHashCodes = new Dictionary<int, MarkupTagDescriptor>();
|
||||
string output = string.Empty;
|
||||
|
||||
for (int i = 0; i < m_MarkupTags.Length; i++)
|
||||
{
|
||||
MarkupTagDescriptor descriptor = m_MarkupTags[i];
|
||||
int hashCode = descriptor.tag == null ? 0 : GetHashCodeCaseInSensitive(descriptor.tag);
|
||||
|
||||
if (descriptor.name == "\n")
|
||||
output += "\n";
|
||||
else if (hashCode == 0)
|
||||
output += descriptor.name + "\n";
|
||||
else
|
||||
{
|
||||
output += descriptor.name + " = " + hashCode + ",\t" + descriptor.description + "\n";
|
||||
|
||||
if (markupHashCodes.ContainsKey(hashCode) == false)
|
||||
markupHashCodes.Add(hashCode, descriptor);
|
||||
else
|
||||
Debug.Log("[" + descriptor.name + "] with HashCode [" + hashCode + "] collides with [" + markupHashCodes[hashCode].name + "].");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log(output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Table used to convert character to uppercase.
|
||||
/// </summary>
|
||||
const string k_lookupStringU = "-------------------------------- !-#$%&-()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[-]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~-";
|
||||
|
||||
/// <summary>
|
||||
/// Get uppercase version of this ASCII character.
|
||||
/// </summary>
|
||||
public static char ToUpperFast(char c)
|
||||
{
|
||||
if (c > k_lookupStringU.Length - 1)
|
||||
return c;
|
||||
|
||||
return k_lookupStringU[c];
|
||||
}
|
||||
|
||||
public static int GetHashCodeCaseInSensitive(string s)
|
||||
{
|
||||
int hashCode = 5381;
|
||||
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
hashCode = (hashCode << 5) + hashCode ^ ToUpperFast(s[i]);
|
||||
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 225b67dcce9247b4c806e435b34695d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1118
Assets/TextMesh Pro/Scripts/Editor/TMP_PackageUtilities.cs
Normal file
1118
Assets/TextMesh Pro/Scripts/Editor/TMP_PackageUtilities.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04722392050a47c49b7b361cdbab4617
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public class TMP_PostBuildProcessHandler
|
||||
{
|
||||
[PostProcessBuildAttribute(10000)]
|
||||
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target == BuildTarget.iOS)
|
||||
{
|
||||
// Try loading the TMP Settings
|
||||
TMP_Settings settings = Resources.Load<TMP_Settings>("TMP Settings");
|
||||
|
||||
if (settings == null || TMP_Settings.enableEmojiSupport == false)
|
||||
return;
|
||||
|
||||
string file = Path.Combine(pathToBuiltProject, "Classes/UI/Keyboard.mm");
|
||||
string content = File.ReadAllText(file);
|
||||
content = content.Replace("FILTER_EMOJIS_IOS_KEYBOARD 1", "FILTER_EMOJIS_IOS_KEYBOARD 0");
|
||||
File.WriteAllText(file, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70339e75bf6d99c41beb541646e89717
|
||||
timeCreated: 1479886230
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
#if !UNITY_2018_3_OR_NEWER
|
||||
using UnityEditor;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
public static class TMP_ProjectTextSettings
|
||||
{
|
||||
// Open Project Text Settings
|
||||
[MenuItem("Edit/Project Settings/TextMeshPro Settings", false, 309)]
|
||||
public static void SelectProjectTextSettings()
|
||||
{
|
||||
TMP_Settings textSettings = TMP_Settings.instance;
|
||||
|
||||
if (textSettings)
|
||||
{
|
||||
Selection.activeObject = textSettings;
|
||||
|
||||
// TODO: Do we want to ping the Project Text Settings asset in the Project Inspector
|
||||
EditorUtility.FocusProjectWindow();
|
||||
EditorGUIUtility.PingObject(textSettings);
|
||||
}
|
||||
else
|
||||
TMPro_EventManager.RESOURCE_LOAD_EVENT.Add(ON_RESOURCES_LOADED);
|
||||
}
|
||||
|
||||
|
||||
// Event received when TMP resources have been loaded.
|
||||
static void ON_RESOURCES_LOADED()
|
||||
{
|
||||
TMPro_EventManager.RESOURCE_LOAD_EVENT.Remove(ON_RESOURCES_LOADED);
|
||||
|
||||
TMP_Settings textSettings = TMP_Settings.instance;
|
||||
|
||||
Selection.activeObject = textSettings;
|
||||
|
||||
// TODO: Do we want to ping the Project Text Settings asset in the Project Inspector
|
||||
EditorUtility.FocusProjectWindow();
|
||||
EditorGUIUtility.PingObject(textSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc2cdafa31541b5419ed60bdde4c0c6d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
159
Assets/TextMesh Pro/Scripts/Editor/TMP_ResourcesLoader.cs
Normal file
159
Assets/TextMesh Pro/Scripts/Editor/TMP_ResourcesLoader.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.Text;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
/*[InitializeOnLoad]
|
||||
class EssentialResourcesManager
|
||||
{
|
||||
private const string s_TMP_API_UpdaterGUID = "bde53ab20f68be04b816a9e44ae1bba2";
|
||||
//const string k_EssentialResourcesShaderVersionCheckKey = "TMP.EssentialResources.ShaderVersionCheck";
|
||||
|
||||
static EssentialResourcesManager()
|
||||
{
|
||||
string currentBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
|
||||
//Check for and inject TMP_INSTALLED
|
||||
if (!currentBuildSettings.Contains("TMP_API_UPDATER_ENABLED"))
|
||||
{
|
||||
//PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings + ";TMP_PRESENT");
|
||||
Debug.Log(currentBuildSettings + " " + EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
}
|
||||
}
|
||||
|
||||
/*static void CheckShaderVersions()
|
||||
{
|
||||
// Get path to TMP shader include file.
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(s_TMPShaderIncludeGUID);
|
||||
|
||||
if (string.IsNullOrEmpty(assetPath))
|
||||
return;
|
||||
|
||||
AssetImporter importer = AssetImporter.GetAtPath(assetPath);
|
||||
|
||||
if (importer != null && string.IsNullOrEmpty(importer.userData))
|
||||
{
|
||||
// Show Shader Import Window
|
||||
TMP_EditorCoroutine.StartCoroutine(ShowShaderPackageImporterWindow());
|
||||
}
|
||||
|
||||
SessionState.SetBool(k_EssentialResourcesShaderVersionCheckKey, true);
|
||||
}
|
||||
|
||||
static IEnumerator ShowShaderPackageImporterWindow()
|
||||
{
|
||||
yield return new WaitForSeconds(5.0f);
|
||||
|
||||
TMP_ShaderPackageImporterWindow.ShowPackageImporterWindow();
|
||||
}#1#
|
||||
}*/
|
||||
|
||||
/*
|
||||
[InitializeOnLoad]
|
||||
class EssentialResourcesManager
|
||||
{
|
||||
private const string s_TMPShaderIncludeGUID = "407bc68d299748449bbf7f48ee690f8d";
|
||||
const string k_EssentialResourcesShaderVersionCheckKey = "TMP.EssentialResources.ShaderVersionCheck";
|
||||
|
||||
static EssentialResourcesManager()
|
||||
{
|
||||
bool shaderSearched = SessionState.GetBool(k_EssentialResourcesShaderVersionCheckKey, false);
|
||||
|
||||
if (!EditorApplication.isPlayingOrWillChangePlaymode && !shaderSearched)
|
||||
CheckShaderVersions();
|
||||
}
|
||||
|
||||
static void CheckShaderVersions()
|
||||
{
|
||||
// Get path to TMP shader include file.
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(s_TMPShaderIncludeGUID);
|
||||
|
||||
if (string.IsNullOrEmpty(assetPath))
|
||||
return;
|
||||
|
||||
AssetImporter importer = AssetImporter.GetAtPath(assetPath);
|
||||
|
||||
if (importer != null && string.IsNullOrEmpty(importer.userData))
|
||||
{
|
||||
// Show Shader Import Window
|
||||
TMP_EditorCoroutine.StartCoroutine(ShowShaderPackageImporterWindow());
|
||||
}
|
||||
|
||||
SessionState.SetBool(k_EssentialResourcesShaderVersionCheckKey, true);
|
||||
}
|
||||
|
||||
static IEnumerator ShowShaderPackageImporterWindow()
|
||||
{
|
||||
yield return new WaitForSeconds(5.0f);
|
||||
|
||||
TMP_ShaderPackageImporterWindow.ShowPackageImporterWindow();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
//[InitializeOnLoad]
|
||||
class TMP_ResourcesLoader
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Function to pre-load the TMP Resources
|
||||
/// </summary>
|
||||
public static void LoadTextMeshProResources()
|
||||
{
|
||||
//TMP_Settings.LoadDefaultSettings();
|
||||
//TMP_StyleSheet.LoadDefaultStyleSheet();
|
||||
}
|
||||
|
||||
|
||||
static TMP_ResourcesLoader()
|
||||
{
|
||||
//Debug.Log("Loading TMP Resources...");
|
||||
|
||||
// Get current targetted platform
|
||||
|
||||
|
||||
//string Settings = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone);
|
||||
//TMPro.TMP_Settings.LoadDefaultSettings();
|
||||
//TMPro.TMP_StyleSheet.LoadDefaultStyleSheet();
|
||||
}
|
||||
|
||||
|
||||
//[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
//static void OnBeforeSceneLoaded()
|
||||
//{
|
||||
//Debug.Log("Before scene is loaded.");
|
||||
|
||||
// //TMPro.TMP_Settings.LoadDefaultSettings();
|
||||
// //TMPro.TMP_StyleSheet.LoadDefaultStyleSheet();
|
||||
|
||||
// //ShaderVariantCollection collection = new ShaderVariantCollection();
|
||||
// //Shader s0 = Shader.Find("TextMeshPro/Mobile/Distance Field");
|
||||
// //ShaderVariantCollection.ShaderVariant tmp_Variant = new ShaderVariantCollection.ShaderVariant(s0, UnityEngine.Rendering.PassType.Normal, string.Empty);
|
||||
|
||||
// //collection.Add(tmp_Variant);
|
||||
// //collection.WarmUp();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
//static class TMP_ProjectSettings
|
||||
//{
|
||||
// [InitializeOnLoadMethod]
|
||||
// static void SetProjectDefineSymbols()
|
||||
// {
|
||||
// string currentBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
|
||||
// //Check for and inject TMP_INSTALLED
|
||||
// if (!currentBuildSettings.Contains("TMP_PRESENT"))
|
||||
// {
|
||||
// PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings + ";TMP_PRESENT");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa98276813a22a34d86255568892b322
|
||||
timeCreated: 1465441092
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
789
Assets/TextMesh Pro/Scripts/Editor/TMP_SDFShaderGUI.cs
Normal file
789
Assets/TextMesh Pro/Scripts/Editor/TMP_SDFShaderGUI.cs
Normal file
@@ -0,0 +1,789 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
public class TMP_SDFShaderGUI : TMP_BaseShaderGUI
|
||||
{
|
||||
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" };
|
||||
|
||||
|
||||
static TMP_SDFShaderGUI()
|
||||
{
|
||||
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")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void DoGUI()
|
||||
{
|
||||
bool isSRPMaterial = m_Material.HasProperty(ShaderUtilities.ID_IsoPerimeter);
|
||||
|
||||
s_Face = BeginPanel("Face", s_Face);
|
||||
if (s_Face)
|
||||
{
|
||||
DoFacePanel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
|
||||
// Outline panels
|
||||
if (isSRPMaterial)
|
||||
{
|
||||
DoOutlinePanels();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_Outline = m_Material.HasProperty(ShaderUtilities.ID_OutlineTex) ? BeginPanel("Outline", s_Outline) : BeginPanel("Outline", s_OutlineFeature, s_Outline);
|
||||
if (s_Outline)
|
||||
{
|
||||
DoOutlinePanel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
|
||||
if (m_Material.HasProperty(ShaderUtilities.ID_Outline2Color))
|
||||
{
|
||||
s_Outline2 = BeginPanel("Outline 2", s_OutlineFeature, s_Outline2);
|
||||
if (s_Outline2)
|
||||
{
|
||||
DoOutline2Panel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
}
|
||||
}
|
||||
|
||||
// Underlay panel
|
||||
if (m_Material.HasProperty(ShaderUtilities.ID_UnderlayColor))
|
||||
{
|
||||
if (isSRPMaterial)
|
||||
{
|
||||
s_Underlay = BeginPanel("Underlay", s_Underlay);
|
||||
if (s_Underlay)
|
||||
{
|
||||
DoUnderlayPanel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_Underlay = BeginPanel("Underlay", s_UnderlayFeature, s_Underlay);
|
||||
if (s_Underlay)
|
||||
{
|
||||
DoUnderlayPanel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
}
|
||||
}
|
||||
|
||||
// Lighting panel
|
||||
if (m_Material.HasProperty("_SpecularColor"))
|
||||
{
|
||||
if (isSRPMaterial)
|
||||
DrawLightingPanelSRP();
|
||||
else
|
||||
DrawLightingPanelLegacy();
|
||||
}
|
||||
|
||||
|
||||
else if (m_Material.HasProperty("_SpecColor"))
|
||||
{
|
||||
s_Bevel = BeginPanel("Bevel", s_Bevel);
|
||||
if (s_Bevel)
|
||||
{
|
||||
DoBevelPanel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
|
||||
s_Light = BeginPanel("Surface Lighting", s_Light);
|
||||
if (s_Light)
|
||||
{
|
||||
DoSurfaceLightingPanel();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
if (isSRPMaterial)
|
||||
DoDebugPanelSRP();
|
||||
else
|
||||
DoDebugPanel();
|
||||
}
|
||||
EndPanel();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (isSRPMaterial)
|
||||
{
|
||||
m_Editor.RenderQueueField();
|
||||
m_Editor.EnableInstancingField();
|
||||
m_Editor.DoubleSidedGIField();
|
||||
m_Editor.EmissionEnabledProperty();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLightingPanelSRP()
|
||||
{
|
||||
s_Lighting = BeginPanel("Lighting", s_Lighting);
|
||||
if (s_Lighting)
|
||||
{
|
||||
s_Bevel = BeginPanel("Bevel", s_Bevel);
|
||||
if (s_Bevel)
|
||||
{
|
||||
DoBevelPanelSRP();
|
||||
}
|
||||
EndPanel();
|
||||
|
||||
s_Light = BeginPanel("Local Lighting", s_Light);
|
||||
if (s_Light)
|
||||
{
|
||||
DoLocalLightingPanel();
|
||||
}
|
||||
EndPanel();
|
||||
}
|
||||
|
||||
EndPanel();
|
||||
}
|
||||
|
||||
private void DrawLightingPanelLegacy()
|
||||
{
|
||||
s_Lighting = BeginPanel("Lighting", s_BevelFeature, 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 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 DoOutlinePanel()
|
||||
{
|
||||
EditorGUI.indentLevel += 1;
|
||||
DoColor("_OutlineColor", "Color");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
DoSlider("_OutlineWidth", "Thickness");
|
||||
if (m_Material.HasProperty("_OutlineShininess"))
|
||||
{
|
||||
DoSlider("_OutlineShininess", "Gloss");
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel -= 1;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
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 DoOutline2Panel()
|
||||
{
|
||||
EditorGUI.indentLevel += 1;
|
||||
DoColor("_Outline2Color", "Color");
|
||||
//if (m_Material.HasProperty(ShaderUtilities.ID_OutlineTex))
|
||||
//{
|
||||
// if (m_Material.HasProperty("_OutlineUVSpeedX"))
|
||||
// {
|
||||
// DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedNames);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// DoTexture2D("_OutlineTex", "Texture", true);
|
||||
// }
|
||||
//}
|
||||
|
||||
DoSlider("_Outline2Width", "Thickness");
|
||||
//if (m_Material.HasProperty("_OutlineShininess"))
|
||||
//{
|
||||
// DoSlider("_OutlineShininess", "Gloss");
|
||||
//}
|
||||
|
||||
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 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 DoBevelPanel()
|
||||
{
|
||||
EditorGUI.indentLevel += 1;
|
||||
DoPopup("_ShaderFlags", "Type", s_BevelTypeLabels);
|
||||
DoSlider("_Bevel", "Amount");
|
||||
DoSlider("_BevelOffset", "Offset");
|
||||
DoSlider("_BevelWidth", "Width");
|
||||
DoSlider("_BevelRoundness", "Roundness");
|
||||
DoSlider("_BevelClamp", "Clamp");
|
||||
EditorGUI.indentLevel -= 1;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
void DoBevelPanelSRP()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user