Okey, i’m making calculator and i want when you click on button 1 or whatever other number to put button text to my text that is named input.
So i made this public :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Glavnaskripta : MonoBehaviour {
public Text unos3;
public Button[] button;
private string stringunosa;
public Text rezultat;
public void InputNumber()
{
int i;
for(i = 0; i < 10; i++)
{
if(button*.isActiveAndEnabled)*
{*
_ string b = button*.GetComponentInChildren().text;_
_ unos3.text = b.ToString ();_
_ }_
_ }_
_ }*_ So basically i want to know which button is pressed and add his text to Input. Any help? You have picture down there how it looks.
}* } The second way is to add the function in the inspector : You choose a button, you look in the inspector at the Button component and there you will see OnClick. Finally, you will add the object that contains the script with the OnButtonClick method and choose the method. Note: the buttons from the array should be ordered. The button with the number 1 should be first and the one with number 9 should be last. For more information about the first way, visit [this][1] link. For more information about the second way, visit [this][2] link. [1]: Button.onClick.AddListener - Questions & Answers - Unity Discussions [2]: Unity Connect