7
7
using UnityExplorer . CacheObject . IValues ;
8
8
using UnityExplorer . Inspectors ;
9
9
using UnityExplorer . UI ;
10
+ using UnityExplorer . UI . Panels ;
10
11
using UnityExplorer . UI . Widgets ;
11
12
using UniverseLib ;
12
13
using UniverseLib . UI ;
@@ -47,9 +48,10 @@ public void Enable()
47
48
public LayoutElement NameLayout ;
48
49
public GameObject RightGroupContent ;
49
50
public LayoutElement RightGroupLayout ;
51
+ public GameObject SubContentHolder ;
50
52
51
53
public Text NameLabel ;
52
- public InputFieldRef HiddenNameLabel ;
54
+ public InputFieldRef HiddenNameLabel ; // for selecting the name label
53
55
public Text TypeLabel ;
54
56
public Text ValueLabel ;
55
57
public Toggle Toggle ;
@@ -60,7 +62,11 @@ public void Enable()
60
62
public ButtonRef SubContentButton ;
61
63
public ButtonRef ApplyButton ;
62
64
63
- public GameObject SubContentHolder ;
65
+ public ButtonRef CopyButton ;
66
+ public ButtonRef PasteButton ;
67
+
68
+ public readonly Color subInactiveColor = new ( 0.23f , 0.23f , 0.23f ) ;
69
+ public readonly Color subActiveColor = new ( 0.23f , 0.33f , 0.23f ) ;
64
70
65
71
protected virtual void ApplyClicked ( )
66
72
{
@@ -82,26 +88,26 @@ protected virtual void SubContentClicked()
82
88
this . Occupant . OnCellSubContentToggle ( ) ;
83
89
}
84
90
85
- public readonly Color subInactiveColor = new Color ( 0.23f , 0.23f , 0.23f ) ;
86
- public readonly Color subActiveColor = new Color ( 0.23f , 0.33f , 0.23f ) ;
91
+ protected virtual void OnCopyClicked ( )
92
+ {
93
+ ClipboardPanel . Copy ( this . Occupant . Value ) ;
94
+ }
95
+
96
+ protected virtual void OnPasteClicked ( )
97
+ {
98
+ if ( ClipboardPanel . TryPaste ( this . Occupant . FallbackType , out object paste ) )
99
+ this . Occupant . SetUserValue ( paste ) ;
100
+ }
87
101
88
102
public void RefreshSubcontentButton ( )
89
103
{
90
- if ( ! this . SubContentHolder . activeSelf )
91
- {
92
- this . SubContentButton . ButtonText . text = "▲" ;
93
- RuntimeProvider . Instance . SetColorBlock ( SubContentButton . Component , subInactiveColor , subInactiveColor * 1.3f ) ;
94
- }
95
- else
96
- {
97
- this . SubContentButton . ButtonText . text = "▼" ;
98
- RuntimeProvider . Instance . SetColorBlock ( SubContentButton . Component , subActiveColor , subActiveColor * 1.3f ) ;
99
- }
104
+ this . SubContentButton . ButtonText . text = SubContentHolder . activeSelf ? "▼" : "▲" ;
105
+ Color color = SubContentHolder . activeSelf ? subActiveColor : subInactiveColor ;
106
+ RuntimeProvider . Instance . SetColorBlock ( SubContentButton . Component , color , color * 1.3f ) ;
100
107
}
101
108
102
109
protected abstract void ConstructEvaluateHolder ( GameObject parent ) ;
103
110
104
-
105
111
public virtual GameObject CreateContent ( GameObject parent )
106
112
{
107
113
// Main layout
@@ -158,7 +164,7 @@ public virtual GameObject CreateContent(GameObject parent)
158
164
159
165
TypeLabel = UIFactory . CreateLabel ( rightHoriGroup , "ReturnLabel" , "<notset>" , TextAnchor . MiddleLeft ) ;
160
166
TypeLabel . horizontalOverflow = HorizontalWrapMode . Wrap ;
161
- UIFactory . SetLayoutElement ( TypeLabel . gameObject , minHeight : 25 , flexibleHeight : 150 , minWidth : 60 , flexibleWidth : 0 ) ;
167
+ UIFactory . SetLayoutElement ( TypeLabel . gameObject , minHeight : 25 , flexibleHeight : 150 , minWidth : 45 , flexibleWidth : 0 ) ;
162
168
163
169
// Bool and number value interaction
164
170
@@ -188,6 +194,24 @@ public virtual GameObject CreateContent(GameObject parent)
188
194
ValueLabel . horizontalOverflow = HorizontalWrapMode . Wrap ;
189
195
UIFactory . SetLayoutElement ( ValueLabel . gameObject , minHeight : 25 , flexibleHeight : 150 , flexibleWidth : 9999 ) ;
190
196
197
+ // Copy and Paste buttons
198
+
199
+ var buttonHolder = UIFactory . CreateHorizontalGroup ( rightHoriGroup , "CopyPasteButtons" , false , false , true , true , 4 ,
200
+ bgColor : new ( 1 , 1 , 1 , 0 ) , childAlignment : TextAnchor . MiddleLeft ) ;
201
+ UIFactory . SetLayoutElement ( buttonHolder , minWidth : 60 , flexibleWidth : 0 ) ;
202
+
203
+ CopyButton = UIFactory . CreateButton ( buttonHolder , "CopyButton" , "Copy" , new Color ( 0.13f , 0.13f , 0.13f , 1f ) ) ;
204
+ UIFactory . SetLayoutElement ( CopyButton . Component . gameObject , minHeight : 25 , minWidth : 28 , flexibleWidth : 0 ) ;
205
+ CopyButton . ButtonText . color = Color . yellow ;
206
+ CopyButton . ButtonText . fontSize = 10 ;
207
+ CopyButton . OnClick += OnCopyClicked ;
208
+
209
+ PasteButton = UIFactory . CreateButton ( buttonHolder , "PasteButton" , "Paste" , new Color ( 0.13f , 0.13f , 0.13f , 1f ) ) ;
210
+ UIFactory . SetLayoutElement ( PasteButton . Component . gameObject , minHeight : 25 , minWidth : 28 , flexibleWidth : 0 ) ;
211
+ PasteButton . ButtonText . color = Color . green ;
212
+ PasteButton . ButtonText . fontSize = 10 ;
213
+ PasteButton . OnClick += OnPasteClicked ;
214
+
191
215
// Subcontent
192
216
193
217
SubContentHolder = UIFactory . CreateUIObject ( "SubContent" , UIRoot ) ;
0 commit comments