您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
34 行
1.3 KiB
34 行
1.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
[ExecuteInEditMode]
|
|
public class LightingScenarioSwitcher : MonoBehaviour {
|
|
|
|
public string[] SceneNames;
|
|
private int LightingScenarioSelector;
|
|
private int lightingScenariosCount;
|
|
private string selectedSceneName;
|
|
private Scene currentAdditiveScene;
|
|
private GameObject sceneUI;
|
|
[SerializeField]
|
|
public int DefaultLightingScenario;
|
|
public bool loadSceneWhenSwitching;
|
|
|
|
public void loadLightingScenario(int index)
|
|
{
|
|
if (!Application.isPlaying)
|
|
{
|
|
this.GetComponent<LevelLightmapData>().LoadLightingScenario(index);
|
|
if (loadSceneWhenSwitching)
|
|
{
|
|
if (currentAdditiveScene.buildIndex != -1) { SceneManager.UnloadSceneAsync(currentAdditiveScene); }
|
|
selectedSceneName = SceneNames[index];
|
|
SceneManager.LoadSceneAsync(selectedSceneName, LoadSceneMode.Additive);
|
|
currentAdditiveScene = SceneManager.GetSceneByPath("Assets/Demo/" + selectedSceneName + ".unity");
|
|
SceneManager.SetActiveScene(SceneManager.GetSceneByPath("Assets/Demo/" + selectedSceneName + ".unity"));
|
|
}
|
|
}
|
|
}
|
|
}
|