@@ -7,7 +7,6 @@ namespace RTLTMPro
77 [ CustomEditor ( typeof ( RTLTextMeshPro ) ) , CanEditMultipleObjects ]
88 public class RTLTextMeshProEditor : TMP_UiEditorPanel
99 {
10- private static readonly string [ ] UIStateLabel = { "\t - <i>Click to expand</i> -" , "\t - <i>Click to collapse</i> -" } ;
1110 private SerializedProperty originalTextProp ;
1211 private SerializedProperty havePropertiesChangedProp ;
1312 private SerializedProperty inputSourceProp ;
@@ -19,7 +18,6 @@ public class RTLTextMeshProEditor : TMP_UiEditorPanel
1918
2019 private bool changed ;
2120 private bool foldout ;
22- private GUIStyle fixNumberStyle ;
2321 private RTLTextMeshPro tmpro ;
2422
2523 private new void OnEnable ( )
@@ -40,65 +38,51 @@ public override void OnInspectorGUI()
4038 {
4139 serializedObject . Update ( ) ;
4240 tmpro = ( RTLTextMeshPro ) target ;
41+
42+ EditorGUILayout . Space ( ) ;
43+ EditorGUI . BeginChangeCheck ( ) ;
44+ EditorGUILayout . PropertyField ( originalTextProp , new GUIContent ( "RTL Text Input Box" ) ) ;
4345
44- // Copy Default GUI Toggle Style
45- if ( fixNumberStyle == null )
46- {
47- fixNumberStyle = new GUIStyle ( GUI . skin . label )
48- {
49- fontSize = 12 ,
50- normal = { textColor = TMP_UIStyleManager . Section_Label . normal . textColor } ,
51- richText = true
52- } ;
53- }
46+ ListenForZeroWidthNoJoiner ( ) ;
5447
55- EditorGUILayout . BeginVertical ( GUI . skin . box ) ;
56- DrawOptions ( ) ;
57- if ( GUILayout . Button ( "Re-Fix" ) )
58- changed = true ;
59- EditorGUILayout . EndVertical ( ) ;
60-
6148 if ( EditorGUI . EndChangeCheck ( ) )
6249 {
50+ inputSourceProp . enumValueIndex = 0 ;
51+ isInputPasingRequiredProp . boolValue = true ;
6352 changed = true ;
6453 }
6554
66- Rect rect = EditorGUILayout . GetControlRect ( false , 25 ) ;
67- rect . y += 2 ;
55+ if ( changed )
56+ OnChanged ( ) ;
57+
58+ serializedObject . ApplyModifiedProperties ( ) ;
6859
69- GUI . Label ( rect , "<b>RTL TEXT INPUT BOX</b>" + ( foldout ? UIStateLabel [ 1 ] : UIStateLabel [ 0 ] ) , TMP_UIStyleManager . Section_Label ) ;
70- if ( GUI . Button ( new Rect ( rect . x , rect . y , rect . width - 150 , rect . height ) , GUIContent . none , GUI . skin . label ) )
71- foldout = ! foldout ;
60+ base . OnInspectorGUI ( ) ;
7261
62+ foldout = EditorGUILayout . Foldout ( foldout , "RTL Settings" , TMP_UIStyleManager . boldFoldout ) ;
7363 if ( foldout )
7464 {
75- EditorGUI . BeginChangeCheck ( ) ;
76- originalTextProp . stringValue = GUILayout . TextArea ( originalTextProp . stringValue , TMP_UIStyleManager . TextAreaBoxEditor , GUILayout . Height ( 125 ) , GUILayout . ExpandWidth ( true ) ) ;
65+ DrawOptions ( ) ;
7766
78- ListenForZeroWidthNoJoiner ( ) ;
67+ if ( GUILayout . Button ( "Re-Fix" ) )
68+ changed = true ;
7969
8070 if ( EditorGUI . EndChangeCheck ( ) )
8171 {
82- inputSourceProp . enumValueIndex = 0 ;
83- isInputPasingRequiredProp . boolValue = true ;
8472 changed = true ;
8573 }
8674 }
8775
88- serializedObject . ApplyModifiedProperties ( ) ;
89-
90- if ( changed )
91- {
92- tmpro . UpdateText ( ) ;
93-
94- havePropertiesChangedProp . boolValue = true ;
95- changed = false ;
96- EditorUtility . SetDirty ( target ) ;
97- }
98-
99- serializedObject . ApplyModifiedProperties ( ) ;
76+ if ( changed )
77+ OnChanged ( ) ;
78+ }
10079
101- base . OnInspectorGUI ( ) ;
80+ protected void OnChanged ( )
81+ {
82+ tmpro . UpdateText ( ) ;
83+ havePropertiesChangedProp . boolValue = true ;
84+ changed = false ;
85+ EditorUtility . SetDirty ( target ) ;
10286 }
10387
10488 protected virtual void DrawOptions ( )
@@ -118,12 +102,12 @@ protected virtual void DrawOptions()
118102 protected virtual void ListenForZeroWidthNoJoiner ( )
119103 {
120104 var editor = ( TextEditor ) GUIUtility . GetStateObject ( typeof ( TextEditor ) , GUIUtility . keyboardControl ) ;
121-
105+
122106 bool shortcutPressed = ( Event . current . modifiers & EventModifiers . Control ) != 0 &&
123- ( Event . current . modifiers & EventModifiers . Shift ) != 0 &&
124- Event . current . type == EventType . KeyUp &&
125- Event . current . keyCode == KeyCode . Alpha2 ;
126-
107+ ( Event . current . modifiers & EventModifiers . Shift ) != 0 &&
108+ Event . current . type == EventType . KeyUp &&
109+ Event . current . keyCode == KeyCode . Alpha2 ;
110+
127111 if ( ! shortcutPressed ) return ;
128112
129113 originalTextProp . stringValue = originalTextProp . stringValue . Insert ( editor . cursorIndex , ( ( char ) GeneralLetters . ZeroWidthNoJoiner ) . ToString ( ) ) ;
0 commit comments