@Choiceを使うことで、Naninovel内で物語を分岐させる、あるいは任意の箇所へジャンプさせることができます。
@Choiceの使い方
Naninovelの基本的な使い方についてはこちら。

選択肢(または単一のクリックできる文章)を表示させるには、@choice “文章”のように入力すればOKです。

まず基本的な仕様として、選択肢を表示してもスクリプトの処理は入力待ちになりません。その後に文章があれば表示されますし、

なんなら選択肢を表示したままその後のテキストを読み続けることが可能です。

選択肢を複数並べると、図のように並んで表示されます。
選択肢で入力待ち

選択肢の後に@stopを置くことで、その位置で入力待ちにすることができます。

特に指示がない場合、選択肢を選択した後は@stop以後の処理が再開されます。
選択肢で物語を分岐

@choiceの後にパラメータでgoto:行き先を指定することで、選択ごとに物語を分岐させることができます。

この行き先で指定できるのは、別のスクリプト(naniファイル)です。

それぞれのルートごとに別の処理を書いておき、

ゲームを実行していずれかを選択すれば、

それぞれに応じた処理が返されます。ただし、別のスクリプトにジャンプするとcharで指定したキャラクターは表示されなくなります(BGMと背景はそのまま)。

なので同じキャラを表示し続ける場合、ジャンプ先で再度charを実行する必要があるようです。

選択肢の中でgotoがないものを作ることで、メインルートは同じスクリプトで続行、サブは別のスクリプトへジャンプ、といった指定をすることも可能です。
ラベル

#を頭に置いたラベルを置いておき、goto .ラベル名を行き先に指定することで、同じスクリプト内のラベルの位置まで物語をジャンプさせることができます。
;Naninovel
;スクリプト「NewScript」の「#here」へジャンプ
@choice "選択肢A" goto:NewScript.here
スクリプト名の後にラベル名を付けることで、任意のスクリプト内のラベルまでジャンプすることができます。

やりたいことから逆引きするUNITYの使い方まとめ
Unityをやりたいことから学習していけるよう、機能・用途別にまとめたページです。C#の命令別の逆引きは現時点で作っていません。2019の時期に書き始めているので、それより前のバージョンについては言及しません。
コメント