您當前的位置:首頁 > 歷史

unity3d中當一個GameObject被Destroy以後所有引用這個物件的欄位全被置為null?

作者:由 創意組的凱文老師 發表于 歷史時間:2015-02-06

unity3d中當一個GameObject被Destroy以後所有引用這個物件的欄位全被置為null?創意組的凱文老師2015-02-07 00:38:48

騷年接我一段文件~

Object.Destroy 銷燬

static function Destroy(obj: Object, t: float = 0。0F): void;

static void Destroy(Object obj, float t = 0。0F);

Description描述

Removes a gameobject, component or asset。

刪除一個遊戲物體,元件或者資源。

The object obj will be destroyed now or if a time is specified t seconds from now。 If obj is a Component it will remove the component from the GameObject and destroy it。 If obj is a GameObject it will destroy the GameObject, all its components and all transform children of the GameObject。 Actual object destruction is always delayed until after the current Update loop, but will always be done before rendering。

物體obj現在被銷燬或在指定了t時間過後銷燬。如果obj是元件,它將從GameObject銷燬元件component。如果obj是GameObject它將銷燬GameObject全部它的元件和GameObject全部transform子物體。

實際物體的銷燬總是延遲到當前更新迴圈後,但總是渲染之前完成。

unity3d中當一個GameObject被Destroy以後所有引用這個物件的欄位全被置為null?wq yang2015-02-07 01:19:11

這是因為UnityEngine。Object過載了operator==,operator!=,所以讓它看上去是null,實際上並沒有被設定成null。

標簽: obj  GameObject  銷燬  object  will