Question by
kylerziegler · Jan 02, 2019 at 11:00 PM ·
scene-loadingscene-switchingscenesdropdown
Loading a specific scene based on the input from the Dropdown,Loading a specific scene based on the Dropdown data
I'm trying to make a compendium for me and my DnD group of certain quick reference rules, similar to this app on the play store: https://play.google.com/store/apps/details?id=org.evilsoft.pathfinder.reference&hl=en_US an idea that I've had was to use the Dropdown list to select certain things (Like quick reference -> conditions, dying, movement -> then transferring to the specific scene that they select). I'm a bit new to coding, so I'm completely lost on the subject. Below is a jumble of code that I was putting together, each a different idea, so it shouldn't quite be looked at as a coherent script. Any help or tips would be appreciated.
I'm also very open to going a different route, if it deems easier or more efficient.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class SceneLoader : MonoBehaviour
{
public Dropdown myDropdown;
public void LoadNextScene()
{
/* Declare and define an interger variable called currentSceneIndex within the
scene manager class, telling it to run the method GetActiveScene() and tell us
the current buildIndex, the active scene*/
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
//Load the next scene
SceneManager.LoadScene(currentSceneIndex + 1);
}
public string sceneToLoad = Dropdown.OptionData;
private void Update()
{
switch (myDropdown.value)
{
case 1:
for (int index = 0; index < myDropdown.value; index++)
{
SceneManager.LoadScene(myDropdown.value);
}
break;
}
}
}
,
Comment