Selection.activeGameObject 激活游戏物体
static var activeGameObject : GameObject
Description描述
Returns the active game object. (The one shown in the inspector)
返回激活的游戏物体。(在检查面板中显示)
It will also return game objects that might be prefabs or non-modifyable objects.
它同样回返的可能是预设的或者不可修改的游戏物体。
// Rotates the selected Game Object +45 degrees if the user presses 'g'
// or -45 degrees if the user presses 'Shift + g'
// If no object is selected, the Menus are grayed out.
// 如果用户按'g'会将游戏物体顺时针旋转45度,如果用户按'Shift + g'将逆时针旋转45度
// 如果没有物体被选择,菜单是灰色的。
@MenuItem ("Example/Rotate Green +45 _g")
static function RotateGreenPlus45() {
var obj = Selection.activeGameObject;
obj.transform.Rotate(Vector3.up*45);
}
@MenuItem ("Example/Rotate Green +45 _g", true)
static function ValidatePlus45() {
return Selection.activeGameObject != null;
}
@MenuItem ("Example/Rotate green -45 #g")
static function RotateGreenMinus45() {
var obj = Selection.activeGameObject;
obj.transform.Rotate(Vector3.down*45);
}
@MenuItem ("Example/Rotate green -45 #g", true)
static function ValidateMinus45() {
return Selection.activeGameObject != null;
}
最后修改:2011年4月11日 Monday 12:06