- Home /
Make an object respond to a click in c# only when a variable equals a certain value
I have a working script to make the object respond to a click, but I only want it to respond when a certain variable equals a certain value.
Here is my c# code:
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnMouseDown(){
//do something
}
}
Comment
Best Answer
Answer by Dave-Carlile · Jun 07, 2013 at 10:25 PM
void OnMouseDown()
{
if (your_variable == some_value)
{
// do stuff
}
}
Replaced your_variable
and some_value
with the variable and value you're interested in comparing.