hi guys, after failing to use streamwriter i’ve attempted to use playerprefs instead. what im trying to do is set usernames in arrays rather simply on a new line of text with streamwriter. regardless could anyone tell me if the concept of this would actually work? becuase im having trouble assasinging new names.
var Name = "input name";
var NameInp = "";
var Users = new Array ();
var FirstNameUsed = false;
var V1 : Vector2 = Vector2 (100,100);
var V2 = 200;
var V3 = 20;
var HoldName = "";
var Name2 = "";
function Update () {
if(Name != "input name" Input.GetKeyDown("return") FirstNameUsed == false) {
PlayerPrefs.SetString("Name", Name);
Users.Push(Name);
print(Name);
FirstNameUsed = true;
HoldName = Name;
}
if(FirstNameUsed HoldName != Name Input.GetKeyDown("return")) {
Users.Push(Name);
Users[1] = Name;
}
if(Input.GetKeyDown("r")) {
print(Users[0]);
}
if(Input.GetKeyDown("l")) {
print(Users[1]);
}
NameInp = Name;
}
function OnGUI () {
Name = GUI.TextField(Rect(V1.x,V1.y,V2,V3), Name, 20);
}
say i wanted to create a game where its used strictly on one system, or database. I want it to create a new name everytime rather than keeping, or overwriting the same name. Is there any more efficient way to do this?
EDIT: I’ve relised that you don’t even need to do half the crap i did! the push function just adds a new name regardless lol FML
hey eric thanks for the reply, but im having a little trouble understanding how its works heres an example of my code could you help me rectify? thanks
var Name = "input name";
var NameInp = "";
var Users = new Array ();
var FirstNameUsed = false;
var V1 : Vector2 = Vector2 (100,100);
var V2 = 200;
var V3 = 20;
var HoldName = "";
var Name2 = "";
function Update () {
if(Name != "input name" Input.GetKeyDown("return") FirstNameUsed == false) {
PlayerPrefs.SetString("Name", Name);
Users.Push(Name);
print(Name);
FirstNameUsed = true;
HoldName = Name;
var Name1 = Users[0];
var names = new String[10];
for (i = 0; i < names.Length; i++)
names[i] = "Player"+(i+1);
if (!PlayerPrefsX.SetStringArray("Users", Users))
print("Can't save names");
PlayerPrefsX.SetStringArray("Users", Users);
}
if(FirstNameUsed HoldName != Name Input.GetKeyDown("return")) {
Users.Push(Name);
}
if(Input.GetKeyDown("r")) {
print(Users);
}
NameInp = Name;
}
function OnGUI () {
Name = GUI.TextField(Rect(V1.x,V1.y,V2,V3), Name, 20);
}