Get the GUID of the resource that will be generated

1) Obtain the GUID of the resource to be generated
​2) The question of merging multiple small resource packs into a large resource pack
3) The function and historical reason of the hasExtraRoot parameter in the model Meta
4) Points for attention in batching


This is the 333rd post of UWA technical knowledge sharing, and it is also the third round of "Accumulation|Technology Sharing". It selects hot topics in the UWA community, covers UWA Q&A, community posts and other technical knowledge points, to help everyone more comprehensively grasp and study.

Asset

Q: Suppose you need to import an FBX file and modify some import settings at the same time. If you import first, generate a GUID, and then modify it, the Import process will appear twice. When the amount of resources is large, a lot of time will be wasted.

The setting itself is simple, and Meta can be created through text. But the resource GUID is a more troublesome problem. Because it needs to be guaranteed not to be repeated, and it has a certain relationship with the path.

If the GUID is generated using the future import resource path, what should be done?

A1: I have a similar requirement recently. My method is to prepare a template Meta for "import settings", and the GUID in it already exists in the project. Then, when generating or modifying corresponding resources, directly copy that template Meta. Then if the resource to be imported has already been imported, replace the GUID back. If it is a newly imported resource, Unity will automatically regenerate a new GUID for me. I don't care about it, so the import will be much faster.

Thanks to junbin.liu@UWA Q&A community for providing answers

A2: It is recommended to modify directly when importing, you can try OnPostprocessAllAssets of Unity 3D.

Thanks to He Fan@UWA Q&A Community for providing answers


AssetBundle

Q: I read an article saying that the interface LoadFromFile(string path, uint crc, ulong offset); can be used to combine resource packages into one package and reduce IO operations. I don’t know if the process is understood as follows:

Before merging:
Asset Bundle A: assets_res_a.bundle
Resource Bundle B: assets_res_b.bundle
How to load resource bundles before merging:
AssetBundle a = AssetBundle.LoadFromFile("assets_res_a.bundle");
AssetBundle b = AssetBundle.LoadFromFile("assets_res_b. bundle");

After merging:
resource bundle AB: assets_res_ab.bundle
and records the offsets of a and b in the big bundle (ab) (offset=0 for package A, offset=12 for package B). The resource bundle loading
method after merging:
AssetBundle a = AssetBundle.LoadFromFile("assets_res_ab.bundle", 0, 0);
AssetBundle b = AssetBundle.LoadFromFile("assets_res_ab.bundle", 0, 12);

From the interface point of view, the IO operations are not reduced after the merger, and the assets_res_ab.bundle is still read twice, unless the engine is optimized internally. When the assets_res_ab.bundle is read for the first time, there is IO, and the second is not released. It is not IO after reading it for the first time, please give me some advice.

A: AssetBundle is already a VFS, and it is unreasonable to manage an additional layer on top of it, and there may be IO handle conflicts.

The so-called reduction of IO above is not to reduce the reading volume of IO itself, but to reduce an IO handle, and directly type two original resources into a bundle, which is actually the same. Then the question becomes how to package the Bundle reasonably.

Thanks to 1 9 7 3-3111356 @UWA Q&A community for providing answers


Asset

Q: What is the hasExtraRoot parameter in the model Meta for? Is there any historical reason?

There is a strange parameter hasExtraRoot in the model Meta, which seems to belong to humanDescription, but it will actually affect any type of model.

There is no place to adjust this parameter whether it is in the API or in the editor interface. Some of the current items are 0 and some are 1. It can be observed that in the case of 1, the Transform with no Mesh association in the outer layer will be retained; in the case of 0, the Transform with the top Child not exceeding 1 and no Mesh will be removed.

I don't know how this was generated, is it to adapt to some historical versions?

A: You can refer to the following:
FBX import: humanoid rig creates extra GameObject ("hasExtraRoot") - Unity Forum

Thanks to Wild Watermelon @UWA Q&A Community for the answer


Rendering

Points for attention in batching of SRP

SPR Batcher is suitable for URP pipelines, as long as the Shader variants used in the material are the same, they can be batched together. However, the DrawCall of UGUI and particles uses Unity's own batch logic, so SRP Batcher is not applicable; and the use of MaterialPropertyBlock to modify materials, including SpriteRenderer, will interrupt SRP Batcher.

In addition, you need to pay attention to the RenderQueue interspersed. The priority of GPU Instancing is higher than that of SRP Batcher. The more invisible problem is that the SRP Batcher batching is successful on the Editor, but the batching fails on the real machine. For example, the version of Unity leads to the failure of OpenGL ES. The API causes the problem that SRPBatcher fails to batch on the real machine. For example, if the variables in the CBuffer are not in the property of the shader, there will be similar problems.

Looking forward to more discussions, welcome to the UWA community for communication:
UWA-Community

What are the points to note about static batching

There are two types of static batching, one is processed in the Editor in advance, and the other is dynamic processing at Runtime, which requires the same material to be batched.

Of course, there are also disadvantages. When the sub-model is repeated, it may increase the Mesh memory usage. That is why everyone says that static batching consumes more space.

Looking forward to more discussions, welcome to the UWA community for communication:
UWA-Community

The cover image comes from the Internet


That's all for today's sharing. Life has a limit but knowledge has no limit. In the long development cycle, the problems we encountered are just the tip of the iceberg. The UWA community is willing to accompany you to explore and share together. More developers are welcome to join the UWA community.

UWA official website: www.uwa4d.com
UWA community: community.uwa4d.com

 

おすすめ

転載: blog.csdn.net/UWA4D/article/details/130336875
おすすめ