Search Unity

Communication between a C# Class (non Monobehavior) with a Monobehavior (websockets learning)

Discussion in 'Getting Started' started by Seba5, Oct 31, 2015.

  1. Seba5

    Seba5

    Joined:
    Mar 14, 2015
    Posts:
    2
    Dear Unity community, I'm trying to communicate events comming from a C# Class (non Monobehavior) to normal Monobehavior Class (and vice-versa).

    I'm kind of new, and my programming skills are OK when dealing with Monobehavior world, but I'm crashing into a wall when trying to communicate with pure C# objects that don't derive from Monobehavior.

    Let me explain a bit more:
    On one side I have a C# object (non Monobehavior) that plays the role of a websocket server. It receives events from the network via websockets. So I'd like to be able to:
    1) Call a monobehavior object function (for instance to log the incomming messages to a Text in a GUI)
    2) press a button on my GUI, and respond to the C# object (websocket server)--> to the websocket client.

    Explaining all my attempt/failures would be very long and confusing, so if anybody could help I'd appreciate.

    There's a websockets asset asset store for 15 bucks, what I want to achieve is learning, not saving. I may end up buying it later as it is supported and well explained!!!

    Thanks,
    Sebastián

    PS: Inspiration came from Youtube
    , there is a link to some code here: http://files.learninginventions.org/unity3d/Unity Websocket Demo.rar
    Also Unity has created a client to send the websocket events.