如果游戏对象在运行时未移动,则被称为静态游戏对象。如果游戏对象在运行时移动,则被称为动态游戏对象。
Unity 中的许多系统都可以在 Editor 中预计算有关静态游戏对象的信息。由于静态游戏对象不会移动,因此这些计算的结果在运行时仍然有效。这意味着 Unity 可以节省运行时计算成本,并可能提高性能。
Static Editor Flags 属性列出了许多 Unity 系统,这些系统的预计算中可以包含一个静态游戏对象。使用下拉选单可定义哪些系统应在它们的预计算中包含此游戏对象。在运行时设置 Static Editor Flag 对这些系统没有影响。
仅当系统需要了解某个游戏对象时,才应该将这个游戏对象包含在预计算中。如果系统无需了解某个游戏对象,但仍然将这个游戏对象包含在预计算中,可能会导致计算资源浪费、产生不必要的大数据文件或意外行为。
Static Editor Flags 属性位于游戏对象的 Inspector 的最右上角。这个属性包含一个复选框(将值设置为 Everything 或 Nothing)和一个下拉菜单(可选择要包含的值)。
还可以使用 GameObjectUtility.SetStaticEditorFlags API 和 GameObject.isStatic 在代码中设置 Static Editor Flags 属性。
可用值如下:
属性: | 功能: |
---|---|
Nothing | 对于任何系统,都不将游戏对象包含在预计算中。 |
Everything | 对于下方的任何系统,都将游戏对象包含在预计算中。 |
Contribute GI | 在预计算光照数据时包含游戏对象。有关预计算光照的更多信息,请参阅有关光照系统的文档。 |
Occluder Static | 在遮挡剔除系统中,将游戏对象标记为静态遮挡物。有关更多信息,请参阅有关遮挡剔除系统的文档。 |
Occludee Static | 在遮挡剔除系统中,将游戏对象标记为静态被遮挡物。有关更多信息,请参阅有关遮挡剔除系统的文档。 |
Batching Static | 将游戏对象的网格与其他符合条件的网格组合起来,有可能降低运行时渲染成本。有关更多信息,请参阅有关静态批处理的文档。 |
Navigation Static | 在预计算导航数据时包含游戏对象。有关更多信息,请参阅有关导航系统的文档。 |
Off Mesh Link Generation | 在预计算导航数据时,尝试生成一个从该游戏对象开始的网格外链接。有关更多信息,请参阅有关自动构建网格外链接的文档。 |
Reflection Probe | 为 Type 属性设置为 Baked 的反射探针预计算数据时,包含此游戏对象。有关更多信息,请参阅有关反射探针的文档。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.