Transform.DetachChildren 分离子物体


function DetachChildren () : void

Description描述

Unparents all children.

所有子物体解除父子关系。

Useful if you want to destroy the root of a hierarchy without destroying the children.

如果你想销毁层级的根,而不销毁子物体是很有用的。

  • C#

  • JavaScript

using UnityEngine;using System.Collections;public class example : MonoBehaviour {public void Awake() {transform.DetachChildren();Destroy(gameObject);}}
transform.DetachChildren();Destroy(gameObject);

See Also: Transform.parent to detach/change the parent of a single transform

参见: Transform.parent 去分类/改变单个变换的父级。


,