您的位置:首页 > 移动开发 > Unity3D

【Unity】怎么强制指定父节点

2016-02-17 15:49 651 查看
文章源于:http://weibo.com/819881121?from=myfollow_all&is_all=1#1455694649734

拖入Hierarchy的prefab强制指定父节点

[InitializeOnLoadMethod]
static void Start()
{
Transform parent = GameObject.Find("Parent").transform;
Selection.selectionChanged = delegate()
{
if (Selection.activeTransform)
{
if (Selection.activeGameObject.name == "Cube")
{
Selection.activeGameObject.transform.SetParent(parent);
}
}
};
}

脚本放在预设体上。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: