禁用和不可见的 Gameobject 会占用性能吗? [英] Will Disabled and invisible Gameobject take up performance?

查看:27
本文介绍了禁用和不可见的 Gameobject 会占用性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我放置一个具有复杂模型和纹理的游戏对象并禁用其网格渲染器,它是否仍会消耗 CPU 和 GPU 资源?只会消耗内存吗?

If I placed a gameobject with complicated model and texture and disable its mesh renderer, will it still consume CPU and GPU resources? Will it only consume memory?

推荐答案

如果它们上面有任何刚体、碰撞体等,它们将消耗相当多的 CPU.如果您禁用了 MeshRenderer 并且游戏对象上没有更多的 rednerer,那么 GPU 的消耗将是 0.它不可避免地会消耗内存.

If they have any Rigidbodies, Colliders, etc on them, they will consume a considerable amount of CPU. If you have disabled MeshRenderer and there are no more rednerers on the gameobject, than there will be 0 consumption of GPU. It will consume memory, inevitably.

现在由于对象是活动的并且在场景中工作,即使它没有任何组件并且本质上只是一个空的游戏对象,它仍然会浪费一些 CPU,但这个数量可以忽略不计.例如,如果游戏对象有一个标签或一个层,或者如果您有任何按名称查找的内容,在这些情况下,它会消耗一些 CPU.

Now since the object is active and working on the scene, even if it doesnt have any components and is essentially just an empty gameobject, it still will waste some CPU, but that amount will be negligable. For example if the gameobject has a tag, or a layer or if you have any Finds by name, in those cases it will consume some CPU.

最好的方法是停用游戏对象,然后在需要时重新激活它 SetActive(false/true);

The best way is to deactivate the GameObject and than re-Activate it when you need it SetActive(false/true);

这篇关于禁用和不可见的 Gameobject 会占用性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