/// <summary> /// Create the core behaviour instance, this must be called for the management system to function. /// </summary> public static void CreateCoreBehaviour() { if (instance == null) // Create if not existent { instance = new CoreBehaviour(); } }
public override void OnManagerRegistered(CoreBehaviour coreBehaviour) { // Registration for virtual managers are initiated from the Initialize() // method. Debug.Log("Virtual score manager initialized"); }
public override void OnManagerRegistered(CoreBehaviour coreBehaviour) { // This is called when the manager has been added to the system. The // MonoManager automatically adds the manager in the Awake method so // this can basically be used as Awake, however if the manager fails // to be registered, this won't be called, so to also catch failure // cases it's best to use PostAwake() for definite Awake behaviour. Debug.Log("Example manager was added to the management system."); }
private static void OnBeforeSceneLoaded() { if (CoreBehaviour.IsCompileTimeEnabled()) // Ensure the core behaviour is enabled { CoreBehaviour.CreateCoreBehaviour(); } else // Core behaviour is not enabled { Debug.LogWarning("Lightweight management system is currently disabled, add 'LWMS' to Scripting Define Symbols in the player settings to enable it."); } }
/// <summary> /// Check the status to see whether the lightweight management system is enabled or not. /// </summary> /// <returns></returns> private bool CheckStatus() { if (CoreBehaviour.IsCompileTimeEnabled()) // Ensure the system is enabled { return(true); } else // System is disabled { Debug.LogError("Lightweight management system is disabled!"); return(false); } }
protected void OnDestroy() { if (CheckStatus()) // Check if the system is enabled { if (!CoreBehaviour.RemoveManager(this)) // Catch failrue to remove manager { Debug.LogError("Unable to remove manager " + GetType()); } } // Continue calls to derived object PostDestroy(); }
protected void Awake() { if (CheckStatus()) // Check if the system is enabled { if (!CoreBehaviour.AddManager(this)) // Catch failure to add manager { Debug.LogError("Unable to add manager " + GetType()); } } // Continue calls to derived object PostAwake(); }
public static void TestExampleManager() { // Create the new manager ExampleVirtualManager manager = new ExampleVirtualManager(); // Initialize the manager, it will be registered automatically into the management system. manager.Initialize(); // Get the manager through the core behaviour to demonstrate that it can be acquired from anywhere. ExampleVirtualManager managerReference = CoreBehaviour.GetFirstManager <ExampleVirtualManager>(); // Deinitialize the manager and remove it from the management system. managerReference.Deinitialize(); }
/// <summary> /// Deinitialize the manager. /// </summary> /// <returns> Whether the manager was deinitialized successfully. </returns> public bool Deinitialize() { if (CheckStatus()) // Check if the system is enabled { if (CoreBehaviour.RemoveManager(this)) // Ensure the manager was removed { return(true); } else // Catch failrue to remove manager { Debug.LogError("Unable to remove manager " + GetType()); } } return(false); }
public virtual void OnManagerRegistered(CoreBehaviour coreBehaviour) { }
public void Deinitialize() { CoreBehaviour.RemoveCoreListener(this); }
public void Initialize() { CoreBehaviour.AddCoreListener(this); }