public void CalledWhenAllSceneAreLoaded()
 {
     _refFuncToCallOnComplete?.Invoke(_lastSceneAssetUsed);
     _refFuncToCallOnComplete = null;
     _lastSceneAssetUsed      = null;
     _isActivatingScene       = false;
 }
        public void LoadSceneFromLister(SceneContextAsset lister, FuncToCallOnComplete funcToCallOnComplete)
        {
            _isActivatingScene       = true;
            _lastSceneAssetUsed      = lister;
            _refFuncToCallOnComplete = funcToCallOnComplete;

            if (Application.isPlaying)
            {
                _asyncOperations.Clear();
                for (int i = 0; i < _lastSceneAssetUsed.SceneToLoad.Count; i++)
                {
                    if (i == 0)
                    {
                        SceneManager.LoadScene(_lastSceneAssetUsed.SceneToLoad[0].ScenePath, LoadSceneMode.Single);
                        if (_lastSceneAssetUsed.SceneToLoad.Count == 1)
                        {
                            CalledWhenAllSceneAreLoaded();
                            return;
                        }
                        else
                        {
                            ExtCoroutineWithoutMonoBehaviour.StartUniqueCoroutine(WaitForLoading());
                        }
                    }
                    else
                    {
                        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(_lastSceneAssetUsed.SceneToLoad[i].ScenePath, LoadSceneMode.Additive);
                        asyncOperation.allowSceneActivation = false;
                        asyncOperation.completed           += OnSecondarySceneCompleted;
                        _asyncOperations.Add(asyncOperation);
                    }
                }
            }
#if UNITY_EDITOR
            else
            {
                EditorUtility.DisplayProgressBar("Loading scene", "", 0f);
                for (int i = 0; i < _lastSceneAssetUsed.SceneToLoad.Count; i++)
                {
                    if (_lastSceneAssetUsed.SceneToLoad[i].ScenePath.IsNullOrEmpty())
                    {
                        continue;
                    }
                    EditorSceneManager.OpenScene(_lastSceneAssetUsed.SceneToLoad[i].ScenePath,
                                                 (i == 0) ? OpenSceneMode.Single : OpenSceneMode.Additive);
                    EditorUtility.DisplayProgressBar("Loading scene", "", i * 1 / _lastSceneAssetUsed.SceneToLoad.Count);
                }
                EditorUtility.ClearProgressBar();
                CalledWhenAllSceneAreLoaded();
            }
#endif
        }
 public void AddContext(SceneContextAsset scene)
 {
     _contextList.AddIfNotContain(scene);
 }