显然,AWS Gamelift API 使用反射或某种机制导致 Unity 编译器过度积极地剥离所需的程序集。因此,您只能使用允许关闭剥离的 Mono 编译器。IL2CPP 没有类似的选项。对于 IL2CPP,您可以通过 link.xml 文件 (\Assets\link.xml) 中的条目来控制剥离。到目前为止,我还没有成功使用 link.xml 方法。
在 link.xml 中使用下面的条目后,可以防止一些异常,但此异常仍然存在。
2020-03-16 12:12:14.622 13883-13898/com.company.app E/Unity: NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <0000000000000000000000000000000> :0 在 Amazon.AWSConfigs.GetConfig (System.String 名称) [0x00000] 在 <000000000000000000000000000000000>:0 在 Amazon.AWSConfigs..cctor () [0x00000] 在 <000000000000000000000000000000000>:0 在 Amazon. () [0x00000] in <0000000000000000000000000000000000>:0 在 Amazon.GameLift.AmazonGameLiftConfig..ctor () [0x00000] 在 <000000000000000000000000000000000>:0 在 Amazon.GameLift.AmazonGameLiftKeyIdClient..ctor , Amazon.RegionEndpoint 区域)[0x00000] in <0000000000000000000000000000000000>:0 在 GameLiftClient.GetConnectionInfo (System.String& ip, System.Int32& 端口, System.String& playerSessionId) [0x00000] 在 <0000000000000000000000000000000000000000000000>:0 在 System.ip, System.&Int32. 端口细绳
链接.xml
<linker>
<assembly fullname="UnityEngine">
<type fullname="UnityEngine.Networking.UnityWebRequest" preserve="all" />
<type fullname="UnityEngine.Networking.UploadHandlerRaw" preserve="all" />
<type fullname="UnityEngine.Networking.UploadHandler" preserve="all" />
<type fullname="UnityEngine.Networking.DownloadHandler" preserve="all" />
<type fullname="UnityEngine.Networking.DownloadHandlerBuffer" preserve="all" />
</assembly>
<assembly fullname="mscorlib">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="System">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.Core" preserve="all"/>
<assembly fullname="AWSSDK.CognitoIdentity" preserve="all"/>
<assembly fullname="AWSSDK.CognitoSync" preserve="all"/>
<assembly fullname="AWSSDK.DynamoDBv2" preserve="all"/>
<assembly fullname="AWSSDK.Kinesis" preserve="all"/>
<assembly fullname="AWSSDK.KinesisFirehose" preserve="all"/>
<assembly fullname="AWSSDK.Lambda" preserve="all"/>
<assembly fullname="AWSSDK.MobileAnalytics" preserve="all"/>
<assembly fullname="AWSSDK.S3" preserve="all"/>
<assembly fullname="AWSSDK.SecurityToken" preserve="all"/>
<assembly fullname="AWSSDK.SimpleEmail" preserve="all"/>
<assembly fullname="AWSSDK.SimpleNotificationService" preserve="all"/>
<assembly fullname="AWSSDK.SQS" preserve="all"/>
<assembly fullname="AWSSDK.IdentityManagement" preserve="all"/>
<assembly fullname="AWSSDK.GameLift" preserve="all"/>
<assembly fullname="System.Configuration" preserve="all"/>
<assembly fullname="System.SecurityUtils" preserve="all"/>
<assembly fullname="System.ComponentModel" preserve="all"/>
<assembly fullname="System.Activator" preserve="all"/>
<assembly fullname="System.RuntimeType" preserve="all"/>
</linker>
无论如何,使用 link.xml 或其他机制来禁用 Unity 中的程序集剥离,以便可以使用 IL2CPP 编译器?