3DMenu

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
m (Text replace - "</javascript>" to "</syntaxhighlight>")
Line 31: Line 31:
 
}
 
}
 
}
 
}
</javascript>
+
</syntaxhighlight>

Revision as of 20:52, 10 January 2012

Description

This is a very basic example implementation of a menu-like mouse input detector. This script detects mouse overs and mouse clicks, the object this script is applied to will change to a red color when the mouse is over it. The game will quit or load level 1 depending on the value of isQuitBtn.

Script

var isQuitBtn : boolean = false;
 
private var startColor : Color = renderer.material.color;
 
function OnMouseEnter ()
{
	renderer.material.color = Color.red;
}
 
function OnMouseExit ()
{
	renderer.material.color = startColor;
}
 
function OnMouseUp()
{
	if(isQuitBtn)
	{
		Application.Quit();
	}
	else
	{
		Application.LoadLevel(1);
}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox