Cross-Scene System
Normally, Unity won't allow objects in scene (such as GameObject or Component) to be assigned in an asset's property. Unity won't even allow an object of a particular scene to be assigned in an object's property across a different scene.
The thing is, in Sequine Flow, some commands are required to be able access components in scene to perform, such as Sequine Player component, Sequine Text component, or a Transform component.
The cross-scene system is the magic behind how Sequine immune to this limitation, so that we can target an object of whichever scene.
In a Sequine Flow, there are 3 ways of how we can target an object of a scene.
- Direct Object
- Cross Scene Reference
- Cross Scene Binding (Legacy)
If you've been learning through Sequine Player and Sequine Text quick-starts, you've seen already how we can assign a scene object target.
1. Direct Object
As its name suggests, this is a way to target a scene object directly, just like when we assign a component reference to a property of another component in Inspector, nothing special.
However, this is a privilege to use only in a Sequine Flow Component. The limitation we talked about was only about assigning a scene's object in an asset or in another scene. Hence, there is no problem in assigning a scene's object in the same scene.
Sequine Flow Component itself is a component that is added to a gameobject, which obviously resides in a scene, therefore, it is aware of any other components, as long as it's from the same scene. With that said, the limitation still applies on components from a different scene, so, you should not assign a target from a different scene.
The other types of Sequine Flow, such as Sequine Flow Asset and Sequine Flow Clip, are asset types. They absolutely can't use Direct Object to target scene's objects. If you try to choose Direct Object, then an error message will be shown instead.
2. Cross-Scene Reference
This is a way to target an object of any scene. Compared to Direct Object, there is no difference on how we assign the target, we can just drag and drop it as usual.
What's happening behind the scene, is that the data we assigned is not directly the object reference itself, but a unique GUID that is generated by Sequine for that object. The GUID value information is shown below the object field.
The object field's color is green when the assigned target is valid, while it turns red when it's invalid. Invalid target is when an object of the specified GUID is not found, mainly because the object is deleted.
When the owning scene is not opened, the object field will show None
but still with green color. This is normal. As long as it's green, then it's a valid reference, and expected to run with no problem during runtime.
We can also assign the GUID directly by clicking the ...
button.
3. Cross-Scene Binding (Legacy)
This was the solution being used in version 1.3.2 and lower. This feature is kept in order to maintain compatibility for long-time users. If this is your first time of using Sequine, then it is recommended to use Cross-Scene Reference instead as it's more efficient and a lot less complex (even having almost no difference than using Direct Object). You may also skip to the next page.
The general idea of Cross-Scene Binding is based on these premises:
- We can't access scene's objects from an asset or from another scene.
- We can access assets from anywhere.
- We can assign an asset in a component.
Combine the premises, we can use an asset as an identity which we can use to refer to a certain component.
We do it by adding a Cross Scene Binder component to a GameObject which we want to target. We assign the binder asset first, which can be literally any type of asset. Then, we select the component of that GameObject which we want to bind.
The Cross Scene Binder component's initial state is required to be active, so if you want to deactivate the GameObject on Awake, tick the Deactivate GameObject on Awake toggle.
While we can use any type of asset as the binder asset, we also have a special type of asset called Cross Scene Binder Asset. It's essentially just an empty ScriptableObject
, which sole purpose is to act as a Binder asset.
But it's still worth noting that a binder asset doesn't necessarily have to be a Cross Scene Binder Asset.
To create a Cross Scene Binder Asset, open the Assets menu, and click Create -> Sequine -> Cross Scene Binder Asset.
We can then assign our previously created Cross Scene Binder Asset in Binder Asset field. To assign the Component to Bind, we can either drag and drop the component, or choose it using the dropdown.
You can assign any type of component inside Component to Bind field, so make sure you dragged the correct one, or simply use the Select Component dropdown.
Instead of manually creating a Cross Scene Binder Asset, you can also click New button under the Binder Asset field to generate it instantly.
In a command, instead of assigning the target object/component to the field, we assign its binder asset.
To assign the Target's Binder field, you can directly drag and drop the GameObject, and it will automatically assign from the specified Binder Asset of the Cross Scene Binder component.
Cross-Scene Binding (Legacy) doesn't scale well if you use a lot of cross-scene objects as your project will be cluttered with a lot of binder asset. This is also the reason why it's better to use Cross-Scene Reference instead.