I’m trying to make a kind of keypad with buttons, so button labeled “1” will produce a 1, etc.
How can I have the button produce its own index number in the list?
The “1” key would be element 0, so pressing it should be “Index Number + 1” and so on with the other buttons. How can I code this?`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Register : MonoBehaviour {
[SerializeField] List<Button> registerKeys = new List<Button>();
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void GetKeyNumber()
{
Debug.Log(// Index Number +1);
}`