Adventure Creator  1.66.8
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2018
AC.SceneChanger Class Reference
Inheritance diagram for AC.SceneChanger:

Public Member Functions

void OnAwake ()
 
void AfterLoad ()
 
void SetRelativePosition (Transform markerTransform)
 Calculates the player's position relative to the next scene's PlayerStart. More...
 
Vector3 GetStartPosition (Vector3 playerStartPosition)
 Gets the player's starting position by adding the relative position (set in ActionScene) to the PlayerStart's position. More...
 
float GetLoadingProgress ()
 Gets the progress of an asynchronous scene load as a decimal. More...
 
bool IsLoading ()
 
void PreloadScene (SceneInfo nextSceneInfo)
 
void ChangeScene (SceneInfo nextSceneInfo, bool saveRoomData, bool forceReload=false, int _removeNPCID=0, bool _takeNPCPosition=false)
 Loads a new scene. This method should be used instead of Unity's own scene-switching method, because this allows for AC objects to be saved beforehand More...
 
void LoadPreviousScene ()
 Loads the previously-entered scene.
 
Player GetPlayerOnTransition ()
 Gets the Player prefab that was active during the last scene transition. More...
 
void DestroyOldPlayer ()
 
void SetTransitionTexture (Texture2D _texture)
 
Texture2D GetAndResetTransitionTexture ()
 Gets, and removes from memory, the texture used as an overlay during a scene transition. More...
 
void ScheduleForDeletion (GameObject _gameObject)
 Deletes a GameObject once the current frame has finished renderering. More...
 
void PrepareSceneForExit ()
 Saves the current scene objects, kills speech dialog etc. This should if the scene is changed using a custom script, i.e. without using the provided 'Scene: Switch' Action.
 
bool AddSubScene (SceneInfo sceneInfo)
 Adds a new scene as a sub-scene, without affecting any other open scenes. More...
 
IEnumerator AddSubSceneCoroutine (SceneInfo sceneInfo)
 
void RegisterSubScene (SubScene subScene)
 Registers a SubScene component with the SceneChanger. More...
 
SubScene [] GetSubScenes ()
 Gets an array of all open SubScenes. More...
 
bool RemoveScene (SceneInfo sceneInfo)
 Removes a scene, without affecting any other open scenes, provided multiple scenes are open. If the active scene is removed, the last-added sub-scene will become the new active scene. More...
 
PlayerData SavePlayerData (PlayerData playerData)
 Saves data used by this script in a PlayerData class. More...
 
void LoadPlayerData (PlayerData playerData, bool loadSubScenes=true)
 Loads data used by this script from a PlayerData class. More...
 
SceneInfo GetPreviousSceneInfo (bool forPlayer=true)
 Gets info about the previous scene.< More...
 
int GetSubSceneIndexOfGameObject (GameObject gameObject)
 Gets the index within the internal list of active sub-scenes that a GameObject is in. This is not the build index of the scene, but the order in which the scene is loaded internally More...
 

Detailed Description

Handles the changing of the scene, and keeps track of which scene was previously loaded. It should be placed on the PersistentEngine prefab.

Member Function Documentation

◆ AddSubScene()

bool AC.SceneChanger.AddSubScene ( SceneInfo  sceneInfo)

Adds a new scene as a sub-scene, without affecting any other open scenes.

SUB-SCENES

Parameters
sceneInfoThe SceneInfo of the new scene to open

◆ AfterLoad()

void AC.SceneChanger.AfterLoad ( )

Called after a scene change.

◆ ChangeScene()

void AC.SceneChanger.ChangeScene ( SceneInfo  nextSceneInfo,
bool  saveRoomData,
bool  forceReload = false,
int  _removeNPCID = 0,
bool  _takeNPCPosition = false 
)

Loads a new scene. This method should be used instead of Unity's own scene-switching method, because this allows for AC objects to be saved beforehand

Parameters
nextSceneInfoInfo about the scene to load
sceneNumberThe number of the scene to load, if sceneName = ""
saveRoomDataIf True, then the states of the current scene's Remember scripts will be recorded in LevelStorage
forceReloadIf True, the scene will be re-loaded if it is already open.
_removeNPCIDIf non-zero, then an NPC with a Constant ID of this number will be removed after the scene-change
_takeNPCPositionIf True, and _revemoNPCID is non-zero, then the Player will teleport to the NPC's position before the NPC is removed

◆ DestroyOldPlayer()

void AC.SceneChanger.DestroyOldPlayer ( )

Destroys the Player prefab that was active during the last scene transition.

◆ GetAndResetTransitionTexture()

Texture2D AC.SceneChanger.GetAndResetTransitionTexture ( )

Gets, and removes from memory, the texture used as an overlay during a scene transition.

Returns
The texture used as an overlay during a scene transition

◆ GetLoadingProgress()

float AC.SceneChanger.GetLoadingProgress ( )

Gets the progress of an asynchronous scene load as a decimal.

Returns
The progress of an asynchronous scene load as a decimal.

◆ GetPlayerOnTransition()

Player AC.SceneChanger.GetPlayerOnTransition ( )

Gets the Player prefab that was active during the last scene transition.

Returns
The Player prefab that was active during the last scene transition

◆ GetPreviousSceneInfo()

SceneInfo AC.SceneChanger.GetPreviousSceneInfo ( bool  forPlayer = true)

Gets info about the previous scene.<

Parameters
forPlayerIf True, then the previous scene will be assumed to be the player character's last-visited scene, as opposed to the last scene that was open
Returns
Info about the previous scene

◆ GetStartPosition()

Vector3 AC.SceneChanger.GetStartPosition ( Vector3  playerStartPosition)

Gets the player's starting position by adding the relative position (set in ActionScene) to the PlayerStart's position.

Parameters
playerStartPositionThe position of the PlayerStart object
Returns
The player's starting position

◆ GetSubSceneIndexOfGameObject()

int AC.SceneChanger.GetSubSceneIndexOfGameObject ( GameObject  gameObject)

Gets the index within the internal list of active sub-scenes that a GameObject is in. This is not the build index of the scene, but the order in which the scene is loaded internally

Parameters
gameObjectThe GameObject to get the sub-scene index for
Returns
The index within the internal list of active sub-scenes that a GameObject is in, starting from 1. If the gameObject is not found, or the sub-scene is not found, it will return 0

◆ GetSubScenes()

SubScene [] AC.SceneChanger.GetSubScenes ( )

Gets an array of all open SubScenes.

Returns
An array of all open SubScenes

◆ LoadPlayerData()

void AC.SceneChanger.LoadPlayerData ( PlayerData  playerData,
bool  loadSubScenes = true 
)

Loads data used by this script from a PlayerData class.

Parameters
playerDataThe PlayerData to load from.
loadSubScenesIf True, then sub-scenes will be loaded

◆ RegisterSubScene()

void AC.SceneChanger.RegisterSubScene ( SubScene  subScene)

Registers a SubScene component with the SceneChanger.

Parameters
subSceneThe SubScene component to register

◆ RemoveScene()

bool AC.SceneChanger.RemoveScene ( SceneInfo  sceneInfo)

Removes a scene, without affecting any other open scenes, provided multiple scenes are open. If the active scene is removed, the last-added sub-scene will become the new active scene.

Parameters
sceneInfoThe SceneInfo of the new scene to remove

◆ SavePlayerData()

PlayerData AC.SceneChanger.SavePlayerData ( PlayerData  playerData)

Saves data used by this script in a PlayerData class.

Parameters
playerDataThe PlayerData to save in.
Returns
The updated PlayerData

◆ ScheduleForDeletion()

void AC.SceneChanger.ScheduleForDeletion ( GameObject  _gameObject)

Deletes a GameObject once the current frame has finished renderering.

Parameters
_gameObjectThe GameObject to delete

◆ SetRelativePosition()

void AC.SceneChanger.SetRelativePosition ( Transform  markerTransform)

Calculates the player's position relative to the next scene's PlayerStart.

Parameters
markerTransformThe Transform of the GameObject that marks the position that the player should be placed relative to.