0
Answered

Method problem

oml 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 1

hello,

I'm new to bolt,

I'm trying to rewrite my c# script to blot script.but i'm stuck on some method problem.

here is my c# script.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.Events;

public class ReceiveOSCValue : MonoBehaviour {

    OSC osc;
    public string address = "/address 0-1 > remap1-remap2";
    public float remap1 = 0.0f;
    public float remap2 = 1.0f;
  
    [Serializable]
    public class oscFloatEvent : UnityEvent <float> { }
    [SerializeField]
    public oscFloatEvent onChangeEvent;

    [SerializeField]
    private float oscFloatin;

    [SerializeField]
    private float oscFloatRemap;

    // Use this for initialization
    void Start () {
        osc = GameObject.Find("OSC").GetComponent<OSC>();

        osc.SetAddressHandler(address, OnReceiveX);
}

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

    void OnReceiveX(OscMessage message)
    {
        oscFloatin = message.GetFloat(0);
        

        oscFloatRemap = oscFloatin * (remap2 - remap1) + remap1;

        onChangeEvent.Invoke(oscFloatRemap);
    }

}



here is my bolt script:

I don't know how to connect with "message" method in SetAddressHaddler.

Any help?. thanks.


Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Answered

Hi oml, welcome to the community!

Sorry for the late reply. Unfortunately, Bolt does not support delegates (passing a method as an argument, like OnReceiveX in your example). Instead, you should use custom events to relay execution.