fix(Additive Levels Example): Simplified Portal::SendPlayerToNewScene

This commit is contained in:
MrGadget 2024-09-30 14:59:47 -04:00
parent c1b5053004
commit 80df4d66b6

View File

@ -27,7 +27,7 @@ public void OnLabelTextChanged(string _, string newValue)
public override void OnStartServer()
{
labelText = Path.GetFileNameWithoutExtension(destinationScene).Replace("MirrorAdditiveLevels","");
labelText = Path.GetFileNameWithoutExtension(destinationScene).Replace("MirrorAdditiveLevels", "");
// Simple Regex to insert spaces before capitals, numbers
labelText = Regex.Replace(labelText, @"\B[A-Z0-9]+", " $0");
@ -60,8 +60,8 @@ void OnTriggerEnter(Collider other)
[ServerCallback]
IEnumerator SendPlayerToNewScene(GameObject player)
{
if (player.TryGetComponent(out NetworkIdentity identity))
{
if (!player.TryGetComponent(out NetworkIdentity identity)) yield break;
NetworkConnectionToClient conn = identity.connectionToClient;
if (conn == null) yield break;
@ -97,5 +97,4 @@ IEnumerator SendPlayerToNewScene(GameObject player)
playerController.enabled = true;
}
}
}
}