Example #1
0
 private static void ClearCache()
 {
     if (Caching.ClearCache())
     {
         JSLDebug.Log("Cleaned all caches successfully.");
     }
     else
     {
         JSLDebug.LogWarning("Failed to clean caches.");
     }
 }
Example #2
0
        private IEnumerator StartUnloadSceneAsync(string sceneName, Action <object> callback, object customData)
        {
            int startFrameCount = Time.frameCount;

            if (SceneManager.GetActiveScene().name == sceneName)
            {
                JSLDebug.LogWarning(LOG_UNLOAD_ACTIVE_SCENE);

                callback?.Invoke(customData);

                yield break;
            }

            m_shouldUnload = false;
            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                if (SceneManager.GetSceneAt(i).name == sceneName)
                {
                    m_shouldUnload = true;
                }
            }

            if (!m_shouldUnload)
            {
                JSLDebug.LogWarning(LOG_NO_SCENE_TO_UNLOAD);

                callback?.Invoke(customData);

                yield break;
            }

            m_cacheAsyncOperation = SceneManager.UnloadSceneAsync(sceneName);
            if (m_cacheAsyncOperation == null)
            {
                callback?.Invoke(customData);

                yield break;
            }

            while (!m_cacheAsyncOperation.isDone)
            {
                yield return(0);
            }

            JSLDebug.LogFormat(LOG_UNLOAD_SCENE_SUCCEED, sceneName, startFrameCount, Time.frameCount);

            callback?.Invoke(customData);
        }