File tree Expand file tree Collapse file tree 4 files changed +42
-7
lines changed
VisualPinball.Unity/VisualPinball.Unity.Editor/AssetBrowser Expand file tree Collapse file tree 4 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -63,13 +63,19 @@ public class Asset : ScriptableObject
63
63
[ NonReorderable ] // see https://answers.unity.com/questions/1828499/nested-class-lists-inspector-overlapping-bug.html
64
64
public List < AssetMaterialVariation > MaterialVariations ;
65
65
66
+ [ SerializeField ]
67
+ public string ThumbBackgroundObjectName ;
68
+
66
69
[ SerializeReference ]
67
70
public Preset ThumbCameraPreset ;
68
71
69
72
[ SerializeField ]
70
73
public float ThumbCameraHeight ;
71
74
72
- [ SerializeReference ]
75
+ [ SerializeField ]
76
+ public bool ThumbTopLight ;
77
+
78
+ [ SerializeField ]
73
79
public bool UnpackPrefab ;
74
80
75
81
[ SerializeReference ]
Original file line number Diff line number Diff line change 22
22
using UnityEditor ;
23
23
using UnityEditor . UIElements ;
24
24
using UnityEngine ;
25
+ using UnityEngine . SceneManagement ;
25
26
using UnityEngine . UIElements ;
26
27
using Object = UnityEngine . Object ;
27
28
@@ -165,6 +166,28 @@ public void Bind(Asset asset)
165
166
description . text = asset . Description ;
166
167
SetVisibility ( description , asset . Library . IsLocked && ! string . IsNullOrEmpty ( asset . Description ) ) ;
167
168
169
+ BindBackgroundObjects ( ) ;
170
+ }
171
+
172
+ private void BindBackgroundObjects ( )
173
+ {
174
+ var bgo = _body . Q < ObjectDropdownElement > ( "background-object-field" ) ;
175
+ var bgParent = SceneManager . GetActiveScene ( ) . GetRootGameObjects ( )
176
+ . FirstOrDefault ( go => go . name == "_BackgroundObjects" ) ;
177
+
178
+ if ( bgParent == null ) {
179
+ bgo . visible = false ;
180
+ return ;
181
+ }
182
+ bgo . visible = true ;
183
+ bgo . Value = _asset . ThumbBackgroundObjectName != null ? bgParent . transform . Find ( _asset . ThumbBackgroundObjectName ) ? . gameObject : null ;
184
+ bgo . AddObjectsToDropdown < MeshRenderer > ( bgParent , true ) ;
185
+ bgo . RegisterValueChangedCallback ( OnThumbBackgroundObjectChanged ) ;
186
+ }
187
+
188
+ private void OnThumbBackgroundObjectChanged ( Object obj )
189
+ {
190
+ _asset . ThumbBackgroundObjectName = obj . name ;
168
191
}
169
192
170
193
private void BindInfo ( Asset asset )
Original file line number Diff line number Diff line change 31
31
<uie:PropertyField binding-path="Links" label="Links" class="top-space" />
32
32
33
33
<!-- Geometry -->
34
- <ui:Foldout text="Geometry ">
34
+ <ui:Foldout text="Thumbnail Settings ">
35
35
<ui:VisualElement class="left-indent">
36
- <uie:PropertyField binding-path="Scale" label="Scale Transform" />
37
- <uivpe:PresetDropdownElement name="thumb-camera-preset" binding-path="ThumbCameraPreset" label="Thumbnail Camera" preset-path="Packages/org.visualpinball.engine.unity/VisualPinball.Unity/Assets/Presets/Asset Thumbcam" />
38
- <uie:PropertyField binding-path="ThumbCameraHeight" label="Thumb Object Z-Pos" />
36
+ <uivpe:ObjectDropdownElement name="background-object-field" label="On Object" />
37
+ <uivpe:PresetDropdownElement name="thumb-camera-preset" binding-path="ThumbCameraPreset" label="Camera" preset-path="Packages/org.visualpinball.engine.unity/VisualPinball.Unity/Assets/Presets/Asset Thumbcam" />
38
+ <uie:PropertyField binding-path="ThumbCameraHeight" label="Z-Position" />
39
+ <uie:PropertyField binding-path="ThumbTopLight" label="Enable Top Light" />
39
40
</ui:VisualElement>
40
41
</ui:Foldout>
41
42
Original file line number Diff line number Diff line change @@ -87,13 +87,13 @@ public void RegisterValueChangedCallback(Action<Object> onValueChanged)
87
87
_onValueChanged = onValueChanged ;
88
88
}
89
89
90
- public void AddObjectsToDropdown < T > ( Object parentObj ) where T : Component
90
+ public void AddObjectsToDropdown < T > ( Object parentObj , bool includeInactive = false ) where T : Component
91
91
{
92
92
if ( parentObj is not GameObject parentGo ) {
93
93
return ;
94
94
}
95
95
_objects . Clear ( ) ;
96
- _objects . AddRange ( parentGo . GetComponentsInChildren < T > ( ) . Select ( c => c . gameObject ) ) ;
96
+ _objects . AddRange ( parentGo . GetComponentsInChildren < T > ( includeInactive ) . Select ( c => c . gameObject ) ) ;
97
97
_dropdown . choices = _objects . Select ( go => go . name ) . ToList ( ) ;
98
98
if ( _objectPicker . value ) {
99
99
_dropdown . SetValueWithoutNotify ( _objectPicker . value . name ) ;
@@ -102,6 +102,11 @@ public void AddObjectsToDropdown<T>(Object parentObj) where T : Component
102
102
103
103
public void SetValue ( Object obj )
104
104
{
105
+ if ( obj == null ) {
106
+ _dropdown . SetValueWithoutNotify ( null ) ;
107
+ _objectPicker . value = null ;
108
+ return ;
109
+ }
105
110
var selectedGo = _objects . FirstOrDefault ( go => go . name == obj . name ) ;
106
111
if ( selectedGo != null ) {
107
112
_dropdown . SetValueWithoutNotify ( obj . name ) ;
You can’t perform that action at this time.
0 commit comments