What 's wrong?

Posted: 09 Jun 2022 11:20
by SgKSFsSCBI9XpfJ

I use

Code: Select all

var scriptPlayer = Engine.GetService<IScriptPlayer>();
        scriptPlayer.PreloadAndPlayAsync(filename).Forget();

What is puzzling is that it was right before.I didn't change anything but it suddenly threw an exception.

System.NullReferenceException: Object reference not set to an instance of an object
at Naninovel.ScriptPlaylist+<>cDisplayClass9_0.<GetCommandAfterLine>b0 (Naninovel.Command a) [0x00000] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\ScriptPlayer\ScriptPlaylist.cs:113
at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func2[T,TResult] predicate, System.Boolean& found) [0x0003f] in <1e18c5a6594041c9844bfd0b6618ee4a>:0
at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func2[T,TResult] predicate) [0x00000] in <1e18c5a6594041c9844bfd0b6618ee4a>:0
at Naninovel.ScriptPlaylist.GetCommandAfterLine (System.Int32 lineIndex, System.Int32 inlineIndex) [0x00014] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\ScriptPlayer\ScriptPlaylist.cs:113
at Naninovel.ScriptPlayer.PreloadAndPlayAsync (Naninovel.Script script, System.Int32 startLineIndex, System.Int32 startInlineIndex, System.String label) [0x000da] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\ScriptPlayer\ScriptPlayer.cs:334
at Naninovel.UniTaskCompletionSource.Naninovel.Async.IAwaiter.GetResult () [0x0001f] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskCompletionSource.cs:89
at Naninovel.UniTask.GetResult () [0x00001] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:46
at Naninovel.UniTask+Awaiter.GetResult () [0x00000] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:213
at Naninovel.ScriptPlayerExtensions.PreloadAndPlayAsync (Naninovel.IScriptPlayer scriptPlayer, System.String scriptName, System.Int32 startLineIndex, System.Int32 startInlineIndex, System.String label) [0x000f7] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\ScriptPlayer\ScriptPlayerExtensions.cs:25
at Naninovel.UniTaskCompletionSource.Naninovel.Async.IAwaiter.GetResult () [0x0001f] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskCompletionSource.cs:89
at Naninovel.UniTask.GetResult () [0x00001] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:46
at Naninovel.UniTask+Awaiter.GetResult () [0x00000] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:213
at Naninovel.UniTaskExtensions.ForgetCore (Naninovel.UniTask task) [0x0001b] in E:\dungeons\trunk\soft\client\Assets\Unity3D_Plugins\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskExtensions.cs:195
UnityEngine.Debug:LogError (object)
Naninovel.Async.UniTaskScheduler:PublishUnobservedTaskException (System.Exception) (at Assets/Unity3D_Plugins/Naninovel/Runtime/Common/Async/UniTask/UniTaskScheduler.cs:65)
Naninovel.Async.CompilerServices.AsyncUniTaskVoidMethodBuilder:SetException (System.Exception) (at Assets/Unity3D_Plugins/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs:29)
Naninovel.UniTaskExtensions/<ForgetCore>d11:MoveNext () (at Assets/Unity3D_Plugins/Naninovel/Runtime/Common/Async/UniTask/Public/UniTaskExtensions.cs:195)
Naninovel.Async.CompilerServices.AsyncUniTaskVoidMethodBuilder:Start<Naninovel.UniTaskExtensions/<ForgetCore>d
11> (Naninovel.UniTaskExtensions/<ForgetCore>d11&) (at Assets/Unity3D_Plugins/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs:77)
Naninovel.UniTaskExtensions:ForgetCore (Naninovel.UniTask)
Naninovel.UniTaskExtensions:Forget (Naninovel.UniTask) (at Assets/Unity3D_Plugins/Naninovel/Runtime/Common/Async/UniTask/Public/UniTaskExtensions.cs:177)
NaninovelManager/<talk>d
3:MoveNext () (at Assets/script/Naninovel/NaninovelManager.cs:46)
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start<NaninovelManager/<talk>d3> (NaninovelManager/<talk>d3&)
NaninovelManager:talk (string)

Can anyone help me?
Thank you


Re: What 's wrong?

Posted: 09 Jun 2022 21:40
by idaot

This is a common error for when there is a cache conflict somewhere so I suggest reimporting the connected assets. I'd also try awaiting instead of using Forget(), as while I don't know the exact extent of when Forget() can/cannot be used, there is no example in the codebase where this is used on PreloadAndPlayAsync().