@@ -64,7 +64,7 @@ public abstract class UiConfigsEditor<TSet> : Editor
6464 "UI Sets group multiple presenter instances that should be displayed together. " +
6565 "When a set is activated via UiService, all its presenters are loaded and shown simultaneously. " +
6666 "Presenters are loaded in the order listed (top to bottom).\n \n " +
67- "You can add the same UI type multiple times with different instance addresses for multi-instance support ." ;
67+ "Each UI's instance address is automatically set to its Addressable address from the config ." ;
6868
6969 private Dictionary < string , string > _assetPathLookup ;
7070 private List < string > _uiConfigsAddress ;
@@ -258,14 +258,6 @@ private VisualElement CreateSetPresenterElement()
258258 dropdown . name = "ui-type-dropdown" ;
259259 container . Add ( dropdown ) ;
260260
261- // Instance address field (optional)
262- var instanceField = new TextField ( ) ;
263- instanceField . style . width = 120 ;
264- instanceField . style . marginLeft = 5 ;
265- instanceField . tooltip = "Optional instance address (leave empty for default instance)" ;
266- instanceField . name = "instance-address-field" ;
267- container . Add ( instanceField ) ;
268-
269261 // Delete button
270262 var deleteButton = new Button { text = "×" } ;
271263 deleteButton . style . width = 25 ;
@@ -335,8 +327,7 @@ private void BindSetPresenterElement(VisualElement element, int index, Serialize
335327 return ;
336328
337329 var dropdown = element . Q < DropdownField > ( "ui-type-dropdown" ) ;
338- var instanceField = element . Q < TextField > ( "instance-address-field" ) ;
339- if ( dropdown == null || instanceField == null )
330+ if ( dropdown == null )
340331 return ;
341332
342333 var entryProperty = uiEntriesProperty . GetArrayElementAtIndex ( index ) ;
@@ -371,14 +362,12 @@ private void BindSetPresenterElement(VisualElement element, int index, Serialize
371362 {
372363 // Unbind to prevent stale property references
373364 dropdown . Unbind ( ) ;
374- instanceField . Unbind ( ) ;
375365
376366 // Set the current values
377367 dropdown . index = selectedIndex ;
378- instanceField . value = instanceAddressProperty . stringValue ?? string . Empty ;
379368
380- // Register callback to store type when changed
381- dropdown . RegisterValueChangedCallback ( evt =>
369+ // Register callback to store type and addressable address when changed
370+ dropdown . RegisterValueChangedCallback ( _ =>
382371 {
383372 var newIndex = dropdown . index ;
384373 if ( newIndex >= 0 && newIndex < _uiConfigsAddress . Count )
@@ -387,25 +376,21 @@ private void BindSetPresenterElement(VisualElement element, int index, Serialize
387376 if ( _uiTypesByAddress . TryGetValue ( selectedAddress , out var selectedType ) )
388377 {
389378 typeNameProperty . stringValue = selectedType . AssemblyQualifiedName ;
379+ // Use the addressable address as the instance address
380+ instanceAddressProperty . stringValue = selectedAddress ;
390381 SaveSetChanges ( ) ;
391382 }
392383 }
393384 } ) ;
394385
395- // Register callback for instance address field
396- instanceField . RegisterValueChangedCallback ( evt =>
397- {
398- instanceAddressProperty . stringValue = evt . newValue ?? string . Empty ;
399- SaveSetChanges ( ) ;
400- } ) ;
401-
402386 // Set initial value if property is empty
403387 if ( string . IsNullOrEmpty ( typeNameProperty . stringValue ) && selectedIndex < _uiConfigsAddress . Count )
404388 {
405389 var address = _uiConfigsAddress [ selectedIndex ] ;
406390 if ( _uiTypesByAddress . TryGetValue ( address , out var type ) )
407391 {
408392 typeNameProperty . stringValue = type . AssemblyQualifiedName ;
393+ instanceAddressProperty . stringValue = address ;
409394 serializedObject . ApplyModifiedProperties ( ) ;
410395 }
411396 }
@@ -429,8 +414,8 @@ private void BindSetPresenterElement(VisualElement element, int index, Serialize
429414
430415 deleteButton . userData = clickHandler ;
431416 deleteButton . RegisterCallback ( clickHandler ) ;
432- }
433417 }
418+ }
434419
435420 private void OnPresenterItemsAdded ( IEnumerable < int > indices , SerializedProperty uiEntriesProperty )
436421 {
@@ -451,7 +436,8 @@ private void OnPresenterItemsAdded(IEnumerable<int> indices, SerializedProperty
451436 var instanceAddressProperty = entryProperty . FindPropertyRelative ( nameof ( UiSetEntry . InstanceAddress ) ) ;
452437
453438 typeNameProperty . stringValue = defaultType ? . AssemblyQualifiedName ?? string . Empty ;
454- instanceAddressProperty . stringValue = string . Empty ;
439+ // Use the addressable address as the instance address
440+ instanceAddressProperty . stringValue = defaultAddress ;
455441 }
456442 }
457443
0 commit comments