说明:
摘录unity官方文档中值得注意的细节
1.Reducing the file size of your build
Unity strips most unused Assets during the build, so you don’t gain anything by manually removing Assets from the Project. The only Assets that are not removed are scripts (which are generally very small anyway) and Assets in the Resources folder (because Unity can’t determine which of these are needed and which are not). With this in mind, you should make sure that the only Assets in the Resources folder are the ones you need for the game. You might be able to replace Assets in the Resources folder with AssetBundles - this means that Unity loads Assets dynamically, thereby reducing the player size.
注意resource文件夹和script脚本,其他的资源unity打包的时候会自动处理是否包含进包内
'most unused asset':自定义的shader文件打包的时候不会自动包含进去,需要在graphic setting里包含
2.Publishing Builds:Preloading
Published builds automatically preload all assets in a scene when the scene loads. The exception to this rule is scene 0. This is because the first scene is usually a splashscreen, which you want to display as quickly as possible.
To make sure all your content is preloaded, you can create an empty scene which calls Application.LoadLevel(1). In the build settings make this empty scene’s index 0. All subsequent levels will be preloaded.
unity中的场景除了第一个scene不会预先加载资源,其他都可以,所以建议第一个scene为空
当加载一个scene的时候,会预先加载这个scene里的资源(好假,你是怎么知道我下一个要加载哪个scene,unity大哥)!
3.Sorting Group
To use the Sorting Group component, add it to the GameObject’s root (the parent GameObject of all the GameObjects you want to apply group sorting to). Select the GameObject’s root, then in the main menu select Component > Rendering > Sorting Group.
Property Function | |
---|---|
Sorting Layer | Use the drop-down to select the Layer used to define this Sprite’s overlay priority during rendering. |
Order in Layer | Set the overlay priority of this Sprite within its layer. Lower numbers are rendered first, and subsequent numbers overlay those below. |
只适用于Spriter(二哈歪舌头)
4.Execution Order of Event Functions:
Script Lifecycle Flowchart:
unity框架MonoBehaviour所有可执行的接口.