Init repository
This commit is contained in:
Executable file
+45
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DropDownScenePopulator : MonoBehaviour
|
||||
{
|
||||
public List<Dropdown.OptionData> optionDataList;
|
||||
public Dropdown scenenavigator;
|
||||
public string SelectedSceneName = "";
|
||||
void Start()
|
||||
{
|
||||
if (scenenavigator)
|
||||
{
|
||||
optionDataList = new List<Dropdown.OptionData>();
|
||||
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; ++i)
|
||||
{
|
||||
string name = System.IO.Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
|
||||
optionDataList.Add(new Dropdown.OptionData(name));
|
||||
}
|
||||
scenenavigator.ClearOptions();
|
||||
scenenavigator.AddOptions(optionDataList);
|
||||
scenenavigator.onValueChanged.AddListener((t) => {
|
||||
//SetSceneOptionData(optionDataList[scenenavigator.value]);
|
||||
SelectedSceneName = optionDataList[scenenavigator.value].text;
|
||||
Debug.LogError("Selected scene in navigator: " + optionDataList[scenenavigator.value].text);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchScene()
|
||||
{
|
||||
Time.timeScale = 1;
|
||||
Debug.Log(SelectedSceneName);
|
||||
Debug.Log(string.Format("Setting current scene to {0}", SelectedSceneName));
|
||||
SceneManager.LoadScene(SelectedSceneName);
|
||||
}
|
||||
|
||||
public void ReloadScene()
|
||||
{
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user