Universal Controller Server
Universal Controller is a SDK that allows developers to use their customised controller on mobile devices with Unity. This package doesn't limited the mobile side application to be an Unity app. It's aimed to support native Android & iOS apps for the controller side.
This repo is the server side Unity package which hosts a socket server within the Unity app by using native .NET socket APIs.
To set up the server, follow the following instructions:
- Create an empty GameObject in the scene you want to start up the server and attach component UCNetworkManager to it.
- Set the port number and maximum connections in UCNetworkManager.
- Create a new C# script as a child class of UCPlayer, override methods from UCPlayer (see SamplePlayer.cs for reference) and implement your own logics for each command received.
- Attach the script you just created to your player object, then make that as a prefab.
- Set the player prefab in UCNetworkManager.
- You are now good to go.
There is a sample scene included in the Sample folder with everything set up properly that you can use it as an example.
The server will shutdown by itself on application quit. Alternatively you can call UCNetworkManager.ServerShutDown() to shutdown the server anytime you want, the server will then shutdown after all data is sent and received.
Below are the formats of each command that will be handled by the server once received from client:
* The client who registered that player will be disconnected.
Type of parameters
- _player_id : int_
- _custom_key : string_
- _extra_content : string_
- x : float
- y : float
- z : float
- value of float x, y, z must be between -1.0f & 1.0f
- Reimplemented socket server with better structure and resources management.
- Added function GetIPv4Address() in NetworkUtilities for fetching the local IPv4 address.
- Implemented callbacks for data received from the clients.
- Introduces UC-Commands (Register, Deregister, KeyDown, Joystick, Gyro).
- Added component UCNetworkManager & UCPlayer.
- Includes sample scene.
- Set up socket server in Unity.
- Includes test script for starting the server.