Exemple #1
0
    public static void TestWeakReferencePauseLock()
    {
        AsyncUtils.RunWithExceptionHandling(async() =>
        {
            object lockObject = new object();
            WeakReference untypedWeakReference = new WeakReference(lockObject);
            LockPauseModule.PauseGame(PauseLockType.AllowMenu, untypedWeakReference);
            Debug.Log("Untyped lock added!");

            await Task.Delay(3000);
            AsyncUtils.ThrowIfEditorStopped();

            lockObject = null;
            CoreUtils.CollectGarbage(false);

            Debug.Log("Untyped lock released!");

            await Task.Yield();
            AsyncUtils.ThrowIfEditorStopped();

            LockPauseModule.ForceCleanLocks();

            Debug.Log("Locks cleaned!");

            await Task.Delay(5000);
            AsyncUtils.ThrowIfEditorStopped();

            IEnumerable typedLockObject = new string[] { "lol", "hi" };
            WeakReference <IEnumerable> typedWeakReference = new WeakReference <IEnumerable>(typedLockObject);

            LockPauseModule.PauseGame(PauseLockType.AllowMenu, typedWeakReference);
            Debug.Log("Typed lock added!");

            await Task.Delay(3000);
            AsyncUtils.ThrowIfEditorStopped();

            typedLockObject = null;
            CoreUtils.CollectGarbage(false);

            Debug.Log("Typed lock released!");

            await Task.Yield();
            AsyncUtils.ThrowIfEditorStopped();

            LockPauseModule.ForceCleanLocks();

            Debug.Log("Locks cleaned!");
        });
    }
Exemple #2
0
        static void PurgeDialogueSystems()
        {
            DialogueController.CurrentDialogue = null;
            DialogueController.CurrentCallback = null;

            var ds = GameObject.Find("DialogueSystem");

            if (ds != null)
            {
                LockPauseModule.UnpauseGame(ds);
                GameObject.Destroy(ds);
            }

            var dc = GameObject.Find("DialogueCamera");

            if (dc != null)
            {
                GameObject.Destroy(dc);
            }

            AudioPlayer.Instance.ClearMusic(MusicSlot.Cinematic);
            LockPauseModule.ForceCleanLocks(); //useless since objects aren't *yet* destroyed
        }