first commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
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 += 16;
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
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;
|
||||
EditorGUI.PropertyField(rect, itemImage, GUIContent.none);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
Init(property);
|
||||
|
||||
return m_ReorderableList.GetHeight();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9545c9eb3bf94265810463794fec8334
|
||||
timeCreated: 1464818008
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
[CustomPropertyDrawer(typeof(TMP_Glyph))]
|
||||
public class GlyphInfoDrawer : PropertyDrawer
|
||||
{
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
SerializedProperty prop_id = property.FindPropertyRelative("id");
|
||||
SerializedProperty prop_x = property.FindPropertyRelative("x");
|
||||
SerializedProperty prop_y = property.FindPropertyRelative("y");
|
||||
SerializedProperty prop_width = property.FindPropertyRelative("width");
|
||||
SerializedProperty prop_height = property.FindPropertyRelative("height");
|
||||
SerializedProperty prop_xOffset = property.FindPropertyRelative("xOffset");
|
||||
SerializedProperty prop_yOffset = property.FindPropertyRelative("yOffset");
|
||||
SerializedProperty prop_xAdvance = property.FindPropertyRelative("xAdvance");
|
||||
SerializedProperty prop_scale = property.FindPropertyRelative("scale");
|
||||
|
||||
|
||||
// We get Rect since a valid position may not be provided by the caller.
|
||||
Rect rect = GUILayoutUtility.GetRect(position.width, 48);
|
||||
rect.y -= 15;
|
||||
|
||||
//GUI.enabled = false;
|
||||
EditorGUIUtility.labelWidth = 40f;
|
||||
EditorGUIUtility.fieldWidth = 45f;
|
||||
|
||||
bool prevGuiState = GUI.enabled;
|
||||
GUI.enabled = true;
|
||||
EditorGUI.LabelField(new Rect(rect.x + 5f, rect.y, 80f, 18), new GUIContent("Ascii: <color=#FFFF80>" + prop_id.intValue + "</color>"), TMP_UIStyleManager.label);
|
||||
EditorGUI.LabelField(new Rect(rect.x + 90f, rect.y, 80f, 18), new GUIContent("Hex: <color=#FFFF80>" + prop_id.intValue.ToString("X") + "</color>"), TMP_UIStyleManager.label);
|
||||
EditorGUI.LabelField(new Rect(rect.x + 170f, rect.y, 80, 18), "Char: [ <color=#FFFF80>" + (char)prop_id.intValue + "</color> ]", TMP_UIStyleManager.label);
|
||||
GUI.enabled = prevGuiState;
|
||||
|
||||
EditorGUIUtility.labelWidth = 35f;
|
||||
EditorGUIUtility.fieldWidth = 10f;
|
||||
|
||||
float width = (rect.width - 5f) / 4;
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 5f + width * 0, rect.y + 22, width - 5f, 18), prop_x, new GUIContent("X:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 5f + width * 1, rect.y + 22, width - 5f, 18), prop_y, new GUIContent("Y:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 5f + width * 2, rect.y + 22, width - 5f, 18), prop_width, new GUIContent("W:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 5f + width * 3, rect.y + 22, width - 5f, 18), prop_height, new GUIContent("H:"));
|
||||
|
||||
//GUI.enabled = true;
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 5f + width * 0, rect.y + 44, width - 5f, 18), prop_xOffset, new GUIContent("OX:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 5f + width * 1, rect.y + 44, width - 5f, 18), prop_yOffset, new GUIContent("OY:"));
|
||||
//GUI.enabled = true;
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 5f + width * 2, rect.y + 44, width - 5f, 18), prop_xAdvance, new GUIContent("ADV:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 5f + width * 3, rect.y + 44, width - 5f, 18), prop_scale, new GUIContent("SF:"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 900f1a451c764dc3bdcc0de815a15935
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,53 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
[CustomPropertyDrawer(typeof(GlyphMetrics))]
|
||||
public class GlyphMetricsPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
SerializedProperty prop_Width = property.FindPropertyRelative("m_Width");
|
||||
SerializedProperty prop_Height = property.FindPropertyRelative("m_Height");
|
||||
SerializedProperty prop_HoriBearingX = property.FindPropertyRelative("m_HorizontalBearingX");
|
||||
SerializedProperty prop_HoriBearingY = property.FindPropertyRelative("m_HorizontalBearingY");
|
||||
SerializedProperty prop_HoriAdvance = property.FindPropertyRelative("m_HorizontalAdvance");
|
||||
|
||||
// We get Rect since a valid position may not be provided by the caller.
|
||||
Rect rect = new Rect(position.x, position.y, position.width, 49);
|
||||
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y - 2.5f, rect.width, 18), new GUIContent("Glyph Metrics"));
|
||||
|
||||
EditorGUIUtility.labelWidth = 50f;
|
||||
EditorGUIUtility.fieldWidth = 15f;
|
||||
|
||||
//GUI.enabled = false;
|
||||
float width = (rect.width - 75f) / 2;
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 0, rect.y + 20, width - 5f, 18), prop_Width, new GUIContent("W:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 1, rect.y + 20, width - 5f, 18), prop_Height, new GUIContent("H:"));
|
||||
|
||||
//GUI.enabled = true;
|
||||
|
||||
width = (rect.width - 75f) / 3;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 0, rect.y + 40, width - 5f, 18), prop_HoriBearingX, new GUIContent("BX:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 1, rect.y + 40, width - 5f, 18), prop_HoriBearingY, new GUIContent("BY:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 2, rect.y + 40, width - 5f, 18), prop_HoriAdvance, new GUIContent("AD:"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return 65f;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3882522a08b6f5459b4dea6f8791278
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
[CustomPropertyDrawer(typeof(GlyphRect))]
|
||||
public class GlyphRectPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
//EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
SerializedProperty prop_X = property.FindPropertyRelative("m_X");
|
||||
SerializedProperty prop_Y = property.FindPropertyRelative("m_Y");
|
||||
SerializedProperty prop_Width = property.FindPropertyRelative("m_Width");
|
||||
SerializedProperty prop_Height = property.FindPropertyRelative("m_Height");
|
||||
|
||||
// We get Rect since a valid position may not be provided by the caller.
|
||||
Rect rect = new Rect(position.x, position.y, position.width, 49);
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y - 2.5f, rect.width, 18), new GUIContent("Glyph Rect"));
|
||||
|
||||
EditorGUIUtility.labelWidth = 50f;
|
||||
EditorGUIUtility.fieldWidth = 20f;
|
||||
|
||||
//GUI.enabled = false;
|
||||
float width = (rect.width - 75f) / 4;
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 0, rect.y + 20, width - 5f, 18), prop_X, new GUIContent("X:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 1, rect.y + 20, width - 5f, 18), prop_Y, new GUIContent("Y:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 2, rect.y + 20, width - 5f, 18), prop_Width, new GUIContent("W:"));
|
||||
EditorGUI.PropertyField(new Rect(rect.x + width * 3, rect.y + 20, width - 5f, 18), prop_Height, new GUIContent("H:"));
|
||||
|
||||
//EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return 45f;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bc2b083b068f3546a9509c805e0541c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91950f78729ab144aa36e94690b28fad
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 438efd46088d408d8a53f707fa68d976
|
||||
timeCreated: 1469844810
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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: 806de5a9211448c8b65c8435ebb48dd4
|
||||
timeCreated: 1469998850
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,235 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(TMP_Character))]
|
||||
public class TMP_CharacterPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
private string k_ColorProperty = "_Color";
|
||||
|
||||
int m_GlyphSelectedForEditing = -1;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
SerializedProperty prop_Unicode = property.FindPropertyRelative("m_Unicode");
|
||||
SerializedProperty prop_GlyphIndex = property.FindPropertyRelative("m_GlyphIndex");
|
||||
SerializedProperty prop_Scale = property.FindPropertyRelative("m_Scale");
|
||||
|
||||
|
||||
GUIStyle style = new GUIStyle(EditorStyles.label);
|
||||
style.richText = true;
|
||||
|
||||
EditorGUIUtility.labelWidth = 40f;
|
||||
EditorGUIUtility.fieldWidth = 50;
|
||||
|
||||
Rect rect = new Rect(position.x + 50, position.y, position.width, 49);
|
||||
|
||||
// Display non-editable fields
|
||||
if (GUI.enabled == false)
|
||||
{
|
||||
int unicode = prop_Unicode.intValue;
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y, 120f, 18), new GUIContent("Unicode: <color=#FFFF80>0x" + unicode.ToString("X") + "</color>"), style);
|
||||
EditorGUI.LabelField(new Rect(rect.x + 115, rect.y, 120f, 18), unicode <= 0xFFFF ? new GUIContent("UTF16: <color=#FFFF80>\\u" + unicode.ToString("X4") + "</color>") : new GUIContent("UTF32: <color=#FFFF80>\\U" + unicode.ToString("X8") + "</color>"), style);
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y + 18, 120, 18), new GUIContent("Glyph ID: <color=#FFFF80>" + prop_GlyphIndex.intValue + "</color>"), style);
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y + 36, 80, 18), new GUIContent("Scale: <color=#FFFF80>" + prop_Scale.floatValue + "</color>"), style);
|
||||
|
||||
// Draw Glyph (if exists)
|
||||
DrawGlyph(position, property);
|
||||
}
|
||||
else // Display editable fields
|
||||
{
|
||||
EditorGUIUtility.labelWidth = 55f;
|
||||
GUI.SetNextControlName("Unicode Input");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string unicode = EditorGUI.TextField(new Rect(rect.x, rect.y, 120, 18), "Unicode:", prop_Unicode.intValue.ToString("X"));
|
||||
|
||||
if (GUI.GetNameOfFocusedControl() == "Unicode Input")
|
||||
{
|
||||
//Filter out unwanted characters.
|
||||
char chr = Event.current.character;
|
||||
if ((chr < '0' || chr > '9') && (chr < 'a' || chr > 'f') && (chr < 'A' || chr > 'F'))
|
||||
{
|
||||
Event.current.character = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
// Update Unicode value
|
||||
prop_Unicode.intValue = TMP_TextUtilities.StringHexToInt(unicode);
|
||||
}
|
||||
|
||||
// Cache current glyph index in case it needs to be restored if the new glyph index is invalid.
|
||||
int currentGlyphIndex = prop_GlyphIndex.intValue;
|
||||
|
||||
EditorGUIUtility.labelWidth = 59f;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.DelayedIntField(new Rect(rect.x, rect.y + 18, 100, 18), prop_GlyphIndex, new GUIContent("Glyph ID:"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
// Get a reference to the font asset
|
||||
TMP_FontAsset fontAsset = property.serializedObject.targetObject as TMP_FontAsset;
|
||||
|
||||
// Make sure new glyph index is valid.
|
||||
int elementIndex = fontAsset.glyphTable.FindIndex(item => item.index == prop_GlyphIndex.intValue);
|
||||
|
||||
if (elementIndex == -1)
|
||||
prop_GlyphIndex.intValue = currentGlyphIndex;
|
||||
else
|
||||
fontAsset.IsFontAssetLookupTablesDirty = true;
|
||||
}
|
||||
|
||||
int glyphIndex = prop_GlyphIndex.intValue;
|
||||
|
||||
// Reset glyph selection if new character has been selected.
|
||||
if (GUI.enabled && m_GlyphSelectedForEditing != glyphIndex)
|
||||
m_GlyphSelectedForEditing = -1;
|
||||
|
||||
// Display button to edit the glyph data.
|
||||
if (GUI.Button(new Rect(rect.x + 120, rect.y + 18, 75, 18), new GUIContent("Edit Glyph")))
|
||||
{
|
||||
if (m_GlyphSelectedForEditing == -1)
|
||||
m_GlyphSelectedForEditing = glyphIndex;
|
||||
else
|
||||
m_GlyphSelectedForEditing = -1;
|
||||
|
||||
// Button clicks should not result in potential change.
|
||||
GUI.changed = false;
|
||||
}
|
||||
|
||||
// Show the glyph property drawer if selected
|
||||
if (glyphIndex == m_GlyphSelectedForEditing && GUI.enabled)
|
||||
{
|
||||
// Get a reference to the font asset
|
||||
TMP_FontAsset fontAsset = property.serializedObject.targetObject as TMP_FontAsset;
|
||||
|
||||
if (fontAsset != null)
|
||||
{
|
||||
// Get the index of the glyph in the font asset glyph table.
|
||||
int elementIndex = fontAsset.glyphTable.FindIndex(item => item.index == glyphIndex);
|
||||
|
||||
if (elementIndex != -1)
|
||||
{
|
||||
SerializedProperty prop_GlyphTable = property.serializedObject.FindProperty("m_GlyphTable");
|
||||
SerializedProperty prop_Glyph = prop_GlyphTable.GetArrayElementAtIndex(elementIndex);
|
||||
|
||||
SerializedProperty prop_GlyphMetrics = prop_Glyph.FindPropertyRelative("m_Metrics");
|
||||
SerializedProperty prop_GlyphRect = prop_Glyph.FindPropertyRelative("m_GlyphRect");
|
||||
|
||||
Rect newRect = EditorGUILayout.GetControlRect(false, 115);
|
||||
EditorGUI.DrawRect(new Rect(newRect.x + 52, newRect.y - 20, newRect.width - 52, newRect.height - 5), new Color(0.1f, 0.1f, 0.1f, 0.45f));
|
||||
EditorGUI.DrawRect(new Rect(newRect.x + 53, newRect.y - 19, newRect.width - 54, newRect.height - 7), new Color(0.3f, 0.3f, 0.3f, 0.8f));
|
||||
|
||||
// Display GlyphRect
|
||||
newRect.x += 55;
|
||||
newRect.y -= 18;
|
||||
newRect.width += 5;
|
||||
EditorGUI.PropertyField(newRect, prop_GlyphRect);
|
||||
|
||||
// Display GlyphMetrics
|
||||
newRect.y += 45;
|
||||
EditorGUI.PropertyField(newRect, prop_GlyphMetrics);
|
||||
|
||||
rect.y += 120;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUIUtility.labelWidth = 39f;
|
||||
EditorGUI.PropertyField(new Rect(rect.x, rect.y + 36, 80, 18), prop_Scale, new GUIContent("Scale:"));
|
||||
|
||||
// Draw Glyph (if exists)
|
||||
DrawGlyph(position, property);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return 58;
|
||||
}
|
||||
|
||||
void DrawGlyph(Rect position, SerializedProperty property)
|
||||
{
|
||||
// Get a reference to the atlas texture
|
||||
TMP_FontAsset fontAsset = property.serializedObject.targetObject as TMP_FontAsset;
|
||||
|
||||
if (fontAsset == null)
|
||||
return;
|
||||
|
||||
// Get a reference to the Glyph Table
|
||||
SerializedProperty prop_GlyphTable = property.serializedObject.FindProperty("m_GlyphTable");
|
||||
int glyphIndex = property.FindPropertyRelative("m_GlyphIndex").intValue;
|
||||
int elementIndex = fontAsset.glyphTable.FindIndex(item => item.index == glyphIndex);
|
||||
|
||||
// Return if we can't find the glyph
|
||||
if (elementIndex == -1)
|
||||
return;
|
||||
|
||||
SerializedProperty prop_Glyph = prop_GlyphTable.GetArrayElementAtIndex(elementIndex);
|
||||
|
||||
// Get reference to atlas texture.
|
||||
int atlasIndex = prop_Glyph.FindPropertyRelative("m_AtlasIndex").intValue;
|
||||
Texture2D atlasTexture = fontAsset.atlasTextures.Length > atlasIndex ? fontAsset.atlasTextures[atlasIndex] : null;
|
||||
|
||||
if (atlasTexture == null)
|
||||
return;
|
||||
|
||||
Material mat;
|
||||
if (((GlyphRasterModes)fontAsset.atlasRenderMode & GlyphRasterModes.RASTER_MODE_BITMAP) == GlyphRasterModes.RASTER_MODE_BITMAP)
|
||||
{
|
||||
mat = TMP_FontAssetEditor.internalBitmapMaterial;
|
||||
|
||||
if (mat == null)
|
||||
return;
|
||||
|
||||
mat.mainTexture = atlasTexture;
|
||||
mat.SetColor(k_ColorProperty, Color.white);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat = TMP_FontAssetEditor.internalSDFMaterial;
|
||||
|
||||
if (mat == null)
|
||||
return;
|
||||
|
||||
mat.mainTexture = atlasTexture;
|
||||
mat.SetFloat(ShaderUtilities.ID_GradientScale, fontAsset.atlasPadding + 1);
|
||||
}
|
||||
|
||||
// Draw glyph
|
||||
Rect glyphDrawPosition = new Rect(position.x, position.y, 48, 58);
|
||||
|
||||
SerializedProperty glyphRectProperty = prop_Glyph.FindPropertyRelative("m_GlyphRect");
|
||||
|
||||
int padding = fontAsset.atlasPadding;
|
||||
|
||||
int glyphOriginX = glyphRectProperty.FindPropertyRelative("m_X").intValue - padding;
|
||||
int glyphOriginY = glyphRectProperty.FindPropertyRelative("m_Y").intValue - padding;
|
||||
int glyphWidth = glyphRectProperty.FindPropertyRelative("m_Width").intValue + padding * 2;
|
||||
int glyphHeight = glyphRectProperty.FindPropertyRelative("m_Height").intValue + padding * 2;
|
||||
|
||||
float normalizedHeight = fontAsset.faceInfo.ascentLine - fontAsset.faceInfo.descentLine;
|
||||
float scale = glyphDrawPosition.width / normalizedHeight;
|
||||
|
||||
// Compute the normalized texture coordinates
|
||||
Rect texCoords = new Rect((float)glyphOriginX / atlasTexture.width, (float)glyphOriginY / atlasTexture.height, (float)glyphWidth / atlasTexture.width, (float)glyphHeight / atlasTexture.height);
|
||||
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
glyphDrawPosition.x += (glyphDrawPosition.width - glyphWidth * scale) / 2;
|
||||
glyphDrawPosition.y += (glyphDrawPosition.height - glyphHeight * scale) / 2;
|
||||
glyphDrawPosition.width = glyphWidth * scale;
|
||||
glyphDrawPosition.height = glyphHeight * scale;
|
||||
|
||||
// Could switch to using the default material of the font asset which would require passing scale to the shader.
|
||||
Graphics.DrawTexture(glyphDrawPosition, atlasTexture, texCoords, 0, 0, 0, 0, new Color(1f, 1f, 1f), mat);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01ada73c4792aba4c937ff5d92cce866
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,50 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
public static class TMP_ColorGradientAssetMenu
|
||||
{
|
||||
[MenuItem("Assets/Create/TextMeshPro/Color Gradient", false, 115)]
|
||||
public static void CreateColorGradient(MenuCommand context)
|
||||
{
|
||||
string filePath;
|
||||
|
||||
if (Selection.assetGUIDs.Length == 0)
|
||||
filePath = "Assets/New TMP Color Gradient.asset";
|
||||
else
|
||||
filePath = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
|
||||
|
||||
if (Directory.Exists(filePath))
|
||||
{
|
||||
filePath += "/New TMP Color Gradient.asset";
|
||||
}
|
||||
else
|
||||
{
|
||||
filePath = Path.GetDirectoryName(filePath) + "/New TMP Color Gradient.asset";
|
||||
}
|
||||
|
||||
filePath = AssetDatabase.GenerateUniqueAssetPath(filePath);
|
||||
|
||||
// Create new Color Gradient Asset.
|
||||
TMP_ColorGradient colorGradient = ScriptableObject.CreateInstance<TMP_ColorGradient>();
|
||||
|
||||
// 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: d9647b571c5e44729b71d756b3d55317
|
||||
timeCreated: 1468187791
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,146 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
[CustomEditor(typeof(TMP_ColorGradient))]
|
||||
public class TMP_ColorGradientEditor : Editor
|
||||
{
|
||||
SerializedProperty m_ColorMode;
|
||||
SerializedProperty m_TopLeftColor;
|
||||
SerializedProperty m_TopRightColor;
|
||||
SerializedProperty m_BottomLeftColor;
|
||||
SerializedProperty m_BottomRightColor;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
m_ColorMode = serializedObject.FindProperty("colorMode");
|
||||
m_TopLeftColor = serializedObject.FindProperty("topLeft");
|
||||
m_TopRightColor = serializedObject.FindProperty("topRight");
|
||||
m_BottomLeftColor = serializedObject.FindProperty("bottomLeft");
|
||||
m_BottomRightColor = serializedObject.FindProperty("bottomRight");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_ColorMode, new GUIContent("Color Mode"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
switch ((ColorMode)m_ColorMode.enumValueIndex)
|
||||
{
|
||||
case ColorMode.Single:
|
||||
m_TopRightColor.colorValue = m_TopLeftColor.colorValue;
|
||||
m_BottomLeftColor.colorValue = m_TopLeftColor.colorValue;
|
||||
m_BottomRightColor.colorValue = m_TopLeftColor.colorValue;
|
||||
break;
|
||||
case ColorMode.HorizontalGradient:
|
||||
m_BottomLeftColor.colorValue = m_TopLeftColor.colorValue;
|
||||
m_BottomRightColor.colorValue = m_TopRightColor.colorValue;
|
||||
break;
|
||||
case ColorMode.VerticalGradient:
|
||||
m_TopRightColor.colorValue = m_TopLeftColor.colorValue;
|
||||
m_BottomRightColor.colorValue = m_BottomLeftColor.colorValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Rect rect;
|
||||
switch ((ColorMode)m_ColorMode.enumValueIndex)
|
||||
{
|
||||
case ColorMode.Single:
|
||||
EditorGUI.BeginChangeCheck();
|
||||
rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2));
|
||||
EditorGUI.PrefixLabel(rect, new GUIContent("Colors"));
|
||||
rect.x += EditorGUIUtility.labelWidth;
|
||||
rect.width = (rect.width - EditorGUIUtility.labelWidth) / (EditorGUIUtility.wideMode ? 1f : 2f);
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_TopLeftColor);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_TopRightColor.colorValue = m_TopLeftColor.colorValue;
|
||||
m_BottomLeftColor.colorValue = m_TopLeftColor.colorValue;
|
||||
m_BottomRightColor.colorValue = m_TopLeftColor.colorValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case ColorMode.HorizontalGradient:
|
||||
rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2));
|
||||
EditorGUI.PrefixLabel(rect, new GUIContent("Colors"));
|
||||
rect.x += EditorGUIUtility.labelWidth;
|
||||
rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2f;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_TopLeftColor);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_BottomLeftColor.colorValue = m_TopLeftColor.colorValue;
|
||||
}
|
||||
|
||||
rect.x += rect.width;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_TopRightColor);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_BottomRightColor.colorValue = m_TopRightColor.colorValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case ColorMode.VerticalGradient:
|
||||
rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2));
|
||||
EditorGUI.PrefixLabel(rect, new GUIContent("Colors"));
|
||||
rect.x += EditorGUIUtility.labelWidth;
|
||||
rect.width = (rect.width - EditorGUIUtility.labelWidth) / (EditorGUIUtility.wideMode ? 1f : 2f);
|
||||
rect.height = EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_TopLeftColor);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_TopRightColor.colorValue = m_TopLeftColor.colorValue;
|
||||
}
|
||||
|
||||
rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2));
|
||||
rect.x += EditorGUIUtility.labelWidth;
|
||||
rect.width = (rect.width - EditorGUIUtility.labelWidth) / (EditorGUIUtility.wideMode ? 1f : 2f);
|
||||
rect.height = EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_BottomLeftColor);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_BottomRightColor.colorValue = m_BottomLeftColor.colorValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case ColorMode.FourCornersGradient:
|
||||
rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2));
|
||||
EditorGUI.PrefixLabel(rect, new GUIContent("Colors"));
|
||||
rect.x += EditorGUIUtility.labelWidth;
|
||||
rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2f;
|
||||
rect.height = EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2);
|
||||
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_TopLeftColor);
|
||||
rect.x += rect.width;
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_TopRightColor);
|
||||
|
||||
rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2));
|
||||
rect.x += EditorGUIUtility.labelWidth;
|
||||
rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2f;
|
||||
rect.height = EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2);
|
||||
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_BottomLeftColor);
|
||||
rect.x += rect.width;
|
||||
TMP_EditorUtility.DrawColorProperty(rect, m_BottomRightColor);
|
||||
break;
|
||||
}
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties())
|
||||
TMPro_EventManager.ON_COLOR_GRADIENT_PROPERTY_CHANGED(target as TMP_ColorGradient);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcc60c1d6bb544d9b712b652f418ff3a
|
||||
timeCreated: 1468400050
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,57 @@
|
||||
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_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_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_AlphaFadeSpeed);
|
||||
EditorGUILayout.PropertyField(m_Options);
|
||||
EditorGUILayout.PropertyField(m_OnSelectionChanged);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dbcf248c987476181a37f01a1814975
|
||||
timeCreated: 1446377461
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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: 27a0335dab59ec542aadd6636a5b4ebd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,204 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Presets;
|
||||
|
||||
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());
|
||||
TMPro_EventManager.ON_TEXTMESHPRO_PROPERTY_CHANGED(true, targets[i] as TextMeshPro);
|
||||
s_EventId = undoEventId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34f6695d37a94370a3697f6b068f5d5e
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,127 @@
|
||||
using UnityEngine;
|
||||
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());
|
||||
TMPro_EventManager.ON_TEXTMESHPRO_UGUI_PROPERTY_CHANGED(true, targets[i] as TextMeshProUGUI);
|
||||
s_EventId = undoEventId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21c0044a7f964773be90d197a78e4703
|
||||
timeCreated: 1443571501
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,451 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public 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>
|
||||
public 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.
|
||||
public static Material[] FindMaterialReferences(TMP_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.
|
||||
public static TMP_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++)
|
||||
{
|
||||
TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath<TMP_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>
|
||||
public 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>
|
||||
public 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>
|
||||
public 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>
|
||||
public 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>
|
||||
public 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;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2300e75732d74890b38a8ff257a3ae15
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96b44f7d98314b139324a8a87eb66067
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,258 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
using TMPro;
|
||||
|
||||
|
||||
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(TMP_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;
|
||||
}
|
||||
|
||||
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 + " - Variant.asset");
|
||||
|
||||
// Set Texture and Material reference to the source font asset.
|
||||
TMP_FontAsset fontAsset = ScriptableObject.Instantiate<TMP_FontAsset>(sourceFontAsset);
|
||||
AssetDatabase.CreateAsset(fontAsset, newAssetFilePathWithName);
|
||||
|
||||
fontAsset.atlasPopulationMode = 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;
|
||||
}
|
||||
|
||||
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 sourceFont = (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(sourceFont, 90) != FontEngineError.Success)
|
||||
{
|
||||
Debug.LogWarning("Unable to load font face for [" + sourceFont.name + "]. Make sure \"Include Font Data\" is enabled in the Font Import Settings.", sourceFont);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new Font Asset
|
||||
TMP_FontAsset fontAsset = ScriptableObject.CreateInstance<TMP_FontAsset>();
|
||||
AssetDatabase.CreateAsset(fontAsset, newAssetFilePathWithName);
|
||||
|
||||
fontAsset.version = "1.1.0";
|
||||
|
||||
fontAsset.faceInfo = FontEngine.GetFaceInfo();
|
||||
|
||||
// Set font reference and GUID
|
||||
fontAsset.m_SourceFontFileGUID = AssetDatabase.AssetPathToGUID(sourceFontFilePath);
|
||||
fontAsset.m_SourceFontFile_EditorRef = sourceFont;
|
||||
fontAsset.atlasPopulationMode = AtlasPopulationMode.Dynamic;
|
||||
|
||||
// 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.normalStyle);
|
||||
tmp_material.SetFloat(ShaderUtilities.ID_WeightBold, fontAsset.boldStyle);
|
||||
|
||||
fontAsset.material = tmp_material;
|
||||
|
||||
AssetDatabase.AddObjectToAsset(tmp_material, fontAsset);
|
||||
|
||||
// Add Font Asset Creation Settings
|
||||
fontAsset.creationSettings = new FontAssetCreationSettings(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: 7496af95dfe67cf429ac65edaaf99106
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,391 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
[CustomPropertyDrawer(typeof(TMP_GlyphPairAdjustmentRecord))]
|
||||
public class TMP_GlyphPairAdjustmentRecordPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
private bool isEditingEnabled = false;
|
||||
private bool isSelectable = false;
|
||||
|
||||
private string m_FirstCharacter = string.Empty;
|
||||
private string m_SecondCharacter = string.Empty;
|
||||
private string m_PreviousInput;
|
||||
|
||||
static GUIContent s_CharacterTextFieldLabel = new GUIContent("Char:", "Enter the character or its UTF16 or UTF32 Unicode character escape sequence. For UTF16 use \"\\uFF00\" and for UTF32 use \"\\UFF00FF00\" representation.");
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
SerializedProperty prop_FirstAdjustmentRecord = property.FindPropertyRelative("m_FirstAdjustmentRecord");
|
||||
SerializedProperty prop_SecondAdjustmentRecord = property.FindPropertyRelative("m_SecondAdjustmentRecord");
|
||||
|
||||
SerializedProperty prop_FirstGlyphIndex = prop_FirstAdjustmentRecord.FindPropertyRelative("m_GlyphIndex");
|
||||
SerializedProperty prop_FirstGlyphValueRecord = prop_FirstAdjustmentRecord.FindPropertyRelative("m_GlyphValueRecord");
|
||||
|
||||
SerializedProperty prop_SecondGlyphIndex = prop_SecondAdjustmentRecord.FindPropertyRelative("m_GlyphIndex");
|
||||
SerializedProperty prop_SecondGlyphValueRecord = prop_SecondAdjustmentRecord.FindPropertyRelative("m_GlyphValueRecord");
|
||||
|
||||
SerializedProperty prop_FontFeatureLookupFlags = property.FindPropertyRelative("m_FeatureLookupFlags");
|
||||
|
||||
position.yMin += 2;
|
||||
|
||||
float width = position.width / 2;
|
||||
float padding = 5.0f;
|
||||
|
||||
Rect rect;
|
||||
|
||||
isEditingEnabled = GUI.enabled;
|
||||
isSelectable = label.text == "Selectable" ? true : false;
|
||||
|
||||
if (isSelectable)
|
||||
GUILayoutUtility.GetRect(position.width, 75);
|
||||
else
|
||||
GUILayoutUtility.GetRect(position.width, 55);
|
||||
|
||||
GUIStyle style = new GUIStyle(EditorStyles.label);
|
||||
style.richText = true;
|
||||
|
||||
// First Glyph
|
||||
GUI.enabled = isEditingEnabled;
|
||||
if (isSelectable)
|
||||
{
|
||||
rect = new Rect(position.x + 70, position.y, position.width, 49);
|
||||
|
||||
float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_FirstGlyphIndex.intValue)).x;
|
||||
EditorGUI.LabelField(new Rect(position.x + (64 - labelWidth) / 2, position.y + 60, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_FirstGlyphIndex.intValue + "</color>"), style);
|
||||
|
||||
GUI.enabled = isEditingEnabled;
|
||||
EditorGUIUtility.labelWidth = 30f;
|
||||
|
||||
rect = new Rect(position.x + 70, position.y + 10, (width - 70) - padding, 18);
|
||||
EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_XPlacement"), new GUIContent("OX:"));
|
||||
|
||||
rect.y += 20;
|
||||
EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_YPlacement"), new GUIContent("OY:"));
|
||||
|
||||
rect.y += 20;
|
||||
EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_XAdvance"), new GUIContent("AX:"));
|
||||
|
||||
//rect.y += 20;
|
||||
//EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_YAdvance"), new GUIContent("AY:"));
|
||||
|
||||
DrawGlyph((uint)prop_FirstGlyphIndex.intValue, new Rect(position.x, position.y, position.width, position.height), property);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = new Rect(position.x, position.y, width / 2 * 0.8f - padding, 18);
|
||||
EditorGUIUtility.labelWidth = 40f;
|
||||
|
||||
// First Character Lookup
|
||||
GUI.SetNextControlName("FirstCharacterField");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string firstCharacter = EditorGUI.TextField(rect, s_CharacterTextFieldLabel, m_FirstCharacter);
|
||||
|
||||
if (GUI.GetNameOfFocusedControl() == "FirstCharacterField")
|
||||
{
|
||||
if (ValidateInput(firstCharacter))
|
||||
{
|
||||
//Debug.Log("1st Unicode value: [" + firstCharacter + "]");
|
||||
|
||||
uint unicode = GetUnicodeCharacter(firstCharacter);
|
||||
|
||||
// Lookup glyph index
|
||||
TMP_SerializedPropertyHolder propertyHolder = property.serializedObject.targetObject as TMP_SerializedPropertyHolder;
|
||||
TMP_FontAsset fontAsset = propertyHolder.fontAsset;
|
||||
if (fontAsset != null)
|
||||
{
|
||||
prop_FirstGlyphIndex.intValue = (int)fontAsset.GetGlyphIndex(unicode);
|
||||
propertyHolder.firstCharacter = unicode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
m_FirstCharacter = firstCharacter;
|
||||
|
||||
// First Glyph Index
|
||||
rect.x += width / 2 * 0.8f;
|
||||
|
||||
EditorGUIUtility.labelWidth = 25f;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.PropertyField(rect, prop_FirstGlyphIndex, new GUIContent("ID:"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GUI.enabled = isEditingEnabled;
|
||||
EditorGUIUtility.labelWidth = 25f;
|
||||
|
||||
rect = new Rect(position.x, position.y + 20, width * 0.5f - padding, 18);
|
||||
EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_XPlacement"), new GUIContent("OX"));
|
||||
|
||||
rect.x += width * 0.5f;
|
||||
EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_YPlacement"), new GUIContent("OY"));
|
||||
|
||||
rect.x = position.x;
|
||||
rect.y += 20;
|
||||
EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_XAdvance"), new GUIContent("AX"));
|
||||
|
||||
//rect.x += width * 0.5f;
|
||||
//EditorGUI.PropertyField(rect, prop_FirstGlyphAdjustment.FindPropertyRelative("m_YAdvance"), new GUIContent("AY"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Second Glyph
|
||||
GUI.enabled = isEditingEnabled;
|
||||
if (isSelectable)
|
||||
{
|
||||
float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_SecondGlyphIndex.intValue)).x;
|
||||
EditorGUI.LabelField(new Rect(position.width / 2 + 20 + (64 - labelWidth) / 2, position.y + 60, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_SecondGlyphIndex.intValue + "</color>"), style);
|
||||
|
||||
GUI.enabled = isEditingEnabled;
|
||||
EditorGUIUtility.labelWidth = 30f;
|
||||
|
||||
rect = new Rect(position.width / 2 + 20 + 70, position.y + 10, (width - 70) - padding, 18);
|
||||
EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_XPlacement"), new GUIContent("OX:"));
|
||||
|
||||
rect.y += 20;
|
||||
EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_YPlacement"), new GUIContent("OY:"));
|
||||
|
||||
rect.y += 20;
|
||||
EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_XAdvance"), new GUIContent("AX:"));
|
||||
|
||||
//rect.y += 20;
|
||||
//EditorGUI.PropertyField(rect, prop_SecondGlyphAdjustment.FindPropertyRelative("m_YAdvance"), new GUIContent("AY"));
|
||||
|
||||
DrawGlyph((uint)prop_SecondGlyphIndex.intValue, new Rect(position.width / 2 + 20, position.y, position.width, position.height), property);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = new Rect(position.width / 2 + 20, position.y, width / 2 * 0.8f - padding, 18);
|
||||
EditorGUIUtility.labelWidth = 40f;
|
||||
|
||||
// Second Character Lookup
|
||||
GUI.SetNextControlName("SecondCharacterField");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string secondCharacter = EditorGUI.TextField(rect, s_CharacterTextFieldLabel, m_SecondCharacter);
|
||||
|
||||
if (GUI.GetNameOfFocusedControl() == "SecondCharacterField")
|
||||
{
|
||||
if (ValidateInput(secondCharacter))
|
||||
{
|
||||
//Debug.Log("2nd Unicode value: [" + secondCharacter + "]");
|
||||
|
||||
uint unicode = GetUnicodeCharacter(secondCharacter);
|
||||
|
||||
// Lookup glyph index
|
||||
TMP_SerializedPropertyHolder propertyHolder = property.serializedObject.targetObject as TMP_SerializedPropertyHolder;
|
||||
TMP_FontAsset fontAsset = propertyHolder.fontAsset;
|
||||
if (fontAsset != null)
|
||||
{
|
||||
prop_SecondGlyphIndex.intValue = (int)fontAsset.GetGlyphIndex(unicode);
|
||||
propertyHolder.secondCharacter = unicode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
m_SecondCharacter = secondCharacter;
|
||||
|
||||
// Second Glyph Index
|
||||
rect.x += width / 2 * 0.8f;
|
||||
|
||||
EditorGUIUtility.labelWidth = 25f;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.PropertyField(rect, prop_SecondGlyphIndex, new GUIContent("ID:"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GUI.enabled = isEditingEnabled;
|
||||
EditorGUIUtility.labelWidth = 25f;
|
||||
|
||||
rect = new Rect(position.width / 2 + 20, position.y + 20, width * 0.5f - padding, 18);
|
||||
EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_XPlacement"), new GUIContent("OX"));
|
||||
|
||||
rect.x += width * 0.5f;
|
||||
EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_YPlacement"), new GUIContent("OY"));
|
||||
|
||||
rect.x = position.width / 2 + 20;
|
||||
rect.y += 20;
|
||||
EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_XAdvance"), new GUIContent("AX"));
|
||||
|
||||
//rect.x += width * 0.5f;
|
||||
//EditorGUI.PropertyField(rect, prop_SecondGlyphAdjustment.FindPropertyRelative("m_YAdvance"), new GUIContent("AY"));
|
||||
}
|
||||
|
||||
// Font Feature Lookup Flags
|
||||
if (isSelectable)
|
||||
{
|
||||
EditorGUIUtility.labelWidth = 55f;
|
||||
|
||||
rect.x = position.width - 255;
|
||||
rect.y += 23;
|
||||
rect.width = 270; // width - 70 - padding;
|
||||
|
||||
FontFeatureLookupFlags flags = (FontFeatureLookupFlags)prop_FontFeatureLookupFlags.intValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
flags = (FontFeatureLookupFlags)EditorGUI.EnumFlagsField(rect, new GUIContent("Options:"), flags);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop_FontFeatureLookupFlags.intValue = (int)flags;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ValidateInput(string source)
|
||||
{
|
||||
int length = string.IsNullOrEmpty(source) ? 0 : source.Length;
|
||||
|
||||
////Filter out unwanted characters.
|
||||
Event evt = Event.current;
|
||||
|
||||
char c = evt.character;
|
||||
|
||||
if (c != '\0')
|
||||
{
|
||||
switch (length)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
if (source != m_PreviousInput)
|
||||
return true;
|
||||
|
||||
if ((source[0] == '\\' && (c == 'u' || c == 'U')) == false)
|
||||
evt.character = '\0';
|
||||
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
if ((c < '0' || c > '9') && (c < 'a' || c > 'f') && (c < 'A' || c > 'F'))
|
||||
evt.character = '\0';
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
if (source[1] == 'u' || (c < '0' || c > '9') && (c < 'a' || c > 'f') && (c < 'A' || c > 'F'))
|
||||
evt.character = '\0';
|
||||
|
||||
// Validate input
|
||||
if (length == 6 && source[1] == 'u' && source != m_PreviousInput)
|
||||
return true;
|
||||
break;
|
||||
case 10:
|
||||
if (source != m_PreviousInput)
|
||||
return true;
|
||||
|
||||
evt.character = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_PreviousInput = source;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint GetUnicodeCharacter (string source)
|
||||
{
|
||||
uint unicode;
|
||||
|
||||
if (source.Length == 1)
|
||||
unicode = source[0];
|
||||
else if (source.Length == 6)
|
||||
unicode = (uint)TMP_TextUtilities.StringHexToInt(source.Replace("\\u", ""));
|
||||
else
|
||||
unicode = (uint)TMP_TextUtilities.StringHexToInt(source.Replace("\\U", ""));
|
||||
|
||||
return unicode;
|
||||
}
|
||||
|
||||
void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
|
||||
{
|
||||
// Get a reference to the font asset
|
||||
TMP_FontAsset fontAsset = property.serializedObject.targetObject as TMP_FontAsset;
|
||||
|
||||
if (fontAsset == null)
|
||||
return;
|
||||
|
||||
Glyph glyph;
|
||||
|
||||
// Check if glyph is present in the atlas texture.
|
||||
if (!fontAsset.glyphLookupTable.TryGetValue(glyphIndex, out glyph))
|
||||
return;
|
||||
|
||||
// Get the atlas index of the glyph and lookup its atlas texture
|
||||
int atlasIndex = glyph.atlasIndex;
|
||||
Texture2D atlasTexture = fontAsset.atlasTextures.Length > atlasIndex ? fontAsset.atlasTextures[atlasIndex] : null;
|
||||
|
||||
if (atlasTexture == null)
|
||||
return;
|
||||
|
||||
Material mat;
|
||||
if (((GlyphRasterModes)fontAsset.atlasRenderMode & GlyphRasterModes.RASTER_MODE_BITMAP) == GlyphRasterModes.RASTER_MODE_BITMAP)
|
||||
{
|
||||
mat = TMP_FontAssetEditor.internalBitmapMaterial;
|
||||
|
||||
if (mat == null)
|
||||
return;
|
||||
|
||||
mat.mainTexture = atlasTexture;
|
||||
}
|
||||
else
|
||||
{
|
||||
mat = TMP_FontAssetEditor.internalSDFMaterial;
|
||||
|
||||
if (mat == null)
|
||||
return;
|
||||
|
||||
mat.mainTexture = atlasTexture;
|
||||
mat.SetFloat(ShaderUtilities.ID_GradientScale, fontAsset.atlasPadding + 1);
|
||||
}
|
||||
|
||||
// Draw glyph from atlas texture.
|
||||
Rect glyphDrawPosition = new Rect(position.x, position.y + 2, 64, 60);
|
||||
|
||||
GlyphRect glyphRect = glyph.glyphRect;
|
||||
|
||||
int padding = fontAsset.atlasPadding;
|
||||
|
||||
int glyphOriginX = glyphRect.x - padding;
|
||||
int glyphOriginY = glyphRect.y - padding;
|
||||
int glyphWidth = glyphRect.width + padding * 2;
|
||||
int glyphHeight = glyphRect.height + padding * 2;
|
||||
|
||||
float normalizedHeight = fontAsset.faceInfo.ascentLine - fontAsset.faceInfo.descentLine;
|
||||
float scale = glyphDrawPosition.width / normalizedHeight;
|
||||
|
||||
// Compute the normalized texture coordinates
|
||||
Rect texCoords = new Rect((float)glyphOriginX / atlasTexture.width, (float)glyphOriginY / atlasTexture.height, (float)glyphWidth / atlasTexture.width, (float)glyphHeight / atlasTexture.height);
|
||||
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
glyphDrawPosition.x += (glyphDrawPosition.width - glyphWidth * scale) / 2;
|
||||
glyphDrawPosition.y += (glyphDrawPosition.height - glyphHeight * scale) / 2;
|
||||
glyphDrawPosition.width = glyphWidth * scale;
|
||||
glyphDrawPosition.height = glyphHeight * scale;
|
||||
|
||||
// Could switch to using the default material of the font asset which would require passing scale to the shader.
|
||||
Graphics.DrawTexture(glyphDrawPosition, atlasTexture, texCoords, 0, 0, 0, 0, new Color(1f, 1f, 1f), mat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d256fa541faf5d4409992c631adb98a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,122 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
|
||||
[CustomPropertyDrawer(typeof(Glyph))]
|
||||
public class TMP_GlyphPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
private string k_ColorProperty = "_Color";
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
SerializedProperty prop_GlyphIndex = property.FindPropertyRelative("m_Index");
|
||||
SerializedProperty prop_GlyphMetrics = property.FindPropertyRelative("m_Metrics");
|
||||
SerializedProperty prop_GlyphRect = property.FindPropertyRelative("m_GlyphRect");
|
||||
SerializedProperty prop_Scale = property.FindPropertyRelative("m_Scale");
|
||||
SerializedProperty prop_AtlasIndex = property.FindPropertyRelative("m_AtlasIndex");
|
||||
|
||||
GUIStyle style = new GUIStyle(EditorStyles.label);
|
||||
style.richText = true;
|
||||
|
||||
Rect rect = new Rect(position.x + 70, position.y, position.width, 49);
|
||||
|
||||
float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_GlyphIndex.intValue)).x;
|
||||
EditorGUI.LabelField(new Rect(position.x + (64 - labelWidth) / 2, position.y + 85, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_GlyphIndex.intValue + "</color>"), style);
|
||||
//EditorGUIUtility.labelWidth = 22f;
|
||||
//EditorGUI.DelayedIntField(new Rect(position.x + (64 - labelWidth) / 2, position.y + 89, 58f, 18f), prop_GlyphIndex, new GUIContent("ID:"));
|
||||
|
||||
// We get Rect since a valid position may not be provided by the caller.
|
||||
EditorGUI.PropertyField(new Rect(rect.x, rect.y, position.width, 49), prop_GlyphRect);
|
||||
|
||||
rect.y += 45;
|
||||
EditorGUI.PropertyField(rect, prop_GlyphMetrics);
|
||||
|
||||
EditorGUIUtility.labelWidth = 40f;
|
||||
EditorGUI.PropertyField(new Rect(rect.x, rect.y + 65, 75, 18), prop_Scale, new GUIContent("Scale:")); // new GUIContent("Scale: <color=#FFFF80>" + prop_Scale.floatValue + "</color>"), style);
|
||||
|
||||
EditorGUIUtility.labelWidth = 74f;
|
||||
EditorGUI.PropertyField(new Rect(rect.x + 85, rect.y + 65, 95, 18), prop_AtlasIndex, new GUIContent("Atlas Index:")); // new GUIContent("Atlas Index: <color=#FFFF80>" + prop_AtlasIndex.intValue + "</color>"), style);
|
||||
|
||||
DrawGlyph(position, property);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return 130f;
|
||||
}
|
||||
|
||||
void DrawGlyph(Rect position, SerializedProperty property)
|
||||
{
|
||||
// Get a reference to the sprite texture
|
||||
TMP_FontAsset fontAsset = property.serializedObject.targetObject as TMP_FontAsset;
|
||||
|
||||
if (fontAsset == null)
|
||||
return;
|
||||
|
||||
// Get reference to atlas texture.
|
||||
int atlasIndex = property.FindPropertyRelative("m_AtlasIndex").intValue;
|
||||
Texture2D atlasTexture = fontAsset.atlasTextures.Length > atlasIndex ? fontAsset.atlasTextures[atlasIndex] : null;
|
||||
|
||||
if (atlasTexture == null)
|
||||
return;
|
||||
|
||||
Material mat;
|
||||
if (((GlyphRasterModes)fontAsset.atlasRenderMode & GlyphRasterModes.RASTER_MODE_BITMAP) == GlyphRasterModes.RASTER_MODE_BITMAP)
|
||||
{
|
||||
mat = TMP_FontAssetEditor.internalBitmapMaterial;
|
||||
|
||||
if (mat == null)
|
||||
return;
|
||||
|
||||
mat.mainTexture = atlasTexture;
|
||||
mat.SetColor(k_ColorProperty, Color.white);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat = TMP_FontAssetEditor.internalSDFMaterial;
|
||||
|
||||
if (mat == null)
|
||||
return;
|
||||
|
||||
mat.mainTexture = atlasTexture;
|
||||
mat.SetFloat(ShaderUtilities.ID_GradientScale, fontAsset.atlasPadding + 1);
|
||||
}
|
||||
|
||||
// Draw glyph from atlas texture.
|
||||
Rect glyphDrawPosition = new Rect(position.x, position.y + 2, 64, 80);
|
||||
|
||||
SerializedProperty glyphRectProperty = property.FindPropertyRelative("m_GlyphRect");
|
||||
|
||||
int padding = fontAsset.atlasPadding;
|
||||
|
||||
int glyphOriginX = glyphRectProperty.FindPropertyRelative("m_X").intValue - padding;
|
||||
int glyphOriginY = glyphRectProperty.FindPropertyRelative("m_Y").intValue - padding;
|
||||
int glyphWidth = glyphRectProperty.FindPropertyRelative("m_Width").intValue + padding * 2;
|
||||
int glyphHeight = glyphRectProperty.FindPropertyRelative("m_Height").intValue + padding * 2;
|
||||
|
||||
float normalizedHeight = fontAsset.faceInfo.ascentLine - fontAsset.faceInfo.descentLine;
|
||||
float scale = glyphDrawPosition.width / normalizedHeight;
|
||||
|
||||
// Compute the normalized texture coordinates
|
||||
Rect texCoords = new Rect((float)glyphOriginX / atlasTexture.width, (float)glyphOriginY / atlasTexture.height, (float)glyphWidth / atlasTexture.width, (float)glyphHeight / atlasTexture.height);
|
||||
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
glyphDrawPosition.x += (glyphDrawPosition.width - glyphWidth * scale) / 2;
|
||||
glyphDrawPosition.y += (glyphDrawPosition.height - glyphHeight * scale) / 2;
|
||||
glyphDrawPosition.width = glyphWidth * scale;
|
||||
glyphDrawPosition.height = glyphHeight * scale;
|
||||
|
||||
// Could switch to using the default material of the font asset which would require passing scale to the shader.
|
||||
Graphics.DrawTexture(glyphDrawPosition, atlasTexture, texCoords, 0, 0, 0, 0, new Color(1f, 1f, 1f), mat);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4777500b5da6094e956c3d4f04de4db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,283 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
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_RestoreOriginalTextOnEscape;
|
||||
|
||||
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_RestoreOriginalTextOnEscape = serializedObject.FindProperty("m_RestoreOriginalTextOnEscape");
|
||||
|
||||
m_OnFocusSelectAll = serializedObject.FindProperty("m_OnFocusSelectAll");
|
||||
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 TMP_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.enableWordWrapping = false;
|
||||
else
|
||||
{
|
||||
text.enableWordWrapping = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 is DeActivated."));
|
||||
EditorGUILayout.PropertyField(m_RestoreOriginalTextOnEscape, new GUIContent("Restore On ESC Key", "Should the original text be restored when pressing ESC."));
|
||||
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: aa160f27c3fe4052a5850e21108811b6
|
||||
timeCreated: 1457861621
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,76 @@
|
||||
// When enabled, allows setting the material by dropping a material onto the MeshRenderer inspector component.
|
||||
// The drawback is that the MeshRenderer inspector will not have properties for light probes, so if you need light probe support, do not enable this.
|
||||
//#define ALLOW_MESHRENDERER_MATERIAL_DRAG_N_DROP
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro.EditorUtilities
|
||||
{
|
||||
// Disabled for compatibility reason as lightprobe setup isn't supported due to inability to inherit from MeshRendererEditor class
|
||||
#if ALLOW_MESHRENDERER_MATERIAL_DRAG_N_DROP
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(MeshRenderer))]
|
||||
public class TMP_MeshRendererEditor : Editor
|
||||
{
|
||||
private SerializedProperty m_Materials;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
m_Materials = serializedObject.FindProperty("m_Materials");
|
||||
}
|
||||
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// Get a reference to the current material.
|
||||
SerializedProperty material_prop = m_Materials.GetArrayElementAtIndex(0);
|
||||
Material currentMaterial = material_prop.objectReferenceValue as Material;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
base.OnInspectorGUI();
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
material_prop = m_Materials.GetArrayElementAtIndex(0);
|
||||
|
||||
TMP_FontAsset newFontAsset = null;
|
||||
Material newMaterial = null;
|
||||
|
||||
if (material_prop != null)
|
||||
newMaterial = material_prop.objectReferenceValue as Material;
|
||||
|
||||
// Check if the new material is referencing a different font atlas texture.
|
||||
if (newMaterial != null && currentMaterial.GetInstanceID() != newMaterial.GetInstanceID())
|
||||
{
|
||||
// Search for the Font Asset matching the new font atlas texture.
|
||||
newFontAsset = TMP_EditorUtility.FindMatchingFontAsset(newMaterial);
|
||||
}
|
||||
|
||||
|
||||
GameObject[] objects = Selection.gameObjects;
|
||||
|
||||
for (int i = 0; i < objects.Length; i++)
|
||||
{
|
||||
// Assign new font asset
|
||||
if (newFontAsset != null)
|
||||
{
|
||||
TMP_Text textComponent = objects[i].GetComponent<TMP_Text>();
|
||||
|
||||
if (textComponent != null)
|
||||
{
|
||||
Undo.RecordObject(textComponent, "Font Asset Change");
|
||||
textComponent.font = newFontAsset;
|
||||
}
|
||||
}
|
||||
|
||||
TMPro_EventManager.ON_DRAG_AND_DROP_MATERIAL_CHANGED(objects[i], currentMaterial, newMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d437b997e074079b4b2f6e395394f4b
|
||||
timeCreated: 1462864011
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68eedd4e5b33b37429c02c4add0036fe
|
||||
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)
|
||||
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: 6fdea2af3daa40fe8f88e5e9cfc17abb
|
||||
timeCreated: 1479886230
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public class TMP_PreBuildProcessor : IPreprocessBuildWithReport
|
||||
{
|
||||
public int callbackOrder { get { return 0; } }
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
// Find all font assets in the project
|
||||
string searchPattern = "t:TMP_FontAsset";
|
||||
string[] fontAssetGUIDs = AssetDatabase.FindAssets(searchPattern);
|
||||
|
||||
for (int i = 0; i < fontAssetGUIDs.Length; i++)
|
||||
{
|
||||
string fontAssetPath = AssetDatabase.GUIDToAssetPath(fontAssetGUIDs[i]);
|
||||
TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(fontAssetPath);
|
||||
|
||||
if (fontAsset != null && fontAsset.atlasPopulationMode == AtlasPopulationMode.Dynamic && fontAsset.clearDynamicDataOnBuild && fontAsset.atlasTexture.width != 0)
|
||||
{
|
||||
//Debug.Log("Clearing [" + fontAsset.name + "] dynamic font asset data.");
|
||||
fontAsset.ClearFontAssetDataInternal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06e104cf21d5fba46985b07321bbebe0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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: 0e751e877ed14d71a6b8e63ac54949cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user