U3D包大小优化之microlib

当迩想把最小类库发上来,迩需要把Stripping Level设置为Use micro mscorlib

这里是MICROLIB所能使用的包的类库列表:http://docs.unity3d.com/410/Documentation/ScriptReference/MonoCompatibility.html

 

 

但如果迩不想手动去对着这个列表,迩可以从U3D编译器查看相应提示信息,迩便可以通过提示而找出是哪些代码出错了。

1、最先做的应该是检测DLL库,可以空建一个项目,把需要检查的包打进去,然后使用use micro mscorlib来编译,报错的话迩就只能把相应DLL删除或者替换了。

2、然后便是检测代码是否含有部分未被允许使用的代码了,

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的方法,这种情况只能通过报错的类型去用排除法推断是哪里出了问题了。

posted @ 2014-08-07 11:36  klobodnf  阅读(...)  评论(...编辑  收藏