MultiSceneRef.cs

CarterGames.MultiScene.Runtime
CarterGames.Experimental.MultiScene

The main way to reference between scenes in the multi scene asset. This class gives you a load of methods to help with getting references between scenes. It is important to note that the scene with the element you are trying to reference has to be loaded to make a valid reference. It is advised to only reference in scenes loaded before the one the reference is being made in or to wait until all the scenes have loaded which can be listened for with the IMultiSceneAwake/Enable/Start Interfaces & the PostScenesLoaded event.

Methods

Method
string ā†’ The scenes name to get the objects from.

Return
GameObject[] ā†’ An array of all the root gameObjects in the scene requested.

Gets all the root games objects in a particular scene.

var objs = MultiSceneRef.GetRootObjects("MyScene");

Method
GameObject ā†’ The object to move.
string ā†’ The scenes name to move the object to.

Tries to move the object entered in the scene string entered.

GameObject obj;
var result = MultiSceneRef.MoveObjectToScene(obj, "MyScene");

Method
List<GameObject> ā†’ The objects to move.
string ā†’ The scenes name to move the object to.

Tries to move the object entered in the scene string entered.

List<GameObject> objs;
var result = MultiSceneRef.MoveObjectsToScene(objs, "MyScene");

Method
string ā†’ The name of the object to find.

Returns
GameObject ā†’ The object found.

Finds the first gameObject of the name entered in all the scenes currently loaded.

var obj = MultiSceneRef.FindObject("MyGameObject");

Method
string ā†’ The scenes name to find the object in.
string ā†’ The name of the object to find.

Returns
GameObject ā†’ The object found.

Finds the first gameObject of the name entered in the scene string entered.

var obj = MultiSceneRef.FindObject("MyScene", "MyGameObject");

Method
string ā†’ The name of the object to find.

Returns
List<GameObject> ā†’ Whether it was successful or not.

Finds all the gameObjects of the name entered in all the scenes currently loaded.

var objs = MultiSceneRef.FindObjects("MyGameObject");

Method

Returns
T ā†’ The type requested.

The first component of the type requested found in the active scene only.

var component = MultiSceneRef.GetComponentFromActiveScene<MyComponent>();

Method
string ā†’ The name of the scene to get from.

Returns
T ā†’ The type requested.

The first component of the type requested found in the scene name entered.

var component = MultiSceneRef.GetComponentFromScene<MyComponent>("MyScene");

Method
string ā†’ The name of the scene to get from.

Returns
T ā†’ The type requested.

The first component of the type requested found in the scene names entered.

var scenes = new List<string>(){ "MyScene", "AnotherScene" };
var conponent = MultiSceneRef.GetComponentFromScenes<MyComponent>(scenes);

Method

Returns
T ā†’ The type requested.

The first component of the type requested found in all currently loaded scenes.

var conponent = MultiSceneRef.GetComponentFromAllScenes<MyComponent>();

Method

Returns
List<T> ā†’ A list of the type requested.

The all components of the type requested found in the active scene only.

var conponents = MultiSceneRef.GetComponentsFromActiveScene<MyComponent>();

Method
string ā†’ The name of the scene to get from.

Returns
List<T> ā†’ A list of the type requested.


All the components of the type requested found in the scene name entered.

var conponents = MultiSceneRef.GetComponentsFromScene<MyComponent>("MyScene");

Method
List<string> ā†’ The name of the scenes to get from.

Returns
List<T> ā†’ A list of the type requested.


All the components of the type requested found in the scene name entered.

var scenes = new List<string>(){ "MyScene", "AnotherScene" };
var conponents = MultiSceneRef.GetComponentsFromScenes<MyComponent>(scenes);

Method

Returns
List<T> ā†’ A list of the type requested.


All the components of the type requested found in all currently loaded scenes.

var conponents = MultiSceneRef.GetComponentsFromAllScenes<MyComponent>();