用户工具

站点工具


侧边栏

script:unityengine:classes:transform:transform.detachchildren

Transform.DetachChildren 分离子对象

JavaScript ⇒ DetachChildren(): void;
C# ⇒ void DetachChildren();

Description 描述

Unparents all children.

所有子对象解除父子关系。

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

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

JavaScript:

	transform.DetachChildren();
	Destroy(gameObject);

C#:

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

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

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

Transform

script/unityengine/classes/transform/transform.detachchildren.txt · 最后更改: 2016/08/02 05:37 (外部编辑)