Cycling74 / rnbo.unity.audioplugin

RNBO Adapter for Unity's Native Audio Plugin
MIT License
40 stars 8 forks source link

async get preset #9

Closed x37v closed 1 year ago

x37v commented 1 year ago

requires more plumbing but would be nice to not block when requesting a preset

x37v commented 1 year ago
using UnityEngine;
using Cycling74.RNBOTypes;

public class PlayerMovement : MonoBehaviour
{
    const int instanceIndex = 1;

    SyncCycleHelper helper;
    SyncCycleHandle plugin;

    void Start() {
        helper = SyncCycleHelper.FindById(instanceIndex);
        plugin = helper?.Plugin;
        if (plugin != null) {
            plugin.PresetEvent += (object sender, PresetEventArgs arg) => {
                Debug.LogFormat("PresetEvent Event: {0}", arg.Preset);
            };
        }
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Y))
        {
            plugin.GetPreset();
        }
    }
}
jinpavg commented 1 year ago

now reflected in PRESETS.md