Okay. So, I have a “settings” page in my app, “Rolly”. Here’s the code for it so far:
public var GUISkin : GUISkin;
var level110 = false;
var soundsOn = true;
var soundsOff = false;
var Skin1 = true;
var Skin2 = false;
var Skin3 = false;
var Skin4 = false;
var Skin5 = false;
function OnGUI () {
GUI.skin = GUISkin;
if (GUI.Button (Rect (10,260,120,40), "Back")) {
Application.LoadLevel ("Menu");
}
level110 = GUI.Toggle (Rect (10, 10, 80, 40), level110, "Level 1-10");
if (level110) {
level1115 = false;
if (GUI.Button (Rect (130,50,75,50), "Level 1")) {
PlayerPrefs.SetString("Level", "Level1");
Application.LoadLevelAdditive ("Loader");
}
}
soundsOn = GUI.Toggle (Rect (100, 10, 80, 40), soundsOn, "On");
if (soundsOn) {
PlayerPrefs.SetString("Sounds", "True");
soundsOff = false;
}
soundsOff = GUI.Toggle (Rect (200, 10, 80, 40), soundsOff, "Off");
if (soundsOff) {
PlayerPrefs.SetString("Sounds", "False");
soundsOn = false;
}
Skin1 = GUI.Toggle (Rect (150, 50, 80, 40), Skin1, "Skin 1");
if (Skin1) {
PlayerPrefs.SetString("Skin", "Skin1");
Skin2 = false;
Skin3 = false;
Skin4 = false;
Skin5 = false;
}
Skin2 = GUI.Toggle (Rect (150, 100, 80, 40), Skin2, "Skin 2");
if (Skin2) {
PlayerPrefs.SetString("Skin", "Skin2");
Skin1 = false;
Skin3 = false;
Skin4 = false;
Skin5 = false;
}
Skin3 = GUI.Toggle (Rect (150, 150, 80, 40), Skin3, "Skin 3");
if (Skin3) {
PlayerPrefs.SetString("Skin", "Skin3");
Skin1 = false;
Skin2 = false;
Skin4 = false;
Skin5 = false;
}
Skin4 = GUI.Toggle (Rect (150, 200, 80, 40), Skin4, "Skin 4");
if (Skin4) {
PlayerPrefs.SetString("Skin", "Skin4");
Skin1 = false;
Skin2 = false;
Skin3 = false;
Skin5 = false;
}
Skin5 = GUI.Toggle (Rect (150, 250, 80, 40), Skin5, "Skin 5");
if (Skin5) {
PlayerPrefs.SetString("Skin", "Skin5");
Skin1 = false;
Skin2 = false;
Skin3 = false;
Skin4 = false;
}
}
Okay. So, basically, I’m trying to set it up so the user gets to pick what texture or “skin” they want on the ball in the game. They have five choices and when they choose one, it is saved in the PlayerPrefs. This part of the coding, I understand. However, I need a little help with the code to be placed on the ball in the game. I understand how to PlayerPrefs.GetString however I’m having a bit of a problem matching that with the textures.
Say the code PlayerPrefs.GetString(“Skin”) is put out by the ball at the beginning of the level. If the return on that is “Skin3”, how to I assign that to the third texture I have?
Thanks, you guys are always a great help!