Hey guys, Im trying to do a clicking counter which the counter read and records every click i clicked. Any ideas?

You will need a few things I guess:

  1. a counter

  2. something to click on or some way of detecting the input

Lets start out:

Instead of going into colliders or other hardcore examples, lets use the build in GUI button as trigger.

First we need a counter.

int counter=0; // there we have a variable for the counter

Then we need to show a button that can be clicked. To be lazy we also use the text label on the button to show how much we have counted.

void OnGUI()
{
    if (GUI.Button(new Rect(100,100,200,50), "Count: " + counter))
    { // the IF is true = clicked, lets count one
       counter ++; 
    }

}

Put these into a new ClickCounter.cs file:

You can copy/paste this:

using UnityEngine;
using System.Collections;

public class ClickCounter : MonoBehaviour 
{
	int counter=0; // lets start with zero
		
	
	void OnGUI()
	{
	    if (GUI.Button(new Rect(100,100,200,50), "Count: " + counter))
	    { // the IF is true = clicked, lets count one
	       counter ++; 
	    }
	}
}