This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//gets called on the local instance from the OnGameLoad, will only be called once obviously | |
void Configure() | |
{ | |
Debug.Log("Manager Configured, Called Once The Game Loads, Right Before The Scene Load"); | |
SceneManager.sceneLoaded += OnSceneChanged; | |
} | |
//listener to scene change event, calls the Init method | |
private void OnSceneChanged(Scene scene, LoadSceneMode loadMode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//gets called when the game loads using the argument gets it called before the startup scene is loaded | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] | |
static void OnGameLoad() | |
{ | |
if (Current) | |
Current.Configure(); | |
else | |
throw new NullReferenceException("No Asset Instance Found, Please Make Sure An Asset Instance Exists Within A Resources Folder"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CreateAssetMenu] | |
public class ManagerScriptableObject : ScriptableObject | |
{ | |
//variable will hold the instance value so we don't look for it everytime we need to access it | |
//access the Instance only via the Current Property | |
static ManagerScriptableObject _current; | |
public static ManagerScriptableObject Current | |
{ | |
get | |
{ |
NewerOlder