How to change a public location,how to get a public variable
My idea is to access saved data. But I have a function that I may need like 4 or 5 times so I wanted to make a script where we can change the location of the data that I want to acces. But I dont know how to do it. Like :
//...........
public string str = playerprefs.skype ;
void change_button_value ()
{
button.getComponent<Text>().text = str
}
//........
I want to be able of changing the str value by an other location of an other string.
,
Comment
Answer by b1gry4n · Aug 31, 2016 at 12:04 AM
change_button_value("this is my string, it can be anything i want");
void change_button_value(string s){
//plug "s" in to whatever you want
String myNewString = s;
}
It doesnt answers my question.. I want to know how to modify a public string on unity editor putting the place where the info is. Insted of writig the string, I want to write the location of the string like :
// ins$$anonymous$$d writing a word in the console like
String s = " aaaaaaa " ;
// I want to write this
String s = Game.current.string1
// but if I write this in the console, i'll obtain
String s = " Game.current.string1 "