I have started today with some programming in C# with Unity. How can I get the content of a value from the 1st_Scene to the 2nd_Scene?
In the first scene, I have to recognize a picture with the Vuforia engine. After the picture is identified, you can see on a canvas an input Textfield, the Button "Transfer", an empty Textfield and a second button "Next". First I write my name in the Textfield. With a click on the first button "Transfer", the text is displayed in the empty Textfield. Then I click on the second button "Next". This will load the 2nd_scene. Additionally the variable from the first Textfield should be displayed in the second scene, also within a Textfield in the canvas in the 2nd scene, but it won't.
I have tried to do this with a static variable and an extra static class. But Unity shows always this error:
This is the script.
public class Button_Event : MonoBehaviour {
public InputField fInput;
public Text txtEingabe;
public void Setget() {
txtEingabe.text = "Your name is: " + fInput.text;
}
public void SwitchScene() {
DontDestroyOnLoad(this.gameObject);
SceneManager.LoadScene(1, LoadSceneMode.Single);
txtEingabe.text = "Your name is: " + fInput.text;
}
}
Here is picture of the Objects in the two scenes: