Repository navigation
|
When adding an element to an array or list in the Inspector, editing a managed-reference field in the new element can also affect an existing element. Why does this happen, and how can I create an independent copy? |
Replies: 1 comment
|
The fields may reference the same instance. When Unity duplicates a collection element, the copy can retain references to the same managed objects within the component or asset. This can also happen when the managed reference is nested inside an ordinary serializable collection element. To create an independent instance, clear the newly added managed-reference field and select its type again, or use Copy followed by Paste Type and Values on that field. If new entries must always start empty, initialize their managed-reference fields in your custom Inspector's collection-add handler. |
The fields may reference the same instance. When Unity duplicates a collection element, the copy can retain references to the same managed objects within the component or asset. This can also happen when the managed reference is nested inside an ordinary serializable collection element.
To create an independent instance, clear the newly added managed-reference field and select its type again, or use Copy followed by Paste Type and Values on that field.
If new entries must always start empty, initialize their managed-reference fields in your custom Inspector's collection-add handler.
SubclassSelectordraws the individual fields and preserves shared references, which can be intentional in a…