-
Notifications
You must be signed in to change notification settings - Fork 0
Quickstart
These plugins are required:
If you install UniSwitcher using UPM, they will be included automatically.
[NOTE]
If you have been using these plugins from the "Plugins" folder, you will run into issues
because they and the ones that UniSwitcher pulls via UPM clash with each other.
If this happens, you will need to remove the dependency from the "Plugins" folder.
If you have not used Zenject in this project, follow the next steps:
- In all the scenes, place
Scene Context
by [GameObject] > [Zenject] > [Scene Context].
You don't have to do anything on it - place it and leave it. -
Create
Project Context
inResources
folder.
After that, or if you already are using Zenject, start from here:
-
Attach
UniSwitcherInstaller
toProject Context
as a component.
The component comes pre-filled with the default implementations of UniSwitcher components. - Drag that component in the
Mono Installers
list in theProject Context
component. - Copy the following into a new file. This is where you write your Scene definitions!
using UniSwitcher.Domain; public class Scene: BaseScene { /////////////////////////////////////// // WRITE YOUR SCENE DEFINITION HERE! // /////////////////////////////////////// private Scene(string rawValue) : base(rawValue) { } }
- In the file above, you will want to add the Scenes that are in your game like this; it should be a static property:
public static Scene FirstScene => new Scene("Assets/Scenes/SampleScene.unity");
To access the scene-changing ability of UniSwitcher, you need to use Switcher.
This class is an abstract class extending MonoBehaviour,
so you can attach the script
as a component on your GameObject.
public class SceneController: Switcher
{
// This is a MonoBehaviour - you can use Unity event methods such as Start and Update
}
In this class, PerformSceneTransition,
ChangeScene,
and several other methods are provided.
To change the scene, call this:
PerformSceneTransition(
ChangeScene(Scene.FirstScene)
);