5. Cross-Scene References

  Uncategorized No Comments

Initializers (and Any<TValue> fields) support cross-scene references.

To create a cross-scene reference, open two scenes in the Editor, and drag-and-drop an component from one into an Initializer in another one.

This will make Init(args) automatically create a globally unique identifier (Guid) for the dragged Object, and assign a value provider into the Initializer argument field, which will be used to automatically resolve the cross-scene reference at runtime during initialization.

The cross-scene reference will persist even if the scene containing the dragged Object is unloaded in the Editor. You can click the Object field to ping the scene asset that contains the referenced Object.

During runtime you will have to make sure to load the scene containing the referenced Object before you load the scene containing the referencer.

Leave a Reply

Your email address will not be published. Required fields are marked *