1

我完全被困住了。我的统一游戏在编辑器中运行良好,但在 IOS 上启动时崩溃。我正在将 AWS Gamelift 用于多人游戏,这可能是罪魁祸首,因为它在集成之前构建良好。对于实际的网络代码,我使用的是新的统一 DOTS 网络代码包。

在我的插件文件夹中,我为客户端提供了以下 dll。

  • AWSSDK.CognitoIdentity
  • AWSSDK.CognitoIdentityProvider
  • AWSSDK.CognitoSync
  • AWSSDK.Core
  • AWSSDK.Extensions.CognitoAuthentication
  • AWSSDK.Gamelift
  • AWSSDK.Lambda
  • AWSSDK.SecurityToken
  • Microsoft.Bcl.AsyncInterfaces
  • System.Threading.Tasks.Extensions
  • log4net

在编辑器中,一切运行完美。我可以连接到 GameLift,创建游戏会话等。当我构建时,它成功完成,但在启动时崩溃,显示带有天空盒的空场景,并在 Xcode 控制台中出现以下错误:

... some other outputs for initialization...

NotSupportedException: System.Web.UI.WebResourceAttribute::set_CdnSupportsSecureConnection
  at System.Web.UI.WebResourceAttribute.set_CdnSupportsSecureConnection (System.Boolean value) [0x00000] in <00000000000000000000000000000000>:0 
  at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00000] in <00000000000000000000000000000000>:0 
  at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Attribute.GetCustomAttributes (System.Reflection.Assembly element, System.Type attributeType, System.Boolean inherit) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Reflection.CustomAttributeExtensions.GetCustomAttributes[T] (System.Reflection.Assembly element) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.Entities.TypeManager.InitializeAllComponentTypes () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.Entities.TypeManager.Initialize () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.Entities.EntityGuid..cctor () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.Entities.World..ctor (System.String name, Unity.Entities.WorldFlags flags) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.Entities.DefaultWorldInitialization.Initialize (System.String defaultWorldName, System.Boolean editorWorld) [0x00000] in <00000000000000000000000000000000>:0 
 
(Filename: currently not available on il2cpp Line: -1)

ArgumentException: Unknown Type:`Unity.Entities.CompanionLink` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
  at Unity.Entities.TypeManager.ManagedException (System.Type type) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.Entities.TypeManager.GetTypeIndex (System.Type type) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.Entities.AttachToEntityClonerInjection.Initialize () [0x00000] in <00000000000000000000000000000000>:0 
Rethrow as TypeInitializationException: The type initializer for 'Unity.Entities.AttachToEntityClonerInjection' threw an exception.

 
(Filename: currently not available on il2cpp Line: -1)

[Subsystems] Loading plugin UnityARKit for subsystem ARKit-Input...
[Subsystems] UnityARKit successfully registered Provider for ARKit-Input
NullReferenceException: Object reference not set to an instance of an object.
  at Unity.NetCode.ConvertToClientServerEntity.Awake () [0x00000] in <00000000000000000000000000000000>:0 

... some other debug messages spamming null reference exceptions that seem to be related to the above errors...
 

我怀疑这与 IOS 构建的代码剥离有关。我的 link.xml 文件如下(基于谷歌搜索,不知道我在这里做什么)。

<?xml version="1.0" encoding="utf-8"?>

<linker>

    <assembly fullname="UnityEngine">
         <type fullname="UnityEngine.Experimental.Networking.UnityWebRequest" preserve="all" />
         <type fullname="UnityEngine.Experimental.Networking.UploadHandlerRaw" preserve="all" />
         <type fullname="UnityEngine.Experimental.Networking.UploadHandler" preserve="all" />
         <type fullname="UnityEngine.Experimental.Networking.DownloadHandler" preserve="all" />
         <type fullname="UnityEngine.Experimental.Networking.DownloadHandlerBuffer" preserve="all" />
     </assembly>
    
    <assembly fullname="log4net"/>
    <assembly fullname="Google.Protobuf"/>
    <assembly fullname="System.Runtime.CompilerServices.Unsafe"/>
    <assembly fullname="websocket-sharp"/>
    
    <assembly fullname="AWSSDK.Core" preserve="all">
        <type fullname ="Amazon.*" preserve = "all" />
          <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
    
      <assembly fullname="AWSSDK.CognitoIdentity" preserve="all">
          <type fullname ="Amazon.*" preserve = "all" />
          <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
      <assembly fullname="AWSSDK.CognitoIdentityProvider" preserve="all">
          <type fullname ="Amazon.*" preserve = "all" />
          <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
      <assembly fullname="AWSSDK.CognitoSync" preserve="all">
        <type fullname ="Amazon.*" preserve = "all" />
        <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
      <assembly fullname="AWSSDK.IdentityManagement" preserve="all">
        <type fullname ="Amazon.*" preserve = "all" />
        <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
      <assembly fullname="AWSSDK.SecurityToken" preserve="all">
        <type fullname ="Amazon.*" preserve = "all" />
        <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
      <assembly fullname="AWSSDK.DynamoDBv2" preserve="all">
        <type fullname ="Amazon.*" preserve = "all" />
        <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
      <assembly fullname="AWSSDK.Lambda" preserve="all">
        <type fullname ="Amazon.*" preserve = "all" />
        <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
      <assembly fullname="AWSSDK.Extensions.CognitoAuthentication" preserve="all">
        <type fullname ="Amazon.*" preserve = "all" />
        <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
      
      <assembly fullname="AWSSDK.GameLift" preserve="all">
        <type fullname ="Amazon.*" preserve = "all" />
        <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
      </assembly>
      
</linker>

奇怪的是,如果我删除保留 log4net.dll 的行,我可以启动程序。

