获取 重置周期 为不限 的leaderboard 报错

我用的是 Unity的 sdk。 当获取 AVLeaderboard时,如果leaderboard设置为 不重置,会报错。但如果把重置改为每周/天/月,就不报错。

challengeModeHistoryLeaderboard = await AVLeaderboard.GetLeaderboard(kChallengeModeHistoryStatisticName_Score);

报错log:

AVEXCEPTION: LeanCloud.AVException: Object reference not set to an instance of an object
at LeanCloud.AVLeaderboard+<>c.b__43_0 (System.Threading.Tasks.Task1[TResult] t) [0x00022] in <c6b28e5de1c34c4fb8a4988a57f6d4ef>:0
at LeanCloud.Storage.Internal.InternalExtensions+<>c__DisplayClass5_0
2[TIn,TResult].b__0 (System.Threading.Tasks.Task t) [0x00000] in <6f50b7c221814d36ac76e75fb0137036>:0
at LeanCloud.Storage.Internal.InternalExtensions+<>c__DisplayClass7_01[TResult].<OnSuccess>b__0 (System.Threading.Tasks.Task t) [0x0006d] in <6f50b7c221814d36ac76e75fb0137036>:0
at System.Threading.Tasks.ContinuationResultTaskFromTask
1[TResult].InnerInvoke () [0x00024] in <9577ac7a62ef43179789031239ba8798>:0
at System.Threading.Tasks.Task.Execute () [0x00010] in <9577ac7a62ef43179789031239ba8798>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0
at EWLeanCloudManager+<GetChallengeModeScoreHistoryLeaderboard>d__59.MoveNext () [0x00035] in D:\P4\globe\Assets\EarthWiki\Scripts\EWLeanCloudManager.cs:748
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter
1[TResult].GetResult () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0
at EWLeanCloudManager+d__57.MoveNext () [0x0005f] in D:\P4\globe\Assets\EarthWiki\Scripts\EWLeanCloudManager.cs:699
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0
at EWMainSceneMenuManager+d__194.MoveNext () [0x001f8] in D:\P4\globe\Assets\EarthWiki\Scripts\UI\EWMainSceneMenuManager.cs:4083
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <9577ac7a62ef43179789031239ba8798>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0
at EWMainSceneMenuManager+d__196.MoveNext () [0x00351] in D:\P4\globe\Assets\EarthWiki\Scripts\UI\EWMainSceneMenuManager.cs:4242

我知道你们发布了最新的 Csharp版 sdk,我还没试过是否有这个问题。

不过我上次尝试c sharp版发现貌似本地无法记录登录状态。下次开启应用又要重新登陆。

感谢反馈,旧版 SDK 确实存在一个反序列化的 bug 导致的,稍后会修复并更新。
(新版测试是正常的,建议如果是新项目,请使用新版 SDK)

这里是这样设计的,因为 SDK 目前没有任何平台相关的代码,具体做法就是保存好 session token,每次启动应用时使用 token 登录即可,参考
后面如果有需求,会考虑通过插件的方式额外支持 Unity 平台的。
感谢关注!

感谢回复。我刚刚也重新改用了新版的Csharp sdk,不重置 leaderboard是没问题的。

另外,我刚刚也意识到了得保存本地的session token。正要做呢,结果发现您回帖了,看来我想的也是对的。

感谢你们的快速回复。

建议还是使用新版 SDK,有问题欢迎发帖。

旧版 SDK 也修复了这个问题,感谢反馈!