Quantcast
Channel: Latest Questions by CallToAdventure
Viewing all articles
Browse latest Browse all 62

Player prefs iOS

$
0
0
I am trying to create a simple "plane selection" menu using player.prefs but for some reason it doesn't work; In the selection level I have a scroll view with buttons and the following script: Each button call the corresponding function bellow: #pragma strict function ActivatePlane_1 () { PlayerPrefs.SetInt("planeType", 1); PlayerPrefs.Save(); Debug.Log("Plane 1 Selected"); } function ActivatePlane_2 () { PlayerPrefs.SetInt("planeType", 2); PlayerPrefs.Save(); Debug.Log("Plane 2 Selected"); } function ActivatePlane_3 () { PlayerPrefs.SetInt("planeType", 3); PlayerPrefs.Save(); Debug.Log("Plane 3 Selected"); } function ReturnMenu () { Application.LoadLevel("SelectLevel"); } In the actual game level I have the following script to spawn the plane: #pragma strict var PlaneType1 : GameObject; var PlaneType2 : GameObject; var PlaneType3 : GameObject; function Start () { if (PlayerPrefs.GetInt("planeType", 1)) { Instantiate(PlaneType1, transform.position, transform.rotation); } else if (PlayerPrefs.GetInt("planeType", 2)) { Instantiate(PlaneType2, transform.position, transform.rotation); } else if (PlayerPrefs.GetInt("planeType", 3)) { Instantiate(PlaneType3, transform.position, transform.rotation); } } But something's wrong and I still end up with the first plane in the list; Thanks for any pointers!

Viewing all articles
Browse latest Browse all 62

Trending Articles



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