- Home /
Question by
bork98 · Mar 15, 2015 at 03:58 PM ·
uiplayerprefsusername
How Can i store string variable through UI text that is confirmed by a button ?
I want to make input field that says "What's your name" and i have done it. I have put an UI button that says confirm and i want after i press it to store the Ui text string and load the game scene, how can i do this ?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class UIInputField : MonoBehaviour {
public Text charText;
public Text placeholderText;
// Use this for initialization
void Start () {
charText = GameObject.Find("CharText").GetComponent<Text>();
placeholderText = GameObject.Find("Placeholder").GetComponent<Text>();
}
public void CharacterField(string inputFieldString)
{
charText.text = inputFieldString;
}
public void ConfirmName()
{
if(placeholderText.enabled == true)
Debug.Log("Please enter a name");
else
Debug.Log(" Confirmed Player Name");
}
}
Comment