- Home /
Question by
rockista_viii · Aug 14, 2014 at 06:48 AM ·
playerprefstextfield
How do i Copy Textfield text to my label
I create a GUI.textfield and GUI.label and Button when i press button the text that i input in the textfield transfer to my label
thank you
see my code below i hope anyone can help me
#pragma strict
var mytext:String;
private var copy : String;
function Start () {
}
function Update () {
PlayerPrefs.SetString("copy","mytext");
}
function OnGUI()
{
mytext=GUI.TextField(Rect(Screen.width/2+100,Screen.height/2+100,100,50),mytext,25);
GUI.Label(Rect(Screen.width/2+100,Screen.height/2+50,100,50),copy);
if(GUI.Button(Rect(Screen.width/2+100,Screen.height/2,100,50),"Copy Text"))
{
copy = PlayerPrefs.GetString("mytext");
}
}
Comment
Best Answer
Answer by Mehul-Rughani · Aug 14, 2014 at 09:31 AM
Hope You Are Looking For This...
var mytext:String;
var flag : boolean;
private var copy : String;
function Start () {
PlayerPrefs.DeleteKey("copy");
}
function Update () {
}
function OnGUI()
{
mytext=GUI.TextField(Rect(Screen.width/2+100,Screen.height/2+100,100,50),mytext,25);
GUI.Label(Rect(Screen.width/2+100,Screen.height/2+50,100,50),PlayerPrefs.GetString("copy"));
if(GUI.Button(Rect(Screen.width/2+100,Screen.height/2,100,50),"Copy Text"))
{
PlayerPrefs.SetString("copy",mytext);
}
}