52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace OctoCore.Localization.Editor
|
|
{
|
|
[CustomEditor(typeof(OctoLocalizedText))]
|
|
public class OctoLocalizedTextEditor : UnityEditor.Editor
|
|
{
|
|
SerializedProperty dataProp;
|
|
SerializedProperty textProp;
|
|
SerializedProperty textMeshProProp;
|
|
SerializedProperty textMeshProUGUIProp;
|
|
|
|
void OnEnable()
|
|
{
|
|
dataProp = serializedObject.FindProperty("data");
|
|
textProp = serializedObject.FindProperty("text");
|
|
textMeshProProp = serializedObject.FindProperty("textMeshPro");
|
|
textMeshProUGUIProp = serializedObject.FindProperty("textMeshProUGUI");
|
|
}
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
serializedObject.Update();
|
|
|
|
EditorGUILayout.PropertyField(dataProp);
|
|
|
|
GUI.enabled = false;
|
|
|
|
if (textProp.objectReferenceValue != null)
|
|
{
|
|
EditorGUILayout.PropertyField(textProp, new GUIContent("Text"));
|
|
}
|
|
else if (textMeshProProp.objectReferenceValue != null)
|
|
{
|
|
EditorGUILayout.PropertyField(textMeshProProp, new GUIContent("Text"));
|
|
}
|
|
else if (textMeshProUGUIProp.objectReferenceValue != null)
|
|
{
|
|
EditorGUILayout.PropertyField(textMeshProUGUIProp, new GUIContent("Text"));
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.HelpBox("No text componant found.", MessageType.Info);
|
|
}
|
|
|
|
GUI.enabled = true;
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
}
|
|
}
|
|
} |