37 lines
991 B
C#
37 lines
991 B
C#
using GatherAndDefend.Events;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class GoToScene : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private bool _useLoadingScreen = true;
|
|
[SerializeField][Scene]
|
|
private string _loadingScreenScene;
|
|
[SerializeField][Scene]
|
|
private string _sceneToLoad;
|
|
[SerializeField]
|
|
[Tooltip("Keep loaded scene")]
|
|
private int _levelToLoad = -1;
|
|
public void Execute()
|
|
{
|
|
if (_useLoadingScreen)
|
|
{
|
|
PlayerPrefs.SetString(LoadingManager.SceneToLoad, _sceneToLoad);
|
|
|
|
if(_levelToLoad != -1)
|
|
PlayerPrefs.SetInt(LoadingManager.LevelToLoad, _levelToLoad);
|
|
|
|
SceneManager.LoadScene(_loadingScreenScene, LoadSceneMode.Additive);
|
|
}
|
|
else
|
|
{
|
|
SceneManager.LoadScene(_sceneToLoad);
|
|
}
|
|
|
|
EventAggregator.Instance.GetEvent<ExitingLevelEvent>().Invoke();
|
|
}
|
|
}
|