unity3d下拉菜单
来源:互联网 发布:佛山广电网络营业厅 编辑:程序博客网 时间:2024/05/18 03:24
// unity3d下拉菜单效果
//you can use or mod this file anyway you like and if you make something cool out of it
// and like to share it send it to piershaw@gmail.com
//just add it to a cam or empty gameObject
// to add buttons just Repeat what you see
private var Ypos1 : float = 0.0;
private var Ypos2 : float = 0.0;
private var Ypos3 : float = 0.0;
private var Ypos4 : float = 0.0;
private var showDropdownButtons1 : boolean;
private var showDropButtonsUP1 : boolean;
var dropSpeed : float = 400.0;// if you like change the speed
function Update(){
if(showDropdownButtons1 == true){
Ypos1 += Time.deltaTime * dropSpeed;
Ypos2 += Time.deltaTime * dropSpeed;
Ypos3 += Time.deltaTime * dropSpeed;
Ypos4 += Time.deltaTime * dropSpeed;
if(Ypos1 >= 30){
Ypos1 = 30;
}
if(Ypos2 >= 60){
Ypos2 = 60;
}
if(Ypos3 >= 90){
Ypos3 = 90;
}
if(Ypos4 >= 120){
Ypos4 = 120;
}
if(showDropButtonsUP1 == true){
Ypos1 -= Time.deltaTime * dropSpeed;
Ypos2 -= Time.deltaTime * dropSpeed;
Ypos3 -= Time.deltaTime * dropSpeed;
Ypos4 -= Time.deltaTime * dropSpeed;
if(Ypos1 >= 0 || Ypos2 >= 0 || Ypos3 >= 0 || Ypos4 >= 0){
Ypos1 = 0;
Ypos2 = 0;
Ypos3 = 0;
Ypos4 = 0;
showDropButtonsUP1 = false;
showDropdownButtons1 = false;
}
}
}
}
// you can change anything in red
function OnGUI (){
if(showDropdownButtons1 == false){
if (GUI.RepeatButton (Rect (50, 0, 100, 30), "Select")){
showDropdownButtons1 = true;
}
}
if(showDropdownButtons1 == true){
if (GUI.Button (Rect (50, 0, 100, 30), "Select")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
if (GUI.Button (Rect (50, Ypos1, 100, 30), "1")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
if (GUI.Button (Rect (50, Ypos2, 100, 30), "2")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
if (GUI.Button (Rect (50, Ypos3, 100, 30), "3")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
if (GUI.Button (Rect (50, Ypos4, 100, 30), "4")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
}
}
//you can use or mod this file anyway you like and if you make something cool out of it
// and like to share it send it to piershaw@gmail.com
//just add it to a cam or empty gameObject
// to add buttons just Repeat what you see
private var Ypos1 : float = 0.0;
private var Ypos2 : float = 0.0;
private var Ypos3 : float = 0.0;
private var Ypos4 : float = 0.0;
private var showDropdownButtons1 : boolean;
private var showDropButtonsUP1 : boolean;
var dropSpeed : float = 400.0;// if you like change the speed
function Update(){
if(showDropdownButtons1 == true){
Ypos1 += Time.deltaTime * dropSpeed;
Ypos2 += Time.deltaTime * dropSpeed;
Ypos3 += Time.deltaTime * dropSpeed;
Ypos4 += Time.deltaTime * dropSpeed;
if(Ypos1 >= 30){
Ypos1 = 30;
}
if(Ypos2 >= 60){
Ypos2 = 60;
}
if(Ypos3 >= 90){
Ypos3 = 90;
}
if(Ypos4 >= 120){
Ypos4 = 120;
}
if(showDropButtonsUP1 == true){
Ypos1 -= Time.deltaTime * dropSpeed;
Ypos2 -= Time.deltaTime * dropSpeed;
Ypos3 -= Time.deltaTime * dropSpeed;
Ypos4 -= Time.deltaTime * dropSpeed;
if(Ypos1 >= 0 || Ypos2 >= 0 || Ypos3 >= 0 || Ypos4 >= 0){
Ypos1 = 0;
Ypos2 = 0;
Ypos3 = 0;
Ypos4 = 0;
showDropButtonsUP1 = false;
showDropdownButtons1 = false;
}
}
}
}
// you can change anything in red
function OnGUI (){
if(showDropdownButtons1 == false){
if (GUI.RepeatButton (Rect (50, 0, 100, 30), "Select")){
showDropdownButtons1 = true;
}
}
if(showDropdownButtons1 == true){
if (GUI.Button (Rect (50, 0, 100, 30), "Select")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
if (GUI.Button (Rect (50, Ypos1, 100, 30), "1")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
if (GUI.Button (Rect (50, Ypos2, 100, 30), "2")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
if (GUI.Button (Rect (50, Ypos3, 100, 30), "3")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
if (GUI.Button (Rect (50, Ypos4, 100, 30), "4")){
showDropButtonsUP1 = true;
showDropdownButtons1 = false;
}
}
}
- unity3d下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 下拉菜单
- 借鉴的一个哥们的组合查询例子
- oracle对用户的管理
- 内核地址空间与进程地址空间
- poj2240 Arbitrage
- 对软件工程的初步认识.
- unity3d下拉菜单
- 2010年12月 六级听力短对话八个
- poj1860 Currency Exchange
- 关于ubuntu上使用github的一些记录
- VC++调用EXE文件的方法 (WinExc,ShellExcute,CreateProcess)
- 【链表】链表上的选择排序
- unity 3d类似 苹果的滑动菜单
- oracle用户权限的管理
- 【链表】链表上的插入排序