Question by
KnightRiderGuy · Mar 01, 2016 at 08:30 PM ·
c#uikeyboardinputfieldmultiple-choice
Handling Multiple U.I. Input Fields
I have a virtual keyboard I made that I'm using but I'm trying to figure out how to get it to work with multiple input fields?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Keyboard4ConFig : MonoBehaviour {
//Input Field references
public InputField inputFieldPilotName;
public InputField inputField_LoadScreenTime;
public GameObject keyboardPanel04;
//public Text morseCodeDisplayText;
//animator reference
private Animator KB3Panim;
void Awake(){
inputFieldPilotName.text = PlayerPrefs.GetString("PilotName");
inputField_LoadScreenTime.text = PlayerPrefs.GetString ("IntroTime");
//morseCodeDisplayText = GameObject.Find ("MorseCodeDisplayText").GetComponent<Text> ();
//morseCodeDisplayText.text = PlayerPrefs.GetString("MorseMessage");
}
void Start ()
{
//Just in case we need the Keyboard retractable to make room for more configurations.
//get the animator component
//KB3Panim = keyboardPanel04.GetComponent<Animator>();
//disable it on start to stop it from playing the default animation
//KB3Panim.enabled = false;
inputFieldPilotName = GameObject.Find ("InputFieldPilotName").GetComponent<InputField> ();
inputField_LoadScreenTime = GameObject.Find ("InputFieldLoadScreenTimeDuration").GetComponent<InputField> ();
//inputFieldPilotName.Select();
//inputFieldPilotName.ActivateInputField();
}
/*
#region Panel Slide In Control
//Start Morse Code Keyboard Panel Slide In Animation
public void StartKB3PanelSlideIn(){
StartCoroutine (KB3PanelSlideIn ());
}
IEnumerator KB3PanelSlideIn(){
yield return new WaitForSeconds (0.6f); // wait time
KB3Panim.enabled = true;
SFXmanager SFXpi = FindObjectOfType<SFXmanager> ();
SFXpi.PanelSlideInSFX ();
KB3Panim.Play("MorseKeyboardSlideInAni");
}
//Start Morse Code Keyboard Panel Slide Out Animation
public void StartKB3PanelSlideOut(){
StartCoroutine (KB3PanelSlideOut ());
}
IEnumerator KB3PanelSlideOut(){
yield return new WaitForSeconds (0.6f); // wait time
KB3Panim.enabled = true;
SFXmanager SFXpi = FindObjectOfType<SFXmanager> ();
SFXpi.PanelSlideOutSFX ();
KB3Panim.Play("MorseKeyboardSlideOutAni");
yield return new WaitForSeconds (2.0f); // wait time
KB3Panim.enabled = false;
}
#endregion
*/
public void readButton (string c){
//Pilot Name
inputFieldPilotName.text += c;
//inputFieldPilotName.Select();
//inputFieldPilotName.ActivateInputField();
inputFieldPilotName.caretPosition = 0;
//Load Screen time Input
//inputField_LoadScreenTime.text +=c;
//inputField_LoadScreenTime.Select ();
}
public void deleteText(){
inputFieldPilotName.Select();
inputFieldPilotName.ActivateInputField();
inputFieldPilotName.text = "";
}
string messageToSend;
public void submitText(){
messageToSend = inputFieldPilotName.text;
//morseCodeDisplayText.text = inputFieldMC;
PlayerPrefs.SetString ("PilotName", inputFieldPilotName.text);
}
public void dell(){
inputFieldPilotName.Select();
inputFieldPilotName.ActivateInputField();
}
}
Comment