您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
21 行
597 B
21 行
597 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class SceneUnloadScript : MonoBehaviour
|
|
{
|
|
public string sceneName; //name of scene to unload without path e.g. "myScene"
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
for (int i = 0; i < SceneManager.sceneCount; i++)
|
|
{
|
|
Debug.Log(SceneManager.GetSceneAt(i).name);
|
|
if (sceneName.Equals(SceneManager.GetSceneAt(i).name))
|
|
{
|
|
SceneManager.UnloadSceneAsync(sceneName);
|
|
}
|
|
}
|
|
}
|
|
}
|