Minor updates to AdditiveScenes example

This commit is contained in:
MrGadget1024 2021-09-29 11:28:56 -04:00
parent 1f1d13ed42
commit 3afd54e182
2 changed files with 14 additions and 16 deletions

View File

@ -25,6 +25,16 @@ public override void OnStartServer()
Instantiate(Zone);
}
public override void OnStopServer()
{
StartCoroutine(UnloadScenes());
}
public override void OnStopClient()
{
StartCoroutine(UnloadScenes());
}
IEnumerator LoadSubScenes()
{
Debug.Log("Loading Scenes");
@ -36,16 +46,6 @@ IEnumerator LoadSubScenes()
}
}
public override void OnStopServer()
{
StartCoroutine(UnloadScenes());
}
public override void OnStopClient()
{
StartCoroutine(UnloadScenes());
}
IEnumerator UnloadScenes()
{
Debug.Log("Unloading Subscenes");

View File

@ -14,22 +14,20 @@ public class ZoneHandler : MonoBehaviour
[Tooltip("Assign the sub-scene to load for this zone")]
public string subScene;
[ServerCallback]
void OnTriggerEnter(Collider other)
{
if (!NetworkServer.active) return;
// Debug.LogFormat(LogType.Log, "Loading {0}", subScene);
// Debug.Log($"Loading {subScene}");
NetworkIdentity networkIdentity = other.gameObject.GetComponent<NetworkIdentity>();
SceneMessage message = new SceneMessage{ sceneName = subScene, sceneOperation = SceneOperation.LoadAdditive };
networkIdentity.connectionToClient.Send(message);
}
[ServerCallback]
void OnTriggerExit(Collider other)
{
if (!NetworkServer.active) return;
// Debug.LogFormat(LogType.Log, "Unloading {0}", subScene);
// Debug.Log($"Unloading {subScene}");
NetworkIdentity networkIdentity = other.gameObject.GetComponent<NetworkIdentity>();
SceneMessage message = new SceneMessage{ sceneName = subScene, sceneOperation = SceneOperation.UnloadAdditive };