c# - Getting toggle player prefs to display in unity text field -
im having trouble displaying strings playerprefs in text fields
public void activetoggle () { if (isnone.ison) { playerprefs.setstring("offer_schedule","none"); playerprefs.save(); debug.log("offer_schedule".tostring()); } else if (isdaily.ison) { playerprefs.setstring("offer_schedule","daily"); playerprefs.save(); debug.log("offer_schedule".tostring()); } else if (isweekly.ison) { playerprefs.setstring("offer_schedule","weekly"); playerprefs.save(); debug.log("offer_schedule".tostring()); } } offer_schedule =playerprefs.getstring("offer_schedule");
i save playerprefs offer schedule string based on toggle selected offerschedule.text = playerprefs.getstring("offer_schedule"); cannot string display in text field
your mistake lays in debug.log("offer_schedule".tostring());
here casting string literal string. means displaying literal string "offer_schedule"
.
if want debug.log()
actual playerprefs
value either a:
// debug result getstring directly debug.log(playerprefs.getstring("offer_schedule"));
or attempted in code above b:
// store our value in in variable string offer_schedule = playerprefs.getstring("offer_schedule"); // display our variable debug.log(offer_schedule);
see how in second example not using "
, making call variable, opposed writing literal.
Comments
Post a Comment