9
9
using UnityExplorer . UI ;
10
10
using UnityExplorer . UI . Utility ;
11
11
using UnityExplorer . UI . CacheObject ;
12
+ using UnityExplorer . Core . Runtime ;
12
13
13
14
namespace UnityExplorer . UI . InteractiveValues
14
15
{
@@ -27,8 +28,8 @@ public override void OnValueUpdated()
27
28
// strings boxed as Il2CppSystem.Objects can behave weirdly.
28
29
// GetActualType will find they are a string, but if its boxed
29
30
// then we need to unbox it like this...
30
- if ( ! ( Value is string ) )
31
- Value = ( ( Il2CppSystem . Object ) Value ) . ToString ( ) ;
31
+ if ( ! ( Value is string ) && Value is Il2CppSystem . Object cppobj )
32
+ Value = cppobj . ToString ( ) ;
32
33
#endif
33
34
34
35
base . OnValueUpdated ( ) ;
@@ -96,10 +97,18 @@ public override void RefreshUIForValue()
96
97
m_labelLayout . flexibleWidth = 0 ;
97
98
}
98
99
99
- internal void OnApplyClicked ( )
100
+ internal void SetValueFromInput ( )
100
101
{
101
102
Value = m_valueInput . text ;
103
+
104
+ if ( ! typeof ( string ) . IsAssignableFrom ( Owner . FallbackType ) )
105
+ ReflectionProvider . Instance . BoxStringToType ( ref Value , Owner . FallbackType ) ;
106
+
102
107
Owner . SetValue ( ) ;
108
+
109
+ // revert back to string now
110
+ OnValueUpdated ( ) ;
111
+
103
112
RefreshUIForValue ( ) ;
104
113
}
105
114
@@ -170,7 +179,7 @@ public override void ConstructSubcontent()
170
179
171
180
if ( Owner . CanWrite )
172
181
{
173
- var apply = UIFactory . CreateButton ( groupObj , "ApplyButton" , "Apply" , OnApplyClicked , new Color ( 0.2f , 0.2f , 0.2f ) ) ;
182
+ var apply = UIFactory . CreateButton ( groupObj , "ApplyButton" , "Apply" , SetValueFromInput , new Color ( 0.2f , 0.2f , 0.2f ) ) ;
174
183
UIFactory . SetLayoutElement ( apply . gameObject , minWidth : 50 , minHeight : 25 , flexibleWidth : 0 ) ;
175
184
}
176
185
else
0 commit comments