Home>

I am a beginner in Unity just beginning programming.
As the title says, I want to display the characters entered in the Input field in one scene on the text in another scene.

The problem that occurred

In the same scene, I was able to display the character input in the Input field on the text, but even if I try to display the input character on the text of another scene using that code, it is in another scene. I can't reference the object and it doesn't work.

What I tried

I did some research on the net and tried to make it possible to refer to game objects in other scenes using Guid Based Reference, but it did not work.

  • Answer # 1

    How about using static?

    Scene 1 script ↓

    public class Scene1 :MonoBehaviour
    {
        public static string str;// str can be referenced from anywhere. Assign the text of InputField to this
    }

    Scene 2 script ↓

    string text = Scene1.str;
    // Now assign the text entered in scene 1 to text

    There are some things that you have to be careful about static, so please check it out...