当前位置:网站首页>Small knowledge points of asset

Small knowledge points of asset

2022-06-23 02:04:00 Thunder Gazi

1. Wavy lines

When the end of the folder is ~. He will not display in the project .

2.DisableWriteTypeTree Use

Unity In order to make the new version compatible with the old version Assetbundle, Complete settings will be made when packaging . For example, the previous version recorded a lot of data, but the new version was not used .. When the new version is packaged, the data will still be written in by default , Let the old version also work . therefore bundle It will be a little bigger

  It uses a very simple Cube package , Generated with the first Bundle yes 39KB. The second is 26KB. Their memory usage at run time is also very different . So if the project is sure not to change the version for development and use DisableWriteTypeTree Packaging reduces package size and memory usage . The author has also experienced 6、7 It's a project , At present, there is no project that has been online, and a new version should be used unity Iterative development .

3. When the same resource is loaded asynchronously and synchronously in the project , The practice of our project is to synchronize directly in asynchrony load To solve .

4.Unity Why is it that setting resources in a project does not change the properties of the file itself , The reason is that the import project will generate a copy of the resources in Library in .Unity Reading is actually Library Resources for .

There was a problem in the previous project , It is wrong to import a shader into a new device no matter how you change it . Later, I took other people's Library Just copy the resource .

5. Officials say that if you want to do a hot update in the project , Many of them are generated AssetBundle In the process of MD5 The record of . This can sometimes be wrong , Maybe two identical files have different versions , Generated MD5 Are not the same as . Recommended in build AssetBundle Go ahead MD5 Record , Or lazy Just use the generated AssetBundle There are Hash Value to record .

6. When there is a sound in the project, the large sound delay in the real machine is likely due to the DSP buff The setting is too large . His principle is that the trigger sound will be added to the cache and wait , Wait until the buffer is large enough to play . This reduces communication with the sound card , But the problem is as mentioned above .

7. If our code writes multiple generics Such as <T,U,X,Z> And so on. , Be sure to pay attention to constraints . Because his implementation will generate a stack of permutation overloads at compile time , Suppose the coefficient of a term is 10 individual , that 4 Item will appear 1000 One such overload . That's pretty efficient .

8.Resource Don't put too many resources in it , Because a non uninstallable red black tree will be generated inside , So as to occupy memory .

9. Official recommendation LZ4 compression technique , The speed is almost Lzma Of 10 times , But the compressed volume will be higher than 30%,trunk-base Compression mode of , When decompressing, you can reduce the memory consumption , Because there is no need to unzip the entire file , Unzip each trunk When , You can reuse buffer( In the China enhanced version, a LZ4 Of AssetBundle encryption )

10.Texture 

1.upload buffer
and DSP buffer similar , Is how much to fill Texture Data time , towards GPU push once
2.r/w
Do not open it if it is not necessary , One Texture The normal loading process is
Load into memory -> analysis -> upload buffer -> From memory delete
After the option is turned on , Not from memory delete, As a result, both memory and video memory have a copy ( notes : Looks like iOS There won't be two , Instead, use a virtual pointer , Point to the same piece of data , The details can be verified )
3.mip maps
for example UI Don't open these , Also reduces memory footprint
 

11. We use Unity It made me feel Unity The memory you eat won't spit out . It actually spits out , But the conditions are hardly met , want 6 Time GC You will not return until you have accessed it . Therefore, in the project, it is still calculated as if you can't spit out after eating . Because its memory structure is not compact , So the sequence of loading and unloading resources is very important .

For example, I now uninstall 2 individual 5MB Resources for , It is not continuous in the memory area , At this time, I want to load a 8MB Resources for . I'm sorry , this 2 individual 5MB Can not meet this condition , So an extra one will be created 8MB To store this resource , This leads to waste .

But if the memory area is unloaded at this time 10MB Resources for , So this 8MB Our resources will be crammed in . There is no extra waste .

In view of this , Projects can first unload resources that occupy a large amount of memory , Then load small resources instead of vice versa .

12. About closures and anonymous functions , During the operation period, there will be new A new object comes out , Do not release until the object is released . Cause some unexpected waste .

原网站

版权声明
本文为[Thunder Gazi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202220504086999.html