你在编辑器里,每次修改、保存的时候就会自动编译(unity是监视Asset文件改动的)
移动平台的话,感觉是载入场景的时候,按需编译、加载的,不过不是十分确定
Unity - Scripting API: 这个文档里有一些说明:Usually graphics drivers do not actually prepare shaders until they are first needed. However when some object is first rendered with a previously unused shader, there can be a hiccup because the driver is compiling/optimizing the shader. This can be quite noticeable, especially on mobile platforms.