文章主要总结了在Unity3d生成Xcode工程的过程中遇到的问题,希望对遇到问题的小伙伴有帮助。
Failed to load package manager
- 错误描述
Failed to load package manager
UnityEditor.HostView:OnGUI() - 原因分析
主要是Unity破解的时候,license使用的不正确。
例如,下载的Unity版本是5.2.4,但是使用了5.2.3的license。如果在电脑上使用没有问题。但是当打包的时候就会出错。 - 参考文档
Failed to load package manager
DXT3 compressed textures are not supported when publishing to iPhone
- 错误描述
DXT3 compressed textures are not supported when publishing to iPhone
Assets/SceneLevel/Model/xuedi/Materials/xd_toushiche.dds
Included from scene:
UnityEditor.HostView:OnGUI() - 原因分析
主要是由于Iphone不支持DDS造成的。 - 参考文档
`xlv_TEXCOORD2’ redeclared
- 错误描述
Shader error in ‘Particles/Additive(clipping)’: `xlv_TEXCOORD2’ redeclared at line 80 (on metal) - 原因分析
在shader中进行了重复定义。
出现此问题的shader为 Particle Add Clipping.shader
主要问题在于以下代码
主要由于在IOS设备上,支持 SOFTPARTICLES_ON,所以导致了重复定义。#ifdef SOFTPARTICLES_ON float4 projPos : TEXCOORD2; #endif //------------------add--------------------------------- float3 vpos:TEXCOORD2; //------------------add---------------------------------
System.Web.Extensions.dll could not be loaded
错误描述
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18Failed running /Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper2/UnusedBytecodeStripper2.exe -out
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
The following assembly referenced from /Users/r1/Documents/client/Assets/Plugins/System.Web.Extensions.dll could not be loaded:
Assembly: System.Web(assemblyref_index=2)
Version:2.0.0.0
Public Key: b03f5f7f11d50a3a
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/Users/r1/Documents/client/Assets/Plugins/).
Could not load file or assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Missing method .ctor in assembly /Users/r1/Documents/client/Assets/Plugins/System.Web.Extensions.dll, type System.Web.UI.WebResourceAttribute
Can't find custom attr constructor image: /Users/r1/Documents/client/Assets/Plugins/System.Web.Extensions.dll mtoken: 0x0a000011原因分析
The following assembly referenced from /Users/r1/Documents/client/Assets/Plugins/System.Web.Extensions.dll
报错原因是在plugin中有个dll被应用,但是目前不支持web。
当在编辑器中转换平台之后,就不会报这个错误了。
也就是并不需要必须将这个System.Web.Extensions.dll 删除
Mono.Cecil.ResolutionException: Failed to resolve System.Web.AspNetHostingPermissionLevel
- 错误描述
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23Failed running /Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper2/UnusedBytecodeStripper2.exe
-out "/Users/r1/Documents/client/Temp/StagingArea/Data/Managed/tempStrip"
-l none -c link
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/native_link.xml"
-f "/Applications/Unity/Unity.app/Contents/Frameworks/il2cpp/LinkerDescriptors"
-x "/Users/r1/Documents/client/Temp/StagingArea/Data/Managed/../platform_native_link.xml"
-x "/Users/r1/Documents/client/Temp/StagingArea/Data/methods_pointedto_by_uievents.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/Animation.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/Audio.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/IMGUI.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/Physics.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/Physics2D.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/TextRendering.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/UI.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStrippernk.xml"
-x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedByteCodeStripper/native_link.xml"
-x "/Users/r1/Documents/client/Assets/Scripts/AStarScriptnk.xml"
-d "/Users/r1/Documents/client/Temp/StagingArea/Data/Managed"
-a "/Users/r1/Documents/client/Temp/StagingArea/Data/Managed/Assembly-CSharp-firstpass.dll"
-a "/Users/r1/Documents/client/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll"
-a "/Users/r1/Documents/client/Temp/StagingArea/Data/Managed/Assembly-UnityScript-firstpass.dll"
-a "/Users/r1/Documents/client/Temp/StagingArea/Data/Managed/Assembly-UnityScript.dll"
-a "/Users/r1/Documents/client/Temp/StagingArea/Data/Managed/UnityEngine.UI.dll"
1 | stdout: |
原因分析
- 主要问题在于“Mono.Cecil.ResolutionException: Failed to resolve System.Web.AspNetHostingPermissionLevel”
这个问题在于,程序中需要用到“System.Web.AspNetHostingPermissionLevel” 这个类,但是当前的Spripting Backend 与 Stripping Level 决定了这个类会被剥离。
那我们要做的就是要对其进行保护,在编译成C++的时候,不对他进行剥离操作。
所以在我们link.xml中设置对其进行保护。 - 为什么IOS要这么设置呢?
在android平台下,Spripting Backend设置为Mono2x,Stripping Level设置为Disable,Api Compatiblity Level设置为.NET 2.0。也就是说android平台下使用了整个.NET2.0框架中的类,并且没有做任何剥离操作。
但是在ios平台下,Spripting Backend设置为IL2CPP,这种编译形式相当于Stripping Level设置为Strip Byte Code。这种剥离等级下,就会将“System.Web.AspNetHostingPermissionLevel”进行剥离,所以我们要在link.xml中对其进行保护。
- 主要问题在于“Mono.Cecil.ResolutionException: Failed to resolve System.Web.AspNetHostingPermissionLevel”
参考文档
- 开始怀疑是dll出现问题,参考 删除对应dll来解决。
但是经过测试dll没有问题,所以此中解决办法搁置。 - 这个涉及到IL2CPP的概念。参考 什么是IL2CPP
- 怎么理解剥离力度。参考 Unity3D占用内存太大的解决方法
- 怎么理解link.xml 什么是link.xml
- 参考 Please help for IL2CPP problem
- 参考 官方文档
- NET2.0与NET2.0 sub Mono Compatibility
- 开始怀疑是dll出现问题,参考 删除对应dll来解决。
IOS贴图解决
- 问题描述
打包iOS之后,多个图集中的图片错位,显示模糊。 - 原因分析
说明一:
首先IOS压缩的方式为 RGBA Compressed PVRET 4 bits。但是前提要求是压缩的图集的宽高比是1,也就是为正方形。
“纹理在导入时将被缩放到最近的幂大小。例如257x511纹理将成为256x512。请注意,PVRTC格式要求纹理是正方形(宽度与高度相等),因此最终大小将变换到512x512。 PVRTC是一种有损的纹理压缩技术,主要用于iPhone,iPod touch和iPad。”
所以如果要使用PVRET压缩方式的话,只能将图集打成正方形的。
在iOS平台下,默认的压缩格式也是这个格式。
说明二:
当使用 RGBA Compressed PVRET 4 bits 压缩方式的话,会发现图片失真。
最优的解决方案是出将一张图拆分为两张图,一张只带有RGB信息,一张带有alpha通道信息。
因为带有alpha通道的这张图包含的信息较少,所以可以将这张图进行压缩。这样既能够减少包体大小,也能够减少占用的内存。
说明三
现在android平台下用到的压缩格式为 RGBA Compressed ETC2 8 bits。
如果单纯带有纯透明的通道的图片,可以选择 RGB + 1-bit Alpha Compressed ETC2 4 bits。
这种压缩模式能够让图片的大小缩小一半。 - 参考文档
- To nearest 到最近的
- 所以最解决方案是:如果现在的图集是正方形的,则使用ios的格式进行压缩(默认已经用这种格式压缩)。
如果图集不是正方形的,则目前先不对其进行压缩处理。
一些非图集的Texture,则选择To nearest进行压缩。Only POT texture can be compressed to PVRTC format - Sprite (2D and UI)
- 移动设备的纹理压缩方案
there are no graphs in the scene
问题描述
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15Caught exception while deserializing data.
System.MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.ComponentModel.UInt32Converter'.
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0
at System.Activator.CreateInstance (System.Type type) [0x00000] in :0
at System.ComponentModel.TypeDescriptor.GetConverter (System.Type type) [0x00000] in :0
at Pathfinding.Serialization.JsonFx.TypeCoercionUtility.CoerceType (System.Type targetType, System.Object value) [0x00000] in :0
at Pathfinding.Serialization.JsonFx.JsonReader.ReadNumber (System.Type expectedType) [0x00000] in :0
at Pathfinding.Serialization.JsonFx.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0
at Pathfinding.Serialization.JsonFx.JsonReader.PopulateObject (System.Object& result, System.Type objectType, System.Collections.Generic.Dictionary`2 memberMap, System.Type genericDictionaryType) [0x00000] in :0
at Pathfinding.Serialization.JsonFx.JsonReader.PopulateObject (System.Object& obj) [0x00000] in :0
at Pathfinding.Serialization.JsonFx.JsonReader.PopulateObject[NavGraph] (Pathfinding.NavGraph& obj) [0x00000] in :0
at Pathfinding.Serialization.AstarSerializer.DeserializeGraphs () [0x00000] in :0
at Pathfinding.AstarData.DeserializeGraphsPart (Pathfinding.Serialization.AstarSerializer sr) [0x00000] in :0
at Pathfinding.AstarData.DeserializeGraphs (System.Byte[] bytes) [0x00000] in :0
(Filename: /Applications/buildAgent/work/aeedb04a1292f85a/artifacts/iPhonePlayer-armv7Generated/UnityEngineDebug.cpp Line: 49)原因分析
“System.ComponentModel.UInt32Converter”在ios当前的编译方式与打包等级的情况下,被剥离了。所以也要在link.xml中对其进行保护- 参考文档