Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Received OSC message that triggers a Unity error causes loop #18

Open
haryo-s opened this issue Mar 22, 2021 · 1 comment
Open

Received OSC message that triggers a Unity error causes loop #18

haryo-s opened this issue Mar 22, 2021 · 1 comment

Comments

@haryo-s
Copy link

haryo-s commented Mar 22, 2021

In Unity v2017.2.0f3, when an OSC message is received succesfully but results in an error in Unity, a loop occurs somewhere where the OSC message is sent again or reprocessed which results in an error....

Below is some simple code which reproduces the issue

// OSCMessageReceiver
// Unity code where an incoming OSC message comes in
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OSCMessageReceiver: MonoBehaviour {

    public OSC osc;
    public int[] numbers = new int[0];

    // Use this for initialization
    void Start () {
        osc.SetAddressHandler("/filter", OnReceiveFilter);
    }
	
    // Update is called once per frame
    void Update () {
		
    }

    void OnReceiveFilter(OscMessage message)
    {
        int x = message.GetInt(0);

        Debug.Log(x);
        Debug.LogError(numbers[x]);
    }
}
# Python code that sends an OSC message
import argparse
import random
import time

from pythonosc import udp_client

if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip", default="127.0.0.1",
      help="The ip of the OSC server")
  parser.add_argument("--port", type=int, default=6969,
      help="The port the OSC server is listening on")
  args = parser.parse_args()

  client = udp_client.SimpleUDPClient(args.ip, args.port)

  msg = 5

  client.send_message("/filter", msg)

In the above example, the Python script sends a message to OSCMessageReceiver to display the 6th item in the array numbers which is out of range and triggers an error inside Unity. As a result the aforementioned loop occurs. This issue is not fatal and does not crash Unity nor hinder gameplay as far as I can tell, but it does flood the console with error messages.

@thomasfredericks
Copy link
Owner

Hi, I am sorry, but I do not update or support UnityOSC anymore. Please use the following libraries instead :

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants