SuperScenes API

SceneComponent base class

Base abstract class that all scene components should derive from.

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 extensions class

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:

GetComponent

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

Returns the first component of type T attached to the given Scene, if any is present. If no component of that type is present, it returns the type's default value.

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

TryGetComponent

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.

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.

Last updated