Unity3D 插件使用

使用方法

  1. 将IOToolkit.unitypackage导入工程

  2. 编写代码

using UnityEngine;

using IOToolkit;
public class IOComponent : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        IODeviceController.Load();
        var _device = IODeviceController.GetIODevice("Standard");
        
        // 监听Key事件
        _device.BindKey(IOKeyCode.A, InputEvent.IE_Pressed, ()=>{
            // Handle Key A pressed event
        });

        // 监听Action事件
        _device.BindAction("TestAction", InputEvent.IE_Pressed, ()=>{
            // Handle TestAction pressed event
        });

        // 输出控制
        _device.BindKey(IOKeyCode.B, InputEvent.IE_Pressed,()=>{
            // 指定通道输出
            _device.SetDO(IOKeyCode.OAxis_00,1);

            // 指定动作输出
            _device.SetDOOn("TurnOnLight");
        });

    }

    // Update is called once per frame
    void Update()
    {
        IODeviceController.Update();
    }

    private void OnDestroy() {
        IODeviceController.UnLoad();
    }
}

最后更新于

这有帮助吗?