Selection.GetTransforms 获取变换列表
static function GetTransforms (mode : SelectionMode) : Transform[]
Description描述
Allows for fine grained control of the selection type using the SelectionMode bitmask.
允许对选择类型进行精细的控制,使用SelectionMode枚举类型。
// C# Example
// Creates a new parent for the selected transforms
// 为选择的变换创建一个新的父级
using UnityEngine;
using UnityEditor;
public class CreateParentForTransforms : ScriptableObject {
[MenuItem ("Example/Create Parent For Selection _p")]
static void MenuInsertParent() {
Transform[] selection = Selection.GetTransforms(
SelectionMode.TopLevel | SelectionMode.OnlyUserModifiable);
GameObject newParent = new GameObject("Parent");
foreach(Transform t in selection)
t.parent = newParent.transform;
}
// Disable the menu if there is nothing selected
// 如果什么都没有选择将禁用菜单功能
[MenuItem ("Example/Create Parent For Selection _p", true)]
static bool ValidateSelection() {
return Selection.activeGameObject != null;
}
}
最后修改:2011年4月11日 Monday 14:07