茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1735126 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
PIMG_00220.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

Game Play Maker : [轉貼]unity3D AddComponentMenu 添加組件菜單

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15773
[轉貼]unity3D AddComponentMenu 添加組件菜單項

AddComponentMenu 添加組件菜單項

Posted on 2013年07月22日 by U3d /

在編輯器添加一個用於添加組件的菜單項,將擁有該屬性的腳本添加到選中的物體上。(用法:[AddComponentMenu(「Duan/Script_Mobile/BreakAndEnd」)])

例:在當前腳本中加入AddComponentMenu屬性,選中某物體後,將擁有該屬性的腳本添加到選中的物體上。



using UnityEngine;
using System.Collections;

///
/// 按返回退出应用
///

[AddComponentMenu("Duan/Script_Mobile/BreakAndEnd")]
public class BreakAndEnd : MonoBehaviour {

// Update is called once per frame
void Update () {
endGame();

//Unity3D教程手册:www.unitymanual.com
void endGame(){
if ( Application.platform == RuntimePlatform.Android &&
(Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home)) )
{
//Home键好像不一定能用。。默认就是把程序挂到后台,并不是退出。
Application.Quit();
}
}
}


原文出處:AddComponentMenu 添加组件菜单项 | Unity3D教程手册
前一個主題 | 下一個主題 | | | |

討論串




Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|