Saving input from user in series of scenes,Saving input from user for a series of scenes

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.

You topic is not very clear about what you’re trying to achieve, so I’m going to give different solutions to different questions:

  • if you only don’t want to pre-load the string in the input field then just comment/remove the line that assign it (last line to Start in your code sample)
  • if you need to store different texts in each scene then you can just add a “public string prefName” to your script and replace “Score” with prefName (and set a value for prefName in the inspector), for example: PlayerPrefs.GetString(prefName) and PlayerPrefs.SetString(prefName, text)