using UnityEditor; using UnityEngine; namespace OctoCore.Localization.Editor { [CustomEditor(typeof(OctoLocalizedText))] public class OctoLocalizedTextEditor : UnityEditor.Editor { public override void OnInspectorGUI() { serializedObject.Update(); OctoLocalizedText target = (OctoLocalizedText)this.target; target.Data = (OctoLocalizedTextData)EditorGUILayout.ObjectField( "Data", target.Data, typeof(OctoLocalizedTextData), false ); GUI.enabled = false; SerializedProperty textProp = serializedObject.FindProperty("text"); SerializedProperty textMeshProProp = serializedObject.FindProperty("textMeshPro"); SerializedProperty textMeshProUGUIProp = serializedObject.FindProperty("textMeshProUGUI"); 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 component found.", MessageType.Info); GUI.enabled = true; serializedObject.ApplyModifiedProperties(); if (GUI.changed) EditorUtility.SetDirty(target); } } }