C# Unity addition
Go to solution
Solved by minibois,
remove the word 'Update' and replace it with 'OnMouseDown' (and remove the void OnMouseDown(); in your update function now)
This will make it so that every time the mouse will be clicked down, this function will play, which will do the cookie += 1; command.
Your code should become this:
using UnityEngine;using System.Collections; public class Clickable : MonoBehaviour { public int cookie; // Use this for initialization void Start () { } void OnMouseDown(){ cookie += 1; }}
Edit:
to display the amount of cookies make a function called 'OnGUI'. In this you will make a GUI.Label in which you can display the variable 'cookie'.
Like this:
void OnGUI () { GUI.Label(new Rect(10, 10, 100, 20), "Amount of cookies is: " + cookies); }
@TheoWasTaken don't forget to follow your topics and quote people when you answer them. I hope my reply helped and if you have any more questions be sure to ask them

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now