Hello, I would like to know how to print a playerpref name to a guitext.
My script that makes the name:
var pos : Rect;
private var Car : GameObject;
private var Perf : GameObject;
var pos2 : Vector3;
var pos3 : Vector3;
function Update () {
Car = gameObject.FindWithTag("Car_Selection");
Perf = gameObject.FindWithTag("CarPerf");
}
function OnGUI () {
if (GUI.Button (pos, "McAron MP3")) {
Destroy(Car);
Destroy(Perf);
var obj : GameObject = Instantiate (Resources.Load ("MP4_SEL"), pos2, Quaternion.identity);
var obj2 : GameObject = Instantiate (Resources.Load ("MP3Perf"), pos3, Quaternion.identity);
PlayerPrefs.SetString("Car Name", "Car2");
}
}
Script that loads the name:
function Start(){
var CarName : float = (PlayerPrefs.GetString("Car Name"));
guiText.text(CarName.ToString());
}
But I get the errors:
Cannot convert 'String' to 'float'.
It is not possible to invoke an expression of type 'String'.
Any ideas?