Handling Triggers

By using the trigger-action in your DanmakuJSON-files, you can execute your own code when certain events occur in the behaviour of a bullet-source.

To add a trigger-listener, simply register a method or delegate to the OnTrigger-event  of a DanmakuContext with the following interface:

void (string triggerName,
      IDictionary<string, string> parameters,
      DanmakuBulletSource bulletSource)
  • string triggerName
    The name of the trigger which has been fired
  • IDictionary<string, string> parameters
    A dictionary containing the parameters which have been passed to this trigger. Note, that this argument is null if no parameters are provided.
  • DanmakuBulletSource bulletSource
    A reference to the bullet-source which fired this trigger


using UnityEngine;
using System.Collections.Generic;
using VirtualDropkick.DanmakuEngine.Unity;

public class MyTriggerHandler : MonoBehaviour
    private DanmakuContext context;
    void Awake()
        // fetch the context we are interested in
        context = DanmakuController.Instance.GetContext("MyContext");

        // register "HandleTrigger" as event listener
        context.OnTrigger += HandleTrigger;
    private void HandleTrigger(string triggerName,
                               IDictionary<string, string> parameters,
                               DanmakuBulletSource bulletSource)
        // put your trigger handling here
        Debug.Log("Trigger: " + triggerName);
        // note, that the parameters can be null!
        if(parameters != null)
            Debug.Log("Parameters: " + parameters.Count);

Buy the Danmaku Engine plugin

Leave a comment