Giter VIP home page Giter VIP logo

Comments (5)

jorgegarcia avatar jorgegarcia commented on August 15, 2024 1

Hi, my understanding is that you can't send the first message in the Start() function so you will need to add it to your Update function, yes.

from unityosc.

francescosoave avatar francescosoave commented on August 15, 2024

ok I think I've found the issue (but for some reason it wasn't an issue before?)

Basically in my main class I was sending the first osc message (through my custom sendOsc) in the Start() method. Now I moved it to the update method and it works, although it doesn't look the best way of doing this.

Here's the code

public class ScreenR : MonoBehaviour
{

public KinectController kinect;
public OSCController oscController;
private GameObject shape;
public float waitTime = 10f;
private float timer;
public string outIP = "127.0.0.1";
public int outPort = 9999;

// current shape (1 cube, 2 sphere, 3 capsule)
private int index;

public int Index
{
    get { return index; }
    set { index = value; }
}

void Start()
{
    //initial index
    index = 1;
    // initial shape
    shape = GameObject.CreatePrimitive(PrimitiveType.Cube);

    //send first message
    oscController.SendOsc(index); //THIS DOES NOT WORK (THROWS ERROR)

    GetComponent<Renderer>().material.color = Color.black;
}
private bool b = true;
void Update()
{
   //THIS WORKS
    if (b)
    {
        oscController.SendOsc(index);
        b = false;
    }

   //..other stuff
}

from unityosc.

jorgegarcia avatar jorgegarcia commented on August 15, 2024

Hi @francescosoave

In order to make the scripts work, you should first initialise the client. Once that's done, you can start sending messages (in the Update() function for instance, as you did).

Thanks,
Jorge

from unityosc.

francescosoave avatar francescosoave commented on August 15, 2024

Hi, ok, so there's no way to send a message from the Start? Basically I need to send a first message which is a bit different than the others (and it starts the whole communication). Using a bool as I did seemed a bit clumsy :)

from unityosc.

francescosoave avatar francescosoave commented on August 15, 2024

ok thanks!

from unityosc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.