Pass Variable Through C Script
Hi.
Loading a random scene, y want to load last scene. In First scene i have a button that on Click, take the scene id and save it in int variable. In the second scene, i have other button and i want to load the scene variable saved previously. thx !
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Botones2 : MonoBehaviour {
public int y;
private static int p;
void Awake(){
DontDestroyOnLoad(gameObject);
}
public void Boton1(){
y = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene (Random.Range(0,4));
}
public void Boton2(){
p=gameObject.getComponent(y);
}
}
I want to assign a void for each button using the same script, or using other script. Note: The var is saved in a gameobject that keep the int when load scene. I can´t take the int of that gameobject later.
pd:
I want in button 2 Scene$$anonymous$$anager.LoadScene(y);
something like load previous scene. The button 2 scene is random.
Your answer
Follow this Question
Related Questions
Why isn't my start screen loading? 0 Answers
Build errors in unity 0 Answers
Passing two variables does not work - only one is passed 0 Answers
When I load a scene a second time, some objects don't show up 0 Answers