I have 3 scenes that have identical layout. They have same script on “Save” button that takes saves input written by user in InputField. When the user comes back to the scene, they can view the text they had written. Here’s the script:
- public InputField inputText;
- string text;
- void Start()
- {
- text = PlayerPrefs.GetString(“Score”);
- inputText.text = text;
- }
- public void getInput()
- {
- text = inputText.text;
- PlayerPrefs.SetString(“Score”, text);
- }
}
However, if I save something in one scene, say - “I’m at Activity1”; it shows up in the next scene as pre-loaded input. So far, I’ve tried following workarounds but they don’t seem to work. 1. Create a new script for particular scene with identical code. 2. Create an object of playerPref class, but the object does not have SetString function of playerPref class.
Eg. private PlayerPrefs Activity1; Activity1.(the function is missing).
Please let me know how to resolve my issue. Thanks.