mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Minor updates to AdditiveScenes example
This commit is contained in:
parent
1f1d13ed42
commit
3afd54e182
@ -25,6 +25,16 @@ public override void OnStartServer()
|
|||||||
Instantiate(Zone);
|
Instantiate(Zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnStopServer()
|
||||||
|
{
|
||||||
|
StartCoroutine(UnloadScenes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnStopClient()
|
||||||
|
{
|
||||||
|
StartCoroutine(UnloadScenes());
|
||||||
|
}
|
||||||
|
|
||||||
IEnumerator LoadSubScenes()
|
IEnumerator LoadSubScenes()
|
||||||
{
|
{
|
||||||
Debug.Log("Loading Scenes");
|
Debug.Log("Loading Scenes");
|
||||||
@ -36,16 +46,6 @@ IEnumerator LoadSubScenes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnStopServer()
|
|
||||||
{
|
|
||||||
StartCoroutine(UnloadScenes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnStopClient()
|
|
||||||
{
|
|
||||||
StartCoroutine(UnloadScenes());
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator UnloadScenes()
|
IEnumerator UnloadScenes()
|
||||||
{
|
{
|
||||||
Debug.Log("Unloading Subscenes");
|
Debug.Log("Unloading Subscenes");
|
||||||
|
@ -14,22 +14,20 @@ public class ZoneHandler : MonoBehaviour
|
|||||||
[Tooltip("Assign the sub-scene to load for this zone")]
|
[Tooltip("Assign the sub-scene to load for this zone")]
|
||||||
public string subScene;
|
public string subScene;
|
||||||
|
|
||||||
|
[ServerCallback]
|
||||||
void OnTriggerEnter(Collider other)
|
void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
if (!NetworkServer.active) return;
|
// Debug.Log($"Loading {subScene}");
|
||||||
|
|
||||||
// Debug.LogFormat(LogType.Log, "Loading {0}", subScene);
|
|
||||||
|
|
||||||
NetworkIdentity networkIdentity = other.gameObject.GetComponent<NetworkIdentity>();
|
NetworkIdentity networkIdentity = other.gameObject.GetComponent<NetworkIdentity>();
|
||||||
SceneMessage message = new SceneMessage{ sceneName = subScene, sceneOperation = SceneOperation.LoadAdditive };
|
SceneMessage message = new SceneMessage{ sceneName = subScene, sceneOperation = SceneOperation.LoadAdditive };
|
||||||
networkIdentity.connectionToClient.Send(message);
|
networkIdentity.connectionToClient.Send(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ServerCallback]
|
||||||
void OnTriggerExit(Collider other)
|
void OnTriggerExit(Collider other)
|
||||||
{
|
{
|
||||||
if (!NetworkServer.active) return;
|
// Debug.Log($"Unloading {subScene}");
|
||||||
|
|
||||||
// Debug.LogFormat(LogType.Log, "Unloading {0}", subScene);
|
|
||||||
|
|
||||||
NetworkIdentity networkIdentity = other.gameObject.GetComponent<NetworkIdentity>();
|
NetworkIdentity networkIdentity = other.gameObject.GetComponent<NetworkIdentity>();
|
||||||
SceneMessage message = new SceneMessage{ sceneName = subScene, sceneOperation = SceneOperation.UnloadAdditive };
|
SceneMessage message = new SceneMessage{ sceneName = subScene, sceneOperation = SceneOperation.UnloadAdditive };
|
||||||
|
Loading…
Reference in New Issue
Block a user