File tree Expand file tree Collapse file tree 4 files changed +26
-21
lines changed
Expand file tree Collapse file tree 4 files changed +26
-21
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,12 @@ namespace GameLoversEditor.UiService
99 /// </summary>
1010 public enum DefaultUiSetId
1111 {
12- None = 0 ,
12+ InitialLoading = 0 ,
1313 MainMenu = 1 ,
1414 Gameplay = 2 ,
1515 Settings = 3 ,
16- Overlay = 4 ,
17- Popup = 5
16+ Overlays = 4 ,
17+ Popups = 5
1818 }
1919
2020 /// <summary>
Original file line number Diff line number Diff line change @@ -81,11 +81,14 @@ private void OnEnable()
8181
8282 SyncConfigsWithAddressables ( ) ;
8383
84- _configsProperty = serializedObject . FindProperty ( "_configs" ) ;
85- _setsProperty = serializedObject . FindProperty ( "_sets" ) ;
86-
8784 // Ensure sets array matches enum size
8885 _scriptableObject . SetSetsSize ( Enum . GetNames ( typeof ( TSet ) ) . Length ) ;
86+
87+ // Update the serializedObject to reflect the changes
88+ serializedObject . Update ( ) ;
89+
90+ _configsProperty = serializedObject . FindProperty ( "_configs" ) ;
91+ _setsProperty = serializedObject . FindProperty ( "_sets" ) ;
8992 }
9093
9194 /// <inheritdoc />
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . Linq ;
34using UnityEngine ;
45
56// ReSharper disable CheckNamespace
@@ -51,6 +52,8 @@ public List<UiConfig> Configs
5152 /// <param name="size">The new size of the list</param>
5253 public void SetSetsSize ( int size )
5354 {
55+ var validAddresses = new HashSet < string > ( _configs . Select ( c => c . AddressableAddress ) ) ;
56+
5457 if ( size < _sets . Count )
5558 {
5659 _sets . RemoveRange ( size , _sets . Count - size ) ;
@@ -60,18 +63,8 @@ public void SetSetsSize(int size)
6063 {
6164 if ( i < _sets . Count )
6265 {
63- var cleanedConfigList = new List < string > ( _sets [ i ] . UiConfigsAddress . Count ) ;
64-
65- foreach ( var address in _sets [ i ] . UiConfigsAddress )
66- {
67- if ( _configs . FindIndex ( config => config . AddressableAddress == address ) > - 1 )
68- {
69- cleanedConfigList . Add ( address ) ;
70- }
71- }
72-
7366 var set = _sets [ i ] ;
74- set . UiConfigsAddress = cleanedConfigList ;
67+ set . UiConfigsAddress . RemoveAll ( address => ! validAddresses . Contains ( address ) ) ;
7568 _sets [ i ] = set ;
7669 continue ;
7770 }
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ namespace GameLovers.UiService
1313 public struct UiSetConfig
1414 {
1515 public int SetId ;
16- public IReadOnlyList < Type > UiConfigsType ;
16+ public Type [ ] UiConfigsType ;
1717 }
1818
1919 /// <summary>
@@ -27,19 +27,28 @@ public struct UiSetConfigSerializable
2727
2828 public static UiSetConfig ToUiSetConfig ( UiSetConfigSerializable serializable , List < UiConfigs . UiConfigSerializable > configs )
2929 {
30- var types = new List < Type > ( ) ;
30+ var types = new Type [ serializable . UiConfigsAddress . Count ] ;
31+ var index = 0 ;
32+
3133 foreach ( var address in serializable . UiConfigsAddress )
3234 {
3335 var config = configs . Find ( c => c . AddressableAddress == address ) ;
3436 if ( ! string . IsNullOrEmpty ( config . UiType ) )
3537 {
36- types . Add ( Type . GetType ( config . UiType ) ) ;
38+ types [ index ++ ] = Type . GetType ( config . UiType ) ;
3739 }
3840 }
41+
42+ // Trim array if some addresses weren't found
43+ if ( index < types . Length )
44+ {
45+ Array . Resize ( ref types , index ) ;
46+ }
47+
3948 return new UiSetConfig
4049 {
4150 SetId = serializable . SetId ,
42- UiConfigsType = types . AsReadOnly ( )
51+ UiConfigsType = types
4352 } ;
4453 }
4554
You can’t perform that action at this time.
0 commit comments