- Home /
Question by
intellectarts · Sep 17, 2017 at 06:36 AM ·
unity 5guiinputfield
How to get input from the input fields and display it through lable?
Hi, i want to enter text, integer or float values in the text box and on clicking the button below, i want to display on the same page down below. P.S i am using c# in Unity 3D. I am a Learner.
Can you help me out in this? Thanks
capture.jpg
(14.5 kB)
Comment
Answer by PersianKiller · Sep 17, 2017 at 07:16 AM
hi. I don't know how do you want to show it,I use a text to show value of input field.
attach this script to the text that will show the value.then on the button OnClick() function call ShowText().
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class text : MonoBehaviour {
public Text t1;
public InputField I1;
// Use this for initialization
void Start () {
t1 = GetComponent<Text> ();
t1.text = I1.text;
}
public void ShowText(){
t1.text = I1.text;
}
}
watch this video ,hope it helps.
https://expirebox.com/download/bfbe774385c97bb399381991b368f668.html