Skip to content

Reverse Usage Lookup

Collapsed Plug edited this page Nov 27, 2021 · 15 revisions

First of all, follow the quickstart; The quickstart gets you ready to use UniSwitcher.
If you are having trouble, check if you have followed everything on that instructions.

This page assumes you have done that, and your IScene implementation is called Scene in your project.

Change the scene to another

Call PerformSceneTransition on ChangeScene:

 PerformSceneTransition(ChangeScene(new Scene("path/to/your/scene.unity")));

Additively load a scene

Call PerformSceneTransition on AddScene:

PerformSceneTransition(AddScene(new Scene("path/to/your/scene.unity")));

Pass value to the destination scene

Put your data in the second argument - it will be available as an [Inject] variable for the scripts in the next scene.

PerformSceneTransition(AddScene(new Scene("path/to/your/scene.unity"), new YourRandomData(12345)));

// In the scripts on the next scene, if you write this, your data will appear in the property `_data`.
[Inject] private YourRandomData _data;

Transition to the next scene with a transition effect

For this to work, you must have a transition effect installed.
If you use the default UniSwitcherInstaller, you will automatically use the sample implementation of the UniSwitcher transition effect Assets/Plugins/UniSwitcher/Sample/Prefab/Transition Background.prefab.

You can even implement your own!!

After that, call WithTransitionEffect() on ChangeScene.

PerformSceneTransition(
    AddScene(new Scene("path/to/your/scene.unity"))
        .WithTransitionEffect()
);

Show Progress Bar

For this to work, you must implement a progress bar using ProgressDisplayController,
which must be referenced from the Switcher's sceneProgressBarController.

As long as it is referenced from the Switcher, the progress bar will automatically appear for all the transitions.

My progress bar is showing even on Additive scene load, and I don't want it

Call HideProgressBar().

PerformSceneTransition(
    AddScene(new Scene("path/to/your/scene.unity"))
        .HideProgressBar()
);

I want to delay the transition after triggering it

Use After on ChangeScene.

PerformSceneTransition(
    AddScene(new Scene("path/to/your/scene.unity"))
        .After(5) // after 5 seconds
);

[NOTE]
The interval you specify is the one between the time of triggering PerformSceneTransition and the start of your transition effect, not the actual scene switch.

More reverse usage lookup is TODO

Clone this wiki locally