Ejemplo n.º 1
0
        public CoroutineService()
        {
            var gameObject = new GameObject(typeof(CoroutineServiceMonoBehaviour).Name);

            _serviceObject = gameObject.AddComponent <CoroutineServiceMonoBehaviour>();

            Object.DontDestroyOnLoad(gameObject);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cleans the coroutine service and deletes the coroutine game object that contains all the coroutines in the game.
        /// This will also stop all currently running coroutines.
        /// </summary>
        public void Dispose()
        {
            if (_serviceObject == null)
            {
                return;
            }

            _serviceObject.StopAllCoroutines();

            Object.Destroy(_serviceObject.gameObject);

            _serviceObject = null;
        }