13
13
using UniverseLib . UI . Models ;
14
14
using UniverseLib . UI . Widgets ;
15
15
using UniverseLib . UI . Widgets . ScrollView ;
16
+ using UniverseLib . Utility ;
16
17
17
18
namespace UnityExplorer . UI . Widgets
18
19
{
@@ -36,6 +37,7 @@ public class TransformCell : ICell
36
37
public ButtonRef ExpandButton ;
37
38
public ButtonRef NameButton ;
38
39
public Toggle EnabledToggle ;
40
+ public InputFieldRef SiblingIndex ;
39
41
40
42
public LayoutElement spacer ;
41
43
@@ -77,6 +79,9 @@ public void ConfigureCell(CachedTransform cached, int cellIndex)
77
79
78
80
EnabledToggle . Set ( cached . Value . gameObject . activeSelf , false ) ;
79
81
82
+ if ( ! SiblingIndex . Component . isFocused )
83
+ SiblingIndex . Text = cached . Value . GetSiblingIndex ( ) . ToString ( ) ;
84
+
80
85
int childCount = cached . Value . childCount ;
81
86
if ( childCount > 0 )
82
87
{
@@ -118,6 +123,17 @@ private void OnEnableClicked(bool value)
118
123
OnEnableToggled ? . Invoke ( cachedTransform ) ;
119
124
}
120
125
126
+ private void OnSiblingIndexEndEdit ( string input )
127
+ {
128
+ if ( this . cachedTransform == null || ! this . cachedTransform . Value )
129
+ return ;
130
+
131
+ if ( int . TryParse ( input . Trim ( ) , out int index ) )
132
+ this . cachedTransform . Value . SetSiblingIndex ( index ) ;
133
+
134
+ this . SiblingIndex . Text = this . cachedTransform . Value . GetSiblingIndex ( ) . ToString ( ) ;
135
+ }
136
+
121
137
public GameObject CreateContent ( GameObject parent )
122
138
{
123
139
UIRoot = UIFactory . CreateUIObject ( "TransformCell" , parent ) ;
@@ -152,10 +168,22 @@ public GameObject CreateContent(GameObject parent)
152
168
nameLabel . horizontalOverflow = HorizontalWrapMode . Overflow ;
153
169
nameLabel . alignment = TextAnchor . MiddleLeft ;
154
170
155
- Color normal = new Color ( 0.11f , 0.11f , 0.11f ) ;
156
- Color highlight = new Color ( 0.25f , 0.25f , 0.25f ) ;
157
- Color pressed = new Color ( 0.05f , 0.05f , 0.05f ) ;
158
- Color disabled = new Color ( 1 , 1 , 1 , 0 ) ;
171
+ // Sibling index input
172
+
173
+ SiblingIndex = UIFactory . CreateInputField ( this . UIRoot , "SiblingIndexInput" , string . Empty ) ;
174
+ SiblingIndex . Component . textComponent . fontSize = 11 ;
175
+ SiblingIndex . Component . textComponent . alignment = TextAnchor . MiddleRight ;
176
+ var siblingImage = SiblingIndex . GameObject . GetComponent < Image > ( ) ;
177
+ siblingImage . color = new ( 0f , 0f , 0f , 0.25f ) ;
178
+ UIFactory . SetLayoutElement ( SiblingIndex . GameObject , 35 , 20 , 0 , 0 ) ;
179
+ SiblingIndex . Component . GetOnEndEdit ( ) . AddListener ( OnSiblingIndexEndEdit ) ;
180
+
181
+ // Setup selectables
182
+
183
+ Color normal = new ( 0.11f , 0.11f , 0.11f ) ;
184
+ Color highlight = new ( 0.25f , 0.25f , 0.25f ) ;
185
+ Color pressed = new ( 0.05f , 0.05f , 0.05f ) ;
186
+ Color disabled = new ( 1 , 1 , 1 , 0 ) ;
159
187
RuntimeHelper . SetColorBlock ( ExpandButton . Component , normal , highlight , pressed , disabled ) ;
160
188
RuntimeHelper . SetColorBlock ( NameButton . Component , normal , highlight , pressed , disabled ) ;
161
189
0 commit comments