Unity3D GUI菜单弹出隐藏的效果

Unity3D GUI菜单弹出隐藏的效果

关于GUI菜单弹出隐藏效果

有做好的预设文件

效果图1






效果图2




再次点击红色LOGO会还原成效果图1的样子






Menu
复制内容到剪贴板
代码:
var showMenuButton:ShowMenuButton;
var menuButton:GUITexture;
var menu1:GUITexture;
var menu2:GUITexture;
var menu3:GUITexture;
function OnGUI(){
if(showMenuButton.showMenu){
if(menu1.transform.position.y menu1.transform.position.y+=Time.deltaTime;
}
if(menu1.transform.position.y>0.18&&menu2.transform.position.y menu2.transform.position.y+=Time.deltaTime;
}
if(menu2.transform.position.y>0.18&&menu3.transform.position.y menu3.transform.position.y+=Time.deltaTime;
}
}
if(!showMenuButton.showMenu){
if(menu1.transform.position.y>menuButton.transform.position.y){
menu1.transform.position.y-=Time.deltaTime;
}else{
menu1.transform.position.y=menuButton.transform.position.y;
}
if(menu2.transform.position.y>menuButton.transform.position.y){
menu2.transform.position.y-=Time.deltaTime;
}else{
menu2.transform.position.y=menuButton.transform.position.y;
}
if(menu3.transform.position.y>menuButton.transform.position.y){
menu3.transform.position.y-=Time.deltaTime;
}else{
menu3.transform.position.y=menuButton.transform.position.y;
}
}
}
ShowMenuButton
复制内容到剪贴板
代码:
var showMenu : boolean = false;
function OnMouseEnter () {
gameObject.GetComponent(GUITexture).color = Color.red;
showMenu = true;
}
function OnMouseUp () {
showMenu = !showMenu;
if(showMenu)
gameObject.GetComponent(GUITexture).color = Color.red;
else
gameObject.GetComponent(GUITexture).color = Color.yellow;
}

你可能感兴趣的:(Unity)