- After the Assetbundle is loaded, the initialization of the asset is not immediately unload (). Otherwise the initialization of the asset will be problematic and the dependency will be missing. Need to wait for 1, 2 seconds and then unload (). Because instantiate () also has a delay, although it can immediately return a Gameobject object.
- Static batch works only on statically-placed objects that are pre-set in the scene. Objects that are loaded at run time may be invalidated. You can call Staticbatchingutility.combine (Gameobject root) and manually trigger static Batch.
- The UV information for the light map is stored on the Uv2 property of the mesh, which is a vector2[]. In the Model import option, these UV information is automatically generated if the Generate Lightmap Uvs are checked. However, these Uvs are lost when the model is packaged into Assetbundle. Can be manually logged using a configuration file. When these models are loaded, they are then restored by code.
- The name of the model (Gameobject.name) and its mesh name (GameObject.renderer.mesh.name) are not the same.
- Assetbundle packaged particles may lose shader. Just add the possible shader to the list of Edit->project settings->graphics->always Included shaders in a packaged project.
- the resources in the Assetbundle will disappear from memory as the Assetbundle unloads.
It's a disgusting question. Consider a situation where you have 3 assetbundle:a saved prefab,b save mesh,c Save texture and material. Dependencies are a->b->c. Then you load into the c,b,a, then prefab A to instantiate one, you will get a complete gameobject. At this time, you think these three assetbundle not to unload it. After unloading, you find that mesh,texture,material is gone. Because the resources in the b,c are all dependent, but unloading the lack is not considered. But if you will b,c things also instantiate each, the dependence on the relationship is gone, can only add themselves.
Therefore, it is advisable to make a assetbundle of related resources. So the dependency is stable. Or you maintain a dependency on your own. It's not a good thing you're pointing at unity.
- Do not pass the variable of the loop iteration into the closure function in the loop. Because iteration variables are overwritten by loops. You can create a local variable within a loop to store the variable. Because the mechanism by which closures use external parameters is essentially a record of memory addresses. This error is easily encountered when you cycle through the initialization of some resources and can be obtained at callback.
- In the editor mode, after you modify the contents of the resources directory, you need to Assetdatabase.refresh () before you can use Resources.load () to read the contents into it.
- Resources that are read through Assetbundle, such as through load (), Loadall (), and Mainasset, are not destroy. When Assetbundle is unloaded, it is refactored together. It is better to instantiate () out first and then use it. Texture2d, mesh Such resources, you need to select Read/write Enabled in the import option.
- Some gameobject if they are held by Monobehavior variables (arrays, list,dictionary, etc.), they must be manually refactored at OnDestroy (). Failure to do so will result in a memory leak.
Unity's resource load as well as some pits of assetbundle