DOTS 优化 之 ScriptableObjects
ScriptableObject
A ScriptableObject is a data container that you can use to save large amounts of data, independent of class instances. One of the main use cases for ScriptableObjects is to reduce your Project’s memory usage by avoiding copies of values. This is useful if your Project has a Prefab
that stores unchanging data in attached MonoBehaviour scripts
.
Every time you instantiate that Prefab, it will get its own copy of that data. Instead of using the method, and storing duplicated data, you can use a ScriptableObject to store the data and then access it by reference from all of the Prefabs
本文介绍了DOTS优化中的ScriptableObject使用,它作为数据容器可以减少Unity项目内存使用,避免Prefab实例化时的数据复制。ScriptableObject不能附加到GameObject上,而是作为Assets保存。主要用途包括Editor会话中保存数据和作为运行时资源。创建ScriptableObject子类,并通过CreateAssetMenu创建实例,然后在其他脚本中引用以读取和使用数据。
订阅专栏 解锁全文

1万+

被折叠的 条评论
为什么被折叠?



