SuperScenes API

SceneComponent

This is the base abstract class that all scene components should derive from.

SceneComponent base class API

scene

public Scene scene;

The scene that the component is attached to. This is only valid at runtime, and only if the scene is currently loaded.

OnSceneLoaded

public virtual void OnSceneLoaded() { }

This method is invoked when the scene that the component is connected to has fully loaded by Unity's Scene Manager. As such, you can inspect the scene's GameObjects in this method.

OnSceneUnloaded

public virtual void OnSceneLoaded() { }

This method is invoked when the scene that the component is connected to has been unloaded by Unity's Scene Manager.

SceneExtensions

At runtime, the static class SceneExtensions provides some extension methods for the built-in Unity struct Scene. This means you can just use an existing Scene reference, and invoke on it one of the available methods listed below:

SceneExtensions extensions class API

GetComponent

public static T GetComponent<T>(this Scene scene) where T : SceneComponent

Returns the first component of type T attached to the given Scene struct, if any is present. If no component of that type is present, it returns null.

If you are not sure if a component is present, you can use TryGetComponent instead.

TryGetComponent<T>

public static bool TryGetComponent<T>(this Scene scene, out T component)
where T : SceneComponent

Returns a boolean value representing whether the requested component of type T is present or not on the given Scene struct.

The output parameter component will contain a reference to the component or, if not present, it will contain null.

GetComponents

public static List<SceneComponent> GetComponents(this Scene scene)

Returns a list of all scene components present on the provided Scene. Returns an empty List if the scene has no components.

SceneDataRegistry

The SceneDataRegistry ScriptableObject holds the index of all the SceneDataSO ScriptableObjects – which in turn hold the data for the components. You can use it to access components even before the related scene is loaded, but finding the component in the list is up to you.

SceneDataRegistry class API

Instance

public static SceneDataRegistry Instance

Holds a reference to the SceneDataRegistry ScriptableObject.

sceneData

public List<SceneDataSO> sceneData;

A list of all SceneDataSO objects.

GetSceneData (string)

public SceneDataSO GetSceneData(string scenePath)

Looks for a SceneDataSO where the path property matches the provided one. The path is intended to be project-related (i.e. starting from "Assets").

GetSceneData (Scene)

public SceneDataSO GetSceneData(Scene scene)

Looks for a SceneDataSO where the path property matches the path of the provided Scene struct.

SceneDataSO

SceneDataRegistrySO ScriptableObjects hold the data for the scene components. You can reference them to access components even before the related scene is loaded.

SceneDataSO class API

sceneAsset

public SceneAsset sceneAsset;

The connected SceneAsset. This is only available in the editor.

scenePath

public string scenePath;

The path of the targeted scene. Can be used at runtime to query for components even before the scene is loaded.

Note: at edit time, this is automatically provided by SuperScenes, no need to fill in manually.

components

[SerializeReference] public List<SceneComponent> components;

The list of scene components attached to the related scene.

GetComponent<T>

public T GetComponent<T>() where T : SceneComponent

Tries to find a component in the list of the provided type. Returns null if not present.

TryGetComponent<T>

public bool TryGetComponent<T>(out T component) where T : SceneComponent

Tries to find a component in the list of the provided type. The returned component will be null if not present.

Last updated