How to use the Event Class!

I just want to know how to use this class. I have searched the document but just find the following example

function OnGUI () {
GUILayout.Label ("Press Enter To Start Game");
if (Event.current.Equals (Event.KeyboardEvent ("[enter]")))
Application.LoadLevel (1);
if (Event.current.Equals (Event.KeyboardEvent ("return")))
print ("I said enter, not return - try the keypad");
}

I want to capture the special event such as the mouse instead of useing the input settings. So I use the following code want to print something when player press the mouse key.

if(Event.current.type == EventType.MouseDown) print("hello");

But it dont work!

So if you want to use Event, use it in OnGUI.

Hey,AngryAnt, yes I konw this page, and I put those code in OnGUI() but It doesn’t work.

“Doesn’t work” as in you get no output or as in it doesn’t compile? Use Debug.Log() if you want debug output to show up in the unity editor console.

Try again, two event dont work!

using UnityEngine;
using System.Collections;

public class CGUIController : MonoBehaviour {

	void OnGUI()
	{
		if(Event.current.type == EventType.ScrollWheel) print("ScrollWheel");	//no work
		if(Event.current.type == EventType.MouseDown) print("MouseDown");		//ok
		if(Event.current.type == EventType.MouseUp) print("MouseUp");			//ok
		if(Event.current.type == EventType.MouseMove) print("MouseMove");		//no work
		if(Event.current.type == EventType.MouseDrag) print("MouseDrag");		//ok	
		if(Event.current.type == EventType.KeyDown) print("KeyDown");	//ok
		if(Event.current.type == EventType.KeyUp) print("KeyUp");		//ok
		if(Event.current.type == EventType.ContextClick) print("ContextClick");	//no description

	}
}