Skip to content

Visual Scripting

Visual scripting ↗ (previously known as Bolt) is a built-in package bundled by default with Unity 2021 and newer version. It enables you to create logic for games or applications with unit-based graphs that both programmers and non-programmers can use without writing code.



First, make sure you're using a compatible Unity version (2021.1.0b1 or newer) and Visual Scripting package is installed in the package manager.


Add Elringus.Naninovel.Runtime library to the Node Library list found in "Visual Scripting" project settings menu. This is required to expose engine types and APIs to the visual scripting graphs.


The Visual Scripting doesn't automatically expose all the available types in the libraries, so we additionally need to add the required Naninovel types to the Type Options list found in the same settings menu. In the example below we added Engine and Script Player Interface, but you'll probably need more types, like the other engine service interfaces, configurations, etc.


Don't forget to regenerate units after adding the libraries and types to apply the changes.



When Naninovel library and types are added in the visual scripting settings, the engine APIs will become available in the fuzzy finder under graph view and can be used in the same way as the other Unity or third-party APIs. For example, below is an example on initializing the engine and playing a script. Make sure to disable Initialize On Applicatoin Load and Show Title UI, before trying this example.


In case you wish to send an event from a scenario script to a visual scripting graph or state machine, below is example of a custom command, which will attempt to find a game object with the provided name and send an event with the specified name and arguments:

using Naninovel;
using Naninovel.Commands;
using UniRx.Async;
using Unity.VisualScripting;
using UnityEngine;

public class BroadcastBoltEvent : Command
    [ParameterAlias("object"), RequiredParameter]
    public StringParameter GameObjectName;
    [ParameterAlias("name"), RequiredParameter]
    public StringParameter EventName;
    public StringListParameter Arguments;

    public override UniTask ExecuteAsync (AsyncToken asyncToken = default)
        var gameObject = GameObject.Find(GameObjectName);
        if (gameObject == null)
            Debug.LogError($"Failed to find `{GameObjectName}` game object.");
            return UniTask.CompletedTask;

        CustomEvent.Trigger(gameObject, EventName, Arguments);

        return UniTask.CompletedTask;

Just copy-paste the contents to a new C# script stored anywhere inside the project Assets directory and the command will automatically become available and can be used as follows:

; Send `MyEvent` to `ExampleEvent` game object with the provided args
@bolt object:ExampleEvent name:MyEvent args:ExampleMessage,Script002

Below is an example graph, that, when attached to a ExampleEvent game object, will print the message and start playing the specified script.



An example project containing all the aforementioned graphs and test scripts is available on GitHub: ↗. Be aware, that Naninovel is not distributed with the project, hence compilation errors will be produced after opening it for the first time; import the package from the Asset Store to resolve the issues.