admin管理员组

文章数量:1565797

unity3d销毁游戏对象

As important instantiating and modifying gameObjects is in a game, it's equally important to destroy them when they are not required.

由于在游戏中实例化和修改gameObjects很重要,因此在不需要它们时销毁它们同样重要。

Main reasons for destroying gameObjects include managing memory, getting rid of not-needed gameObjects (Like those that go beyond the camera and don't return), or even game-related events (Getting hit by a bullet).

销毁游戏对象的主要原因包括管理内存清除不需要的游戏对象 (就像那些超出摄像头且不会返回的对象),甚至是与游戏相关的事件(被子弹击中)。

Destroy(gameObject): That's the code which is used to destroy a gameObject. Fairly simple, isn't it? Let's rewind and have a slightly more deeper look at what's going on. If you try to explore the Destroy method in your IDE, you will see that the Destroy method has 2 variants(overloaded forms).

Destroy(gameObject):这是用于销​​毁游戏对象的代码。 很简单,不是吗? 让我们倒带,对发生的事情有更深入的了解。 如果您尝试在IDE中探索Destroy方法,则会看到Destroy方法具有2个变体(重载表格)。

The first overload form simply Destroys the gameObject that's input as a parameter, and nothing else.

第一个重载形式只是销毁作为参数输入的gameObject,而没有其他任何事情。

While, the second overload form, involves another parameter time, t as a float variable. This will wait for the time specified in seconds

本文标签: 对象游戏如何在Unity3dUnity