Since the keypad don't have buttons I added cubes to each number and attached a script to each cube so when clicking on a cube it will show it's number in the top area.
For example Key 1 (Cube) when I click on it when the game is running it's not firing the click on all the cube area same for all the other cubes :
When I click on the cube of key 1 it's working only on the left bottom area mostly on that sides. Even if the cube is covering the whole key area.
This is how it looks like when I uncheck the cubes mesh renderer :
Then when running the game and clicking on a cube : it's showing the number in the Security Keypad Text(Text Mesh)
This is the script attached to each cube :
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
public class SecurityKeypadKeys : MonoBehaviour
{
public TextMesh text;
private void Start()
{
text = GameObject.Find("Security Keypad Text").GetComponent<TextMesh>();
}
private void OnMouseDown()
{
string[] digits = Regex.Split(transform.name, @"\D+");
foreach (string value in digits)
{
int number;
if (int.TryParse(value, out number))
{
text.text = value;
}
}
}
}
The main problem is that on most of the cubes you need to click on specific point/small area to make it work and I want it to be working trigger when you click on each cube at any place on the cube.