DiscoverTenerife
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ChangeScene Class Reference

This class follows the singleton pattern, the unique instance of the class can be found on an object with the tag "sceneManager". It has to be instanciate because the coroutines cant be used in static methods, so if you need to use the changeSceneWithAnimation method you have to have an instance of the class. It also has the public static method changeScene that allow change the active scene to other but without any transition. More...

Inheritance diagram for ChangeScene:

Public Member Functions

void changeSceneWithAnimation (string sceneName, float transitionTime=1f, string text="Loading...")
 this method starts a coroutine that execute the makeFadeInFadeOutAnimation method. More...
 

Static Public Member Functions

static void changeScene (string sceneName)
 This method tries to load the scene that have the given name, if there isnt any scene with the given name it will produce an exception. More...
 

Private Member Functions

void Awake ()
 This method is called just before the first frame. It search for other sceneManager objects and if there is other one, it will destroy this instance. It also hide the text that will be showed during the fade in animation. More...
 
IEnumerator makeFadeInFadeOutAnimation (string sceneName, float transitionTime, string text="Loading...")
 this coroutine shows the given text, makes a fade in animation, change the scene, and then it does a fade out animation to hide both the text and the black image. All the process takes the given number of seconds. More...
 

Private Attributes

Animator transition_
 
GameObject text_
 

Detailed Description

This class follows the singleton pattern, the unique instance of the class can be found on an object with the tag "sceneManager". It has to be instanciate because the coroutines cant be used in static methods, so if you need to use the changeSceneWithAnimation method you have to have an instance of the class. It also has the public static method changeScene that allow change the active scene to other but without any transition.

Member Function Documentation

◆ Awake()

void ChangeScene.Awake ( )
private

This method is called just before the first frame. It search for other sceneManager objects and if there is other one, it will destroy this instance. It also hide the text that will be showed during the fade in animation.

◆ changeScene()

static void ChangeScene.changeScene ( string  sceneName)
static

This method tries to load the scene that have the given name, if there isnt any scene with the given name it will produce an exception.

Parameters
stringthat contains the name of the scene that it will change.

◆ changeSceneWithAnimation()

void ChangeScene.changeSceneWithAnimation ( string  sceneName,
float  transitionTime = 1f,
string  text = "Loading..." 
)

this method starts a coroutine that execute the makeFadeInFadeOutAnimation method.

Parameters
stringthe name of the scene to change
floatthe duration time of the transition in seconds
stringthe text that will be showed during the transition

◆ makeFadeInFadeOutAnimation()

IEnumerator ChangeScene.makeFadeInFadeOutAnimation ( string  sceneName,
float  transitionTime,
string  text = "Loading..." 
)
private

this coroutine shows the given text, makes a fade in animation, change the scene, and then it does a fade out animation to hide both the text and the black image. All the process takes the given number of seconds.

Parameters
stringthe name of the scene to change
floatthe duration time of the transition in seconds
stringthe text that will be showed during the transition

Member Data Documentation

◆ text_

GameObject ChangeScene.text_
private

this SerializeField GameObject contains a GameObject with the text that will be showed during the fade in animation.

◆ transition_

Animator ChangeScene.transition_
private

this SerializeField Animator contains a reference to an Animator object that has the fade in and fade out animations


The documentation for this class was generated from the following file: