我完全被困住了。我的统一游戏在编辑器中运行良好,但在 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)
所以因为这是一个类型初始化问题,所以我怀疑代码剥离有问题。但我根本不懂代码剥离,这种预感只是基于我阅读的一些论坛帖子。
任何想法都会非常有帮助。我被困住了。