Added Unity 5 support
This commit is contained in:
parent
190564eb87
commit
8e19568e19
@ -110,8 +110,10 @@ namespace MLAPI
|
||||
//Legacy channel. ReliableFragmentedSequenced doesn't exist in older Unity versions.
|
||||
if(NetworkConfig.UseLegacyChannel)
|
||||
NetworkConfig.Channels.Add("MLAPI_RELIABLE_FRAGMENTED_SEQUENCED", QosType.ReliableSequenced);
|
||||
#if !UNITY_5 //Unity 5.6 has confirmed to not have the ReliableFragmentedSequenced channel type.
|
||||
else
|
||||
NetworkConfig.Channels.Add("MLAPI_RELIABLE_FRAGMENTED_SEQUENCED", QosType.ReliableFragmentedSequenced);
|
||||
#endif
|
||||
|
||||
NetworkConfig.Channels.Add("MLAPI_POSITION_UPDATE", QosType.StateUpdate);
|
||||
NetworkConfig.Channels.Add("MLAPI_ANIMATION_UPDATE", QosType.ReliableSequenced);
|
||||
@ -177,6 +179,17 @@ namespace MLAPI
|
||||
return cConfig;
|
||||
}
|
||||
|
||||
#if UNITY_5
|
||||
internal IEnumerator WaitForSceneSwitch(AsyncOperation operation, Action callback)
|
||||
{
|
||||
while(!operation.isDone)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
callback();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
public void StartServer(NetworkingConfiguration netConfig)
|
||||
{
|
||||
|
@ -47,7 +47,15 @@ namespace MLAPI.NetworkingManagerComponents
|
||||
isSwitching = true;
|
||||
lastScene = SceneManager.GetActiveScene();
|
||||
AsyncOperation sceneLoad = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
|
||||
#if !UNITY_5
|
||||
sceneLoad.completed += OnSceneLoaded;
|
||||
#else
|
||||
NetworkingManager.singleton.StartCoroutine(NetworkingManager.singleton.WaitForSceneSwitch(sceneLoad, () =>
|
||||
{
|
||||
//This block runs when scene switch is done.
|
||||
OnSceneLoaded(sceneLoad);
|
||||
}));
|
||||
#endif
|
||||
using(MemoryStream stream = new MemoryStream(4))
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(stream))
|
||||
@ -72,7 +80,15 @@ namespace MLAPI.NetworkingManagerComponents
|
||||
}
|
||||
lastScene = SceneManager.GetActiveScene();
|
||||
AsyncOperation sceneLoad = SceneManager.LoadSceneAsync(sceneIndexToString[sceneIndex], LoadSceneMode.Additive);
|
||||
#if !UNITY_5
|
||||
sceneLoad.completed += OnSceneLoaded;
|
||||
#else
|
||||
NetworkingManager.singleton.StartCoroutine(NetworkingManager.singleton.WaitForSceneSwitch(sceneLoad, () =>
|
||||
{
|
||||
//This block runs when scene switch is done.
|
||||
OnSceneLoaded(sceneLoad);
|
||||
}));
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void OnSceneLoaded(AsyncOperation operation)
|
||||
@ -85,7 +101,15 @@ namespace MLAPI.NetworkingManagerComponents
|
||||
SceneManager.MoveGameObjectToScene(objectsToKeep[i].gameObject, nextScene);
|
||||
}
|
||||
AsyncOperation sceneLoad = SceneManager.UnloadSceneAsync(lastScene);
|
||||
#if !UNITY_5
|
||||
sceneLoad.completed += OnSceneUnload;
|
||||
#else
|
||||
NetworkingManager.singleton.StartCoroutine(NetworkingManager.singleton.WaitForSceneSwitch(sceneLoad, () =>
|
||||
{
|
||||
//This block runs when scene switch is done.
|
||||
OnSceneUnload(sceneLoad);
|
||||
}));
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void OnSceneUnload(AsyncOperation operation)
|
||||
|
Loading…
x
Reference in New Issue
Block a user