但是,这样做之后,当我单击登录 gamelift 按钮时,我收到一个不同的错误,似乎缺少与 log4net 相关的内容。(我在注册和其他事情上遇到同样的错误)。奇怪的是程序启动并运行良好,直到我尝试使用gamelift。

这是 Xcode 中的不同错误。这是我尝试连接到 Cognito 登录后出现的唯一内容。

NullReferenceException: Object reference not set to an instance of an object.
  at Amazon.Runtime.Internal.Util.InternalLog4netLogger..ctor (System.Type declaringType) [0x00000] in <00000000000000000000000000000000>:0 
  at Amazon.Runtime.Internal.Util.Logger..ctor (System.Type type) [0x00000] in <00000000000000000000000000000000>:0 
  at Amazon.Runtime.Internal.Util.Logger.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0 
  at Amazon.Runtime.Internal.EnvironmentVariableInternalConfiguration..ctor () [0x00000] in <00000000000000000000000000000000>:0 
  at Amazon.Runtime.Internal.FallbackInternalConfigurationFactory.Reset () [0x00000] in <00000000000000000000000000000000>:0 
  at Amazon.Runtime.ClientConfig.get_RetryMode () [0x00000] in <00000000000000000000000000000000>:0 
  at Amazon.Runtime.AmazonServiceClient.BuildRuntimePipeline () [0x00000] in <00000000000000000000000000000000>:0 
  at SignInManager+<TrySignIn>d__10.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskCache.CreateCacheableTask[TResult] (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at SignInManager.TrySignIn (EmailAddress email, Password password, LoginEvents+SignInCallback callback) [0x00000] in <00000000000000000000000000000000>:0 
  at LoginEvents+SignInEvent.Invoke (EmailAddress email, Password password, LoginEvents+SignInCallback callback) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventCallback`1[TEventType].Invoke (TEventType evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.UIElements.EventBase evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.PointerEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventSystem.SendPositionBasedEvent[TArg] (UnityEngine.Vector3 mousePosition, UnityEngine.Vector3 delta, System.Func`4[T1,T2,T3,TResult] evtFactory, TArg arg) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventSystem.SendIMGUIEvents () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventSystem.Update () [0x00000] in <00000000000000000000000000000000>:0 
Rethrow as TypeInitializationException: The type initializer for 'Amazon.Runtime.Internal.FallbackInternalConfigurationFactory' threw an exception.
  at Amazon.Runtime.ClientConfig.get_RetryMode () [0x00000] in <00000000000000000000000000000000>:0 
  at Amazon.Runtime.AmazonServiceClient.BuildRuntimePipeline () [0x00000] in <00000000000000000000000000000000>:0 
  at SignInManager+<TrySignIn>d__10.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskCache.CreateCacheableTask[TResult] (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at SignInManager.TrySignIn (EmailAddress email, Password password, LoginEvents+SignInCallback callback) [0x00000] in <00000000000000000000000000000000>:0 
  at LoginEvents+SignInEvent.Invoke (EmailAddress email, Password password, LoginEvents+SignInCallback callback) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventCallback`1[TEventType].Invoke (TEventType evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.UIElements.EventBase evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.PointerEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventSystem.SendPositionBasedEvent[TArg] (UnityEngine.Vector3 mousePosition, UnityEngine.Vector3 delta, System.Func`4[T1,T2,T3,TResult] evtFactory, TArg arg) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventSystem.SendIMGUIEvents () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UIElements.EventSystem.Update () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.SendOrPostCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.UnitySynchronizationContext:Exec()
UnityEngine.UnitySynchronizationContext:Exec()
 
(Filename: currently not available on il2cpp Line: -1)

所以因为这是一个类型初始化问题,所以我怀疑代码剥离有问题。但我根本不懂代码剥离,这种预感只是基于我阅读的一些论坛帖子。

任何想法都会非常有帮助。我被困住了。

4

1 回答 1

0

我设法解决了这个问题,困难重重,工作了一周。这是我修复它的步骤。以防其他人将来有问题。

  1. 确保我已更新 AWS 开发工具包 dll。我在 Rider 中使用 nuget 获得了这些,然后将 netstandard2.0 dll 拖到 plugins 文件夹中。注意:非常仔细地查看 nuget 中列出的依赖项。我必须使用稍旧的 AWS SDK 版本才能与 cognitoAuthentification.dll 兼容。

这是骑手中的包裹的屏幕截图。软件包版本似乎很重要。仔细检查依赖关系。

在此处输入图像描述

  1. 使用 Amazon.Extensions.CognitoAuthentication.dll 而不是 AWSSDK.Extensions.CognitoAuthentication.dll

  2. 删除 link.xml 文件中的所有内容。仅包括以下条目:

     <linker>
     <assembly fullname="AWSSDK.Core">
         <type fullname="Amazon.Util.Internal.PlatformServices.NetworkReachability" preserve="all"/>
         <namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
     </assembly>
     </linker>
    
  3. 浏览所有其他插件,并一一检查排除 iOS。首先,检查它是否会破坏编辑器中的桌面播放。然后检查它是否破坏了 iOS 构建中的任何内容。我认为这可能是最重要的一步。

  4. 进入 unity editor.app 包内容,进入 monobleedingedge/unityjit/ 并将 Mono.Posix、System.Core、System.Configuration 拖到我的插件文件夹中。

请注意,每次我更改统一插件文件夹中的 dll 时,我都必须重新启动统一以消除控制台错误和无法重新加载脚本。

如果有人好奇,这是我的插件文件夹的屏幕截图

截屏

无论如何......真正的答案是这不是一个用户友好的系统。

于 2020-12-02T21:11:32.913 回答