Hi everyone I’m in a bit of a pickle. I’m trying to make a remote security keypad in unity. So basically it displays a gameObejct with 10 different buttons that represents 0-9 digits. Once push the button will turn red, which will symbolize that it is pushed. I’m having trouble setting this up can some one help please? I started but then I don’t know where to go. And yes it is in CSharp.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class KeyPad : MonoBehaviour
{
public float distance = 25.0f;
public GameObject buttonZero;//Number Zero Button for the KeyPad
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
Ray rayOrigin = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast(rayOrigin, out hitInfo, distance))
{
Debug.Log ("0");//Just to let me know its hitting the object
if (hitInfo.rigidbody != null)
hitInfo.transform.buttonZero.renderer.material.color = Color.red;
}
}
}
}