Skip to content

Gaskellgames/Unity_CrossSceneEvents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note: This repo contains code enabling cross scene references. You can find the original repo here: Link

Unity - Cross Scene Events

Two Unity components enabling inspector events to be called across scenes. Simply add a caller component in the fist scene, and a repeater component in another scene and reference the caller in the repeater. Now whenever the caller is invoked, the repeater will also be invoked (as oong as both scenes are open).

CrossSceneEventCaller Component:

CrossSceneEventCaller

CrossSceneEventRepeater Component:

CrossSceneEventRepeater

Example Scene

Within the samples folder there are two example scenes.

The first scene (called LoadFirst) contains a plane and a single cube that can be rotated. This scene also contains a canvas with buttons for

  • Start Spinning: Invokes the CrossSceneEventCaller script, with a UnityEvent that calls the SimpleRotator in scene 1 to start rotation.
  • Stop Spinning: Invokes the CrossSceneEventCaller script, with a UnityEvent that calls the SimpleRotator in scene 1 to stop rotation.
  • Load Scene: Calls the LoadScene method from within the SimpleSceneLoader script.
  • Unload Scene: Calls the UnloadScene method from within the SimpleSceneLoader script.

The second scene (called LoadSecond) contains a single cube that can be rotated, alongside two CrossSceneEventRepeaters:

  • Start Spinning: Links to a CrossSceneEventCaller script in scene 1, with a UnityEvent that calls the SimpleRotator in scene 2 to start rotation.
  • Stop Spinning: Links to a CrossSceneEventCaller script in scene 1, with a UnityEvent that calls the SimpleRotator in scene 2 to stop rotation.

Game view with scene 1 open by itself:

GameView1

Game view with scene 1 and scene 2 open:

GameView2

Licence

This repo has a two licences, depending on the containing folder:

  • Anything within the folder "CrossSceneReference" uses the Unity Companion License.
  • Everything else uses the standard MIT License.

About

Unity components enabling inspector events to be called across scenes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages