I am very new to unity, this is the first project I have worked on. I have a scene where it is the player selection scene and then they click a button to select the player and put him in the new scene. This is where I am having trouble. I can load the new scene but it seems everything im trying is not working. (I have tried DontDestroyOnLoad but I am not sure if im implementing it correctly because my models are in a list and It was tricky) Any help would be appreciated. Sorry for sloppy or bad code/unity skills. im still learning
public class CharCreation : MonoBehaviour
{
private List<GameObject> models;
private int selectionIndex = 0; //default indect of the model
private GameObject ringO;
private GameObject FlameStrike;
static int temp;
void Start()
{
models = new List<GameObject>();
foreach (Transform T in transform)
{
models.Add(T.gameObject);
T.gameObject.SetActive(false);
}
models[selectionIndex].SetActive(true);
}public void Select(int index)
{
if (index == selectionIndex)
{
return;
}
if (index < 0 || index >= models.Count)
{
return;
}
models[selectionIndex].SetActive(false);
selectionIndex = index;
models[selectionIndex].SetActive(true);
temp = selectionIndex;
} public void ConfirmButton()
{
//PlayerPrefs.SetInt("CharacterSelected", selectionIndex);
selectionIndex = temp;
SceneManager.LoadScene("StartMap");
models[selectionIndex].SetActive(true);
print(selectionIndex);
}