Unity SDK
v1.0.0
Integrate Game On Dude! into your Unity project with our official SDK.
Installation
Unity Package Manager (Recommended)
Install via Git URL in Unity Package Manager
- 1Open Unity and go to Window → Package Manager
- 2Click the + button and select "Add package from git URL"
- 3Enter: https://github.com/gameon-guy/unity-sdk.git
- 4Click Add and wait for installation
Manual Installation
Download and import the Unity package
- 1Download the latest .unitypackage from GitHub Releases
- 2In Unity, go to Assets → Import Package → Custom Package
- 3Select the downloaded file and import all assets
Requirements
- Unity 2021.3 LTS or newer
- .NET Standard 2.1 or .NET 4.x
- WebSocket support (included in Unity)
- Newtonsoft.Json (included with SDK)
Components
GameOnNetworkManager
Core component for managing server connections and rooms.
Properties
serverUrl(string)WebSocket server URLautoConnect(bool)Connect on Start()reconnectAttempts(int)Max reconnection attemptsEvents
OnConnectedFired when connected to serverOnDisconnectedFired when disconnectedOnRoomJoinedFired when joined a roomOnRoomLeftFired when left a roomOnErrorFired on connection errorsExample
using GameOn.Multiplayer;
using UnityEngine;
public class GameManager : MonoBehaviour
{
[SerializeField] private GameOnNetworkManager networkManager;
async void Start()
{
networkManager.OnConnected += () => Debug.Log("Connected!");
networkManager.OnRoomJoined += OnRoomJoined;
await networkManager.Connect();
}
async void JoinGame()
{
await networkManager.JoinOrCreate("trivia", new {
username = "Player1",
team = "blue"
});
}
void OnRoomJoined(Room room)
{
Debug.Log($"Joined room: {room.Id}");
room.OnStateChange += (state) => {
// Update game UI based on state
UpdateUI(state);
};
room.OnMessage<ChatMessage>("chat", (msg) => {
chatUI.AddMessage(msg.from, msg.text);
});
}
}GameOnTriviaManager
Specialized component for trivia game functionality.
Properties
networkManager(GameOnNetworkManager)Reference to network managerquestionTimeLimit(float)Seconds per questionEvents
OnQuestionReceivedNew question from serverOnAnswerResultResult of submitted answerOnScoresUpdatedScores changedOnGameEndedGame finishedExample
using GameOn.Multiplayer;
using UnityEngine;
using UnityEngine.UI;
public class TriviaGameUI : MonoBehaviour
{
[SerializeField] private GameOnTriviaManager triviaManager;
[SerializeField] private Text questionText;
[SerializeField] private Button[] answerButtons;
void OnEnable()
{
triviaManager.OnQuestionReceived += DisplayQuestion;
triviaManager.OnAnswerResult += ShowResult;
triviaManager.OnScoresUpdated += UpdateScoreboard;
}
void DisplayQuestion(TriviaQuestion question)
{
questionText.text = question.text;
for (int i = 0; i < answerButtons.Length; i++)
{
int index = i;
answerButtons[i].GetComponentInChildren<Text>().text =
question.answers[i];
answerButtons[i].onClick.AddListener(() =>
triviaManager.SubmitAnswer(index));
}
}
void ShowResult(AnswerResult result)
{
if (result.correct)
Debug.Log($"Correct! +{result.points} points");
else
Debug.Log($"Wrong! Correct answer: {result.correctAnswer}");
}
}NetworkTransform
Automatically sync transform between clients with interpolation.
Properties
syncPosition(bool)Sync positionsyncRotation(bool)Sync rotationsyncScale(bool)Sync scaleinterpolationSpeed(float)Smoothing factorsendRate(float)Updates per secondExample
// Simply add NetworkTransform component to your GameObject
// Configure in Inspector or via code:
using GameOn.Multiplayer;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
private NetworkTransform netTransform;
void Awake()
{
netTransform = GetComponent<NetworkTransform>();
netTransform.syncPosition = true;
netTransform.syncRotation = true;
netTransform.interpolationSpeed = 10f;
netTransform.sendRate = 20f; // 20 updates/sec
}
void Update()
{
if (netTransform.IsOwner)
{
// Only owner can move
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
transform.Translate(new Vector3(h, 0, v) * Time.deltaTime * 5f);
}
// Other clients automatically receive interpolated updates
}
}Migration from Photon
Switching from Photon? Here's a quick reference for equivalent APIs.
| Photon | GameOn | Notes |
|---|---|---|
PhotonNetwork.ConnectUsingSettings() | await networkManager.Connect() | GameOn uses async/await for all network operations |
PhotonNetwork.JoinOrCreateRoom("room", options, lobby) | await networkManager.JoinOrCreate("room", options) | Simplified API without lobby system |
[PunRPC] void MyRPC() | room.OnMessage<T>("type", handler) | Message-based instead of RPC attributes |
PhotonView.IsMine | networkTransform.IsOwner | Ownership works similarly |
PhotonNetwork.CurrentRoom.PlayerCount | room.State.players.Count | Access through synchronized state |
Note: While GameOn provides similar functionality to Photon, the APIs are designed differently. We recommend reviewing the full documentation rather than doing a 1:1 port.
Ready to Build?
Check out our tutorials for building complete multiplayer games with Unity.