Unity 5 and using data sent/received from websocket in other part of project than in WebSocketBehavior class
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I am still trying to understand exactly how websocket-sharp works and how I can use it in my existing projects.
So, I created a small Unity project where I have a simple canvas with a Text and a Slider elements. And where I am also creating a HTTP server, with a WebSocket server (following example3).
Then on a webpage, I put a simple button and a slider. When the button is pushed, it sends a string message; when the slider is changed it sends its value as message.
I am now stuck, and I would like to understand:
-
How to use the received data from the web page in our WebSocketBehavior class, in my other Unity scripts?
I would like for example to display the received message from the web page to my Unity Text field. -
How can I send a Websocket message to the client when my Unity Slider is changed?
So far I managed to send message to the web page only in my WebSocketBehavior class (echoing the received message).
How can I send data from the websocket server to any of the clients from any other Unity scripts?
Any help would be appreciated.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with example3 and the WebSocketBehavior class, then trace how the Unity Text and Slider scripts interact with the WebSocket server. The work is complete when the project has a documented pattern for receiving messages in other Unity scripts and sending updates from a Unity Slider to clients.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- game-dev, networking
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100