Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

PlayerPref only saving 1 variable

$
0
0
Hello, I am using PlayerPrefs to store values from 2 TMP Input fields. The On Value Change event for each input field calls the StoreDisplay method. What is odd is that the value for wD is stored and displayed correctly on the next startup. The tD does not. Both are set with identical syntax. In the Inspector both have the input fields set properly. When I type in values to the 2 input fields both are showing up in the debug.log, but on the next startup only wD is working fine, tD is not storing anything. I'm probably missing something really basic, any help is appreciated. Here is the code that sets the values: public void StoreDisplay() // Get the window depth and the estimated TD for playerprefs { PlayerPrefs.SetString("totalDepth", tD.text); PlayerPrefs.SetString("windowDepth", wD.text); PlayerPrefs.Save(); Debug.Log("wD =" + PlayerPrefs.GetString("windowDepth")); Debug.Log("tD =" + PlayerPrefs.GetString("totalDepth")); } When I type into the input fields during run time every keystroke is seen on debug.log for both fields, so I know the data is getting into the correct keys. When I start it up the next time debug.log statements show wD = 123 //(correctly stored and retrieved from the last run) and tD = //(nothing, blank)

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>