using UnityEngine ;
using UnityEngine.SceneManagement ;
public class LevelManagerPi : MonoBehaviour
{
void Start ()
{
SceneManager . LoadScene ( " a " , LoadSceneMode . Additive ) ;
}
void Update ()
{
if ( Input . GetButtonDown ( " Fire2 " ))
{
SceneManager . UnloadSceneAsync ( " a " ) ;
}
}
}
using System ;
using UnityEngine ;
using UnityEngine.SceneManagement ;
public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }
public static Action OnSceneLoad ;
private void Awake ()
{
if ( Instance != null && Instance != this )
{
Destroy ( this ) ;
}
else
{
Instance = this;
}
}
int activeSceneNumber = 0 ;
int scenesTotal ;
void Start ()
{
scenesTotal = SceneManager . sceneCountInBuildSettings ;
SceneManager . LoadScene ( activeSceneNumber . ToString (), LoadSceneMode . Additive ) ;
}
public void SwitchScene ()
{
SceneManager . UnloadSceneAsync ( activeSceneNumber . ToString ()) ;
if ( activeSceneNumber + 2 < scenesTotal )
{
activeSceneNumber ++;
}
else
{
activeSceneNumber = 0 ;
}
SceneManager . LoadScene ( activeSceneNumber . ToString (), LoadSceneMode . Additive ) ;
OnSceneLoad ? . Invoke () ;
}
}