Thanks for reply,
about the second problem with the inventory I'd forgot to put the inventory UI inside the project settings.
But concenrning my custom command C# class I don't understend what I'm wrong. this is the steps that I made:
1) I look into project folders and I found the others commands in Assets/Naninovel/Runtime/Command folder
2) I put in this folder a MultichoiseGenerator.cs blank file then I added this code to file
Code: Select all
using Naninovel;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
[CommandAlias("multichoise")]
public class MultichoiseGenerator : Command
{
public StringListParameter choises;
public StringListParameter scripts;
protected virtual ICustomVariableManager variableManager => Engine.GetService<ICustomVariableManager>();
protected virtual IScriptPlayer player => Engine.GetService<IScriptPlayer>();
public override async UniTask ExecuteAsync(AsyncToken asyncToken = default)
{
var variableManager = Engine.GetService<ICustomVariableManager>();
var player = Engine.GetService<IScriptPlayer>();
foreach (string choise in choises)
{
string[] choiseScriptArray = choise.Split('.');
Debug.Log(choiseScriptArray[0] + " "+ choiseScriptArray[1]);
variableManager.TrySetVariableValue("tmpChoiseLabel", choiseScriptArray[0]);
variableManager.TrySetVariableValue("tmpScriptName", choiseScriptArray[1]);
await player.PreloadAndPlayAsync("ChoiseLine");
}
await UniTask.CompletedTask;
//await player.PreloadAndPlayAsync("Stop");
/*
var aaa = new NamedString("Script001", "AfterStorm")
var Goto = new Goto { Path = aaa };
Goto.ExecuteAsync();
*/
}
}
3) i create the ChoiseLine.nani file and placed it into project /Scripts folder, I also added it to the script resources inside project settings -> naninovel -> scripts with this line of code
Code: Select all
# Choises
@choise {tmpChoiseLabel} goto:{tmpScriptName}
then I put tmpChoiseLabel and tmpScriptName into project settings -> naninovel ->custom variables adding to new line with these names
4) Into the Main.nani at the top of file I added these lines
Code: Select all
@printer Wide
@bgm Wind fade:1 wait:false
@multichoise choises:home.morningAtHome,office.work,school.homecoming scripts:teststring
@stop
5) while executin the game when it reach the line starting with @multichois i see in unity console my debug log, then i get the mentioned error, here the complete error string
Code: Select all
casa mattina
UnityEngine.Debug:Log (object)
System.NullReferenceException: Object reference not set to an instance of an object
at Naninovel.ScriptPlaylist+<>c__DisplayClass9_0.<GetCommandAfterLine>b__0 (Naninovel.Command a) [0x00000] in D:\\Demo-master\Assets\Naninovel\Runtime\ScriptPlayer\ScriptPlaylist.cs:111
at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate, System.Boolean& found) [0x0003f] in <d630687edd41403db17561f5afda04df>:0
at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00000] in <d630687edd41403db17561f5afda04df>:0
at Naninovel.ScriptPlaylist.GetCommandAfterLine (System.Int32 lineIndex, System.Int32 inlineIndex) [0x00014] in D:\Demo-master\Assets\Naninovel\Runtime\ScriptPlayer\ScriptPlaylist.cs:111
at Naninovel.ScriptPlayer.PreloadAndPlayAsync (Naninovel.Script script, System.Int32 startLineIndex, System.Int32 startInlineIndex, System.String label) [0x000bc] in D:\Demo-master\Assets\Naninovel\Runtime\ScriptPlayer\ScriptPlayer.cs:338
at Naninovel.UniTaskCompletionSource.Naninovel.Async.IAwaiter.GetResult () [0x00013] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskCompletionSource.cs:91
at Naninovel.UniTask.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:46
at Naninovel.UniTask+Awaiter.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:201
at Naninovel.ScriptPlayerExtensions.PreloadAndPlayAsync (Naninovel.IScriptPlayer scriptPlayer, System.String scriptName, System.Int32 startLineIndex, System.Int32 startInlineIndex, System.String label) [0x000c6] in D:\Demo-master\Assets\Naninovel\Runtime\ScriptPlayer\ScriptPlayerExtensions.cs:23
at Naninovel.UniTaskCompletionSource.Naninovel.Async.IAwaiter.GetResult () [0x00013] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskCompletionSource.cs:91
at Naninovel.UniTask.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:46
at Naninovel.UniTask+Awaiter.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:201
at MultichoiseGenerator.ExecuteAsync (Naninovel.AsyncToken asyncToken) [0x000ad] in D:\Demo-master\Assets\Runtime\MultichoiseGenerator.cs:26
at Naninovel.UniTaskCompletionSource.Naninovel.Async.IAwaiter.GetResult () [0x00013] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskCompletionSource.cs:91
at Naninovel.UniTask.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:46
at Naninovel.UniTask+Awaiter.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:201
at Naninovel.ScriptPlayer.ExecuteIgnoringCancellationAsync (Naninovel.Command command, Naninovel.AsyncToken asyncToken) [0x0002e] in D:\Demo-master\Assets\Naninovel\Runtime\ScriptPlayer\ScriptPlayer.cs:598
at Naninovel.UniTaskCompletionSource.Naninovel.Async.IAwaiter.GetResult () [0x00013] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskCompletionSource.cs:91
at Naninovel.UniTask.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:46
at Naninovel.UniTask+Awaiter.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:201
at Naninovel.ScriptPlayer.ExecutePlayedCommandAsync (Naninovel.AsyncToken asyncToken) [0x002b7] in D:\Demo-master\Assets\Naninovel\Runtime\ScriptPlayer\ScriptPlayer.cs:558
at Naninovel.UniTaskCompletionSource.Naninovel.Async.IAwaiter.GetResult () [0x00013] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskCompletionSource.cs:91
at Naninovel.UniTask.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:46
at Naninovel.UniTask+Awaiter.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:201
at Naninovel.ScriptPlayer.PlayRoutineAsync (Naninovel.AsyncToken asyncToken) [0x00227] in D:\Demo-master\Assets\Naninovel\Runtime\ScriptPlayer\ScriptPlayer.cs:622
at Naninovel.UniTaskCompletionSource.Naninovel.Async.IAwaiter.GetResult () [0x00013] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskCompletionSource.cs:91
at Naninovel.UniTask.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:46
at Naninovel.UniTask+Awaiter.GetResult () [0x00000] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTask.cs:201
at Naninovel.UniTaskExtensions.ForgetCore (Naninovel.UniTask task) [0x00016] in D:\Demo-master\Assets\Naninovel\Runtime\Common\Async\UniTask\Public\UniTaskExtensions.cs:189
UnityEngine.Debug:LogError (object)
Naninovel.Async.UniTaskScheduler:PublishUnobservedTaskException (System.Exception) (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskScheduler.cs:65)
Naninovel.Async.CompilerServices.AsyncUniTaskVoidMethodBuilder:SetException (System.Exception) (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs:29)
Naninovel.UniTaskExtensions/<ForgetCore>d__11:MoveNext () (at Assets/Naninovel/Runtime/Common/Async/UniTask/Public/UniTaskExtensions.cs:189)
Naninovel.Async.CompilerServices.AsyncUniTaskVoidMethodBuilder:Start<Naninovel.UniTaskExtensions/<ForgetCore>d__11> (Naninovel.UniTaskExtensions/<ForgetCore>d__11&) (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs:77)
Naninovel.UniTaskExtensions:ForgetCore (Naninovel.UniTask)
Naninovel.UniTaskExtensions:Forget (Naninovel.UniTask) (at Assets/Naninovel/Runtime/Common/Async/UniTask/Public/UniTaskExtensions.cs:171)
Naninovel.ScriptPlayer:Play () (at Assets/Naninovel/Runtime/ScriptPlayer/ScriptPlayer.cs:290)
Naninovel.ScriptPlayer:Play (Naninovel.Script,int,int) (at Assets/Naninovel/Runtime/ScriptPlayer/ScriptPlayer.cs:324)
Naninovel.ScriptPlayer/<PreloadAndPlayAsync>d__106:MoveNext () (at Assets/Naninovel/Runtime/ScriptPlayer/ScriptPlayer.cs:346)
Naninovel.Async.CompilerServices.MoveNextRunner`1<Naninovel.ScriptPlayer/<PreloadAndPlayAsync>d__106>:Run () (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/MoveNextRunner.cs:16)
Naninovel.Async.Internal.FuncExtensions:Invoke<UnityEngine.AsyncOperation> (System.Action,UnityEngine.AsyncOperation) (at Assets/Naninovel/Runtime/Common/Async/UniTask/Internal/FuncExtensions.cs:18)
UnityEngine.AsyncOperation:InvokeCompletionEvent ()
6) I moved my file outside naninovel and placed it into a folder /Runtime in project main directory just as I saw within the IntegrationExample-master's git repo example, but i get the same error
7) I'm bushing my head on my desk from days by this error
my Idea is to create small nani script and call them multiple times to avoid to write thousand of times the same lines of code in the whole storyline.
the result I would like to get is write this:
Code: Select all
@multichoise choises:home.morningAtHome,office.work,school.homecoming scripts:teststring
instead of this:
Code: Select all
@choise home goTo:morningAtHome
@choise office goTo:work
@choise school goTo:homecoming
I'm forgetting some steps in Unity or somewherelse? this is my first project in C# , Unity and Naninovel even if I'm a long time developer
I'm using Unity 2021.3.23f1 for my project
I also tryed to remove Main.nani from the scripts list and reappend it, I aslo quited the cache from preference -> GI Cache -> clean cache button
thanks again