This code will add C# Script Template for Naninovel Command, so you don't need to rename it again.
This is a script editor. You may edit private cons string template
for the target template. In my case, I put in #Game folder. You can also add another template by copy the method and paste below it.
Code: Select all
#if UNITY_EDITOR
using UnityEditor;
public class CreateNewScriptClassFromCustomTemplate
{
private const string template = "Assets/#Game/NovelCommand.cs.txt";
[MenuItem(itemName: "Assets/Create/C# Script Novel Command Template", isValidateFunction: false, priority: 51)]
public static void Template()
{
ProjectWindowUtil.CreateScriptAssetFromTemplateFile(template, "YourDefaultNewScriptName.cs");
}
}
#endif
This is the NovelCommand.cs.txt. Put it to your template folder, in my case, I put in #Game folder.
You may remove using System.Linq
if you don't use them. Well, I added it because I found Linq mostly inside Naninovel and also really useful for sorting collection
like List<T>
.
Code: Select all
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UniRx.Async;
using UnityEngine;
using Naninovel;
using Naninovel.Commands;
using Naninovel.UI;
[CommandAlias("#SCRIPTNAME#")]
public class #SCRIPTNAME# : Command
{
public override async UniTask ExecuteAsync (CancellationToken cancellationToken = default)
{
//Do your stuff here
await UniTask.CompletedTask;
}
}