Пример #1
0
        /// <summary>
        /// Saves data asynchronously, at runtime
        /// </summary>
        /// <param name="save"></param>
        public void SaveAsync(SaveType save, Action onFinished)
        {
            if (!Application.isPlaying)
            {
                this.LogError("Cannot save asynchronously outside of playmode...");
                return;
            }

            IEnumerator routine()
            {
                if (debug)
                {
                    this.Log($"Asynchronous save on {save} started");
                }
                onSaveAsyncStarted?.Invoke(save);
                yield return(new WaitForEndOfFrame());

                Save(save);
                onFinished?.Invoke();
                onSaveAsyncEnded?.Invoke(save);
                if (debug)
                {
                    this.Log($"Asynchronous save on {save} ended");
                }
            }

            StratusCoroutineRunner.Run(routine());
        }
Пример #2
0
        /// <summary>
        /// Destroys the GameObject this component belongs to on the next frame
        /// </summary>
        public void DestroyGameObjectOnNextFrame()
        {
            IEnumerator routine()
            {
                yield return(new WaitForEndOfFrame());

                Destroy(this.gameObject);
            }

            StratusCoroutineRunner.Run(routine());
        }