77using UnityExplorer . CacheObject . IValues ;
88using UnityExplorer . Inspectors ;
99using UnityExplorer . UI ;
10+ using UnityExplorer . UI . Panels ;
1011using UnityExplorer . UI . Widgets ;
1112using UniverseLib ;
1213using UniverseLib . UI ;
@@ -47,9 +48,10 @@ public void Enable()
4748 public LayoutElement NameLayout ;
4849 public GameObject RightGroupContent ;
4950 public LayoutElement RightGroupLayout ;
51+ public GameObject SubContentHolder ;
5052
5153 public Text NameLabel ;
52- public InputFieldRef HiddenNameLabel ;
54+ public InputFieldRef HiddenNameLabel ; // for selecting the name label
5355 public Text TypeLabel ;
5456 public Text ValueLabel ;
5557 public Toggle Toggle ;
@@ -60,7 +62,11 @@ public void Enable()
6062 public ButtonRef SubContentButton ;
6163 public ButtonRef ApplyButton ;
6264
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 ) ;
6470
6571 protected virtual void ApplyClicked ( )
6672 {
@@ -82,26 +88,26 @@ protected virtual void SubContentClicked()
8288 this . Occupant . OnCellSubContentToggle ( ) ;
8389 }
8490
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+ }
87101
88102 public void RefreshSubcontentButton ( )
89103 {
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 ) ;
100107 }
101108
102109 protected abstract void ConstructEvaluateHolder ( GameObject parent ) ;
103110
104-
105111 public virtual GameObject CreateContent ( GameObject parent )
106112 {
107113 // Main layout
@@ -158,7 +164,7 @@ public virtual GameObject CreateContent(GameObject parent)
158164
159165 TypeLabel = UIFactory . CreateLabel ( rightHoriGroup , "ReturnLabel" , "<notset>" , TextAnchor . MiddleLeft ) ;
160166 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 ) ;
162168
163169 // Bool and number value interaction
164170
@@ -188,6 +194,24 @@ public virtual GameObject CreateContent(GameObject parent)
188194 ValueLabel . horizontalOverflow = HorizontalWrapMode . Wrap ;
189195 UIFactory . SetLayoutElement ( ValueLabel . gameObject , minHeight : 25 , flexibleHeight : 150 , flexibleWidth : 9999 ) ;
190196
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+
191215 // Subcontent
192216
193217 SubContentHolder = UIFactory . CreateUIObject ( "SubContent" , UIRoot ) ;
0 commit comments