Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Added support for the Alpha Locator flow.
- Added support for connecting mobile devices to cloud deployments via the anonymous authentication flow.
- Added option to build workers out via IL2CPP in the cmd.
- Added an example of handling disconnect for mobile workers.

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ protected override void OnUpdate()
PostUpdateCommands.AddComponent(entity, CameraComponentDefaults.Transform);

Cursor.lockState = CursorLockMode.Locked;

// Disable system after first run.
Enabled = false;
}
}

protected override void OnDestroyManager()
{
Cursor.lockState = CursorLockMode.None;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public void OnConnectionFailed(string connectionError)
$"Connection failed. Please check the IP address entered.\nSpatialOS error message:\n{connectionError}";
}

public void OnDisconnected(string disconnectReason)
{
UnityObjectDestroyer.Destroy(worker);
ipAddressInput.text = PlayerPrefs.GetString(HostIpPlayerPrefsKey);
connectionPanel.SetActive(true);
}

private IMobileConnectionController PrepareConnect()
{
errorMessage.text = string.Empty;
Expand Down
5 changes: 5 additions & 0 deletions workers/unity/Assets/Playground/Scripts/UI/InitUISystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@ protected override void OnUpdate()
// Disable system after first run.
Enabled = false;
}

protected override void OnDestroyManager()
{
UnityObjectDestroyer.Destroy(UIComponent.Main.gameObject);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public async void TryConnectAsync(ConnectionService connectionService)
protected override void HandleWorkerConnectionEstablished()
{
ConnectionScreenController.OnConnectionSucceeded();
Worker.OnDisconnect += ConnectionScreenController.OnDisconnected;
WorkerUtils.AddClientSystems(Worker.World);

if (level == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public async void TryConnectAsync(ConnectionService connectionService)
protected override void HandleWorkerConnectionEstablished()
{
ConnectionScreenController.OnConnectionSucceeded();
Worker.OnDisconnect += ConnectionScreenController.OnDisconnected;
WorkerUtils.AddClientSystems(Worker.World);

if (level == null)
Expand Down