U3D包大小優化之microlib

當邇想把最小類庫發上來,邇須要把Stripping Level設置爲Use micro mscorlibhtml

這裏是MICROLIB所能使用的包的類庫列表:http://docs.unity3d.com/410/Documentation/ScriptReference/MonoCompatibility.htmlapp

 

 

但若是邇不想手動去對着這個列表,邇能夠從U3D編譯器查看相應提示信息,邇即可以經過提示而找出是哪些代碼出錯了。ui

一、最早作的應該是檢測DLL庫,能夠空建一個項目,把須要檢查的包打進去,而後使用use micro mscorlib來編譯,報錯的話邇就只能把相應DLL刪除或者替換了。spa

二、而後即是檢測代碼是否含有部分未被容許使用的代碼了,3d

UnityException: Failed assemblies stripper: /Applications/Unity4.3.4/Unity.app/Contents/Frameworks/Mono/bin/mono "/Applications/Unity4.3.4/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/UnusedBytecodeStripper.exe" -l none -c link -a "Assembly-CSharp-firstpass.dll" -a "Assembly-CSharp.dll" -a "Assembly-UnityScript.dll" -out output -x "/Applications/Unity4.3.4/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/link.xml" -d "Temp/StagingArea/Data/Managed" -x "tmplink.xml" current dir : Temp/StagingArea/Data/Managed result file exists: False stdout: stderr: Unhandled Exception: Mono.Linker.ResolutionException: Can not resolve reference: System.Void System.Security.SecurityException::.ctor(System.String) at Mono.Linker.Steps.MarkStep.MarkMethod (Mono.Cecil.MethodReference reference, System.Object markedby) [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction, Mono.Cecil.MethodDefinition markedby) [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.Process () [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0   at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0   at UnusedBytecodeStripper.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 UnityEditor.MonoProcessUtility.RunMonoProcess (System.Diagnostics.Process process, System.String name, System.String resultingFile) UnityEditor.MonoAssemblyStripping.MonoLink (BuildTarget buildTarget, System.String managedLibrariesDirectory, System.String[] input, System.String[] allAssemblies, UnityEditor.RuntimeClassRegistry usedClasses) UnityEditor.HostView:OnGUI()

若是打包時發現錯誤,邇能夠查看stderr那一行,這一句Can not resolve reference: System.Void System.Security.SecurityException即是指明瞭有哪些因爲microlib未有包含而報錯的。運氣好的話邇直接搜索源代碼哪裏調用這句即可以知道是哪裏出問題了,若是運氣很差的話像這個SecurityException,便會是其它的方法引起這個錯誤,好比是Socket.Connect的方法,這種狀況只能經過報錯的類型去用排除法推斷是哪裏出了問題了。code

相關文章
相關標籤/搜索