Unity3D Tutorial 18/24 : GUI text appear when mouse hovering on a object.
THIS IS Java# script: GOOD 4 2D GAMES AND 3D GAMES !
--------------------------------------------------------------------------------------
DIRECT DOWNLOAD HERE
THIS IS BACKUP IN TEXT FORM TUTORIAL GUI text appear 18/24
1. Create New java and name it : GUIPOPUPTEXT
2. Copy & Past this text and save java :
---------------------------------------------------------------------------------
var text = "PUT TEXT HERE";
private var currentToolTipText = "";
private var guiStyleFore : GUIStyle;
private var guiStyleBack : GUIStyle;
function Start()
{
guiStyleFore = new GUIStyle();
guiStyleFore.normal.textColor = Color.white;
guiStyleFore.alignment = TextAnchor.UpperCenter ;
guiStyleFore.wordWrap = true;
guiStyleBack = new GUIStyle();
guiStyleBack.normal.textColor = Color.black;
guiStyleBack.alignment = TextAnchor.UpperCenter ;
guiStyleBack.wordWrap = true;
}
function OnMouseEnter ()
{
currentToolTipText = text;
}
function OnMouseExit ()
{
currentToolTipText = "";
}
function OnGUI()
{
if (currentToolTipText != "")
{
var x = Event.current.mousePosition.x;
var y = Event.current.mousePosition.y;
GUI.Label (Rect (x-149,y+40,300,60), currentToolTipText, guiStyleBack);
GUI.Label (Rect (x-150,y+40,300,60), currentToolTipText, guiStyleFore);
}
}
---------------------------------------------------------------------------------
Thank, it's work !
ReplyDeleteBut how set font size ?....