Moved a couple of folders and wrote some code
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8eb071c832ae3664c9b1701b52872513
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,38 @@
|
||||
using FishNet.Broadcast;
|
||||
using FishNet.Documenting;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Sent when there are starting scenes for the client to load.
|
||||
/// </summary>
|
||||
public struct EmptyStartScenesBroadcast : IBroadcast { }
|
||||
/// <summary>
|
||||
/// Sent to clients to load networked scenes.
|
||||
/// </summary>
|
||||
[APIExclude]
|
||||
public struct LoadScenesBroadcast : IBroadcast
|
||||
{
|
||||
public LoadQueueData QueueData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent to clients to unload networked scenes.
|
||||
/// </summary>
|
||||
[APIExclude]
|
||||
public struct UnloadScenesBroadcast : IBroadcast
|
||||
{
|
||||
public UnloadQueueData QueueData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent to server to indicate which scenes a client has loaded.
|
||||
/// </summary>
|
||||
[APIExclude]
|
||||
public struct ClientScenesLoadedBroadcast : IBroadcast
|
||||
{
|
||||
public SceneLookupData[] SceneLookupDatas;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 698a94b4f8664ac4ab108deae0ba3b7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,155 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnitySceneManager = UnityEngine.SceneManagement.SceneManager;
|
||||
using UnityScene = UnityEngine.SceneManagement.Scene;
|
||||
using System.Collections;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
|
||||
public class DefaultSceneProcessor : SceneProcessorBase
|
||||
{
|
||||
#region Private.
|
||||
/// <summary>
|
||||
/// Currently active loading AsyncOperations.
|
||||
/// </summary>
|
||||
protected List<AsyncOperation> LoadingAsyncOperations = new List<AsyncOperation>();
|
||||
/// <summary>
|
||||
/// A collection of scenes used both for loading and unloading.
|
||||
/// </summary>
|
||||
protected List<UnityScene> Scenes = new List<UnityScene>();
|
||||
/// <summary>
|
||||
/// Current AsyncOperation being processed.
|
||||
/// </summary>
|
||||
protected AsyncOperation CurrentAsyncOperation;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Called when scene loading has begun.
|
||||
/// </summary>
|
||||
public override void LoadStart(LoadQueueData queueData)
|
||||
{
|
||||
base.LoadStart(queueData);
|
||||
ResetValues();
|
||||
}
|
||||
|
||||
public override void LoadEnd(LoadQueueData queueData)
|
||||
{
|
||||
base.LoadEnd(queueData);
|
||||
ResetValues();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets values for a fresh load or unload.
|
||||
/// </summary>
|
||||
private void ResetValues()
|
||||
{
|
||||
CurrentAsyncOperation = null;
|
||||
LoadingAsyncOperations.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when scene unloading has begun within an unload operation.
|
||||
/// </summary>
|
||||
/// <param name="queueData"></param>
|
||||
public override void UnloadStart(UnloadQueueData queueData)
|
||||
{
|
||||
base.UnloadStart(queueData);
|
||||
Scenes.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begin loading a scene using an async method.
|
||||
/// </summary>
|
||||
/// <param name="sceneName">Scene name to load.</param>
|
||||
public override void BeginLoadAsync(string sceneName, UnityEngine.SceneManagement.LoadSceneParameters parameters)
|
||||
{
|
||||
AsyncOperation ao = UnitySceneManager.LoadSceneAsync(sceneName, parameters);
|
||||
LoadingAsyncOperations.Add(ao);
|
||||
|
||||
CurrentAsyncOperation = ao;
|
||||
CurrentAsyncOperation.allowSceneActivation = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begin unloading a scene using an async method.
|
||||
/// </summary>
|
||||
/// <param name="sceneName">Scene name to unload.</param>
|
||||
public override void BeginUnloadAsync(UnityScene scene)
|
||||
{
|
||||
CurrentAsyncOperation = UnitySceneManager.UnloadSceneAsync(scene);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns if a scene load or unload percent is done.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool IsPercentComplete()
|
||||
{
|
||||
return (GetPercentComplete() >= 0.9f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the progress on the current scene load or unload.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override float GetPercentComplete()
|
||||
{
|
||||
return (CurrentAsyncOperation == null) ? 1f : CurrentAsyncOperation.progress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a loaded scene.
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene loaded.</param>
|
||||
public override void AddLoadedScene(UnityScene scene)
|
||||
{
|
||||
base.AddLoadedScene(scene);
|
||||
Scenes.Add(scene);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns scenes which were loaded during a load operation.
|
||||
/// </summary>
|
||||
public override List<UnityScene> GetLoadedScenes()
|
||||
{
|
||||
return Scenes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Activates scenes which were loaded.
|
||||
/// </summary>
|
||||
public override void ActivateLoadedScenes()
|
||||
{
|
||||
foreach (AsyncOperation ao in LoadingAsyncOperations)
|
||||
ao.allowSceneActivation = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns if all asynchronized tasks are considered IsDone.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override IEnumerator AsyncsIsDone()
|
||||
{
|
||||
bool notDone;
|
||||
do
|
||||
{
|
||||
notDone = false;
|
||||
foreach (AsyncOperation ao in LoadingAsyncOperations)
|
||||
{
|
||||
|
||||
if (!ao.isDone)
|
||||
{
|
||||
notDone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
} while (notDone);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c6eacaa60569d947b383df03fff1ea3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09823f70d9231d34f91d88d11b937758
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,34 @@
|
||||
using FishNet.Connection;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Data container about a scene presence change for a client.
|
||||
/// </summary>
|
||||
public struct ClientPresenceChangeEventArgs
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Scene on the server which the client's presence has changed.
|
||||
/// </summary>
|
||||
public Scene Scene;
|
||||
/// <summary>
|
||||
/// Connection to client.
|
||||
/// </summary>
|
||||
public NetworkConnection Connection;
|
||||
/// <summary>
|
||||
/// True if the client was added to the scene, false is removed.
|
||||
/// </summary>
|
||||
public bool Added;
|
||||
|
||||
internal ClientPresenceChangeEventArgs(Scene scene, NetworkConnection conn, bool added)
|
||||
{
|
||||
Scene = scene;
|
||||
Connection = conn;
|
||||
Added = added;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa91039d4ab1c6445af72881af122b0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Data container about a scene load start.
|
||||
/// </summary>
|
||||
public struct SceneLoadStartEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Queue data used by the current scene action.
|
||||
/// </summary>
|
||||
public readonly LoadQueueData QueueData;
|
||||
|
||||
internal SceneLoadStartEventArgs(LoadQueueData lqd)
|
||||
{
|
||||
QueueData = lqd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Data container about a scene load percent change.
|
||||
/// </summary>
|
||||
public struct SceneLoadPercentEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Queue data used by the current scene action.
|
||||
/// </summary>
|
||||
public readonly LoadQueueData QueueData;
|
||||
/// <summary>
|
||||
/// Percentage of change completion. 1f is equal to 100% complete.
|
||||
/// </summary>
|
||||
public readonly float Percent;
|
||||
|
||||
internal SceneLoadPercentEventArgs(LoadQueueData lqd, float percent)
|
||||
{
|
||||
QueueData = lqd;
|
||||
Percent = percent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Data container about a scene load end.
|
||||
/// </summary>
|
||||
public struct SceneLoadEndEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Queue data used by the current scene action.
|
||||
/// </summary>
|
||||
public readonly LoadQueueData QueueData;
|
||||
/// <summary>
|
||||
/// Scenes which were loaded.
|
||||
/// </summary>
|
||||
public readonly Scene[] LoadedScenes;
|
||||
/// <summary>
|
||||
/// Scenes which were skipped because they were already loaded.
|
||||
/// </summary>
|
||||
public readonly string[] SkippedSceneNames;
|
||||
/// <summary>
|
||||
/// Scenes which were unloaded.
|
||||
/// </summary>
|
||||
public readonly string[] UnloadedSceneNames;
|
||||
|
||||
internal SceneLoadEndEventArgs(LoadQueueData lqd, string[] skipped, Scene[] loaded, string[] unloadedSceneNames)
|
||||
{
|
||||
QueueData = lqd;
|
||||
SkippedSceneNames = skipped;
|
||||
LoadedScenes = loaded;
|
||||
UnloadedSceneNames = unloadedSceneNames;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86278568f8087de49b0908f148501993
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Data container about a scene unload start.
|
||||
/// </summary>
|
||||
public struct SceneUnloadStartEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Queue data used by the current scene action.
|
||||
/// </summary>
|
||||
public readonly UnloadQueueData QueueData;
|
||||
|
||||
internal SceneUnloadStartEventArgs(UnloadQueueData sqd)
|
||||
{
|
||||
QueueData = sqd;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data container about a scene unload end.
|
||||
/// </summary>
|
||||
public struct SceneUnloadEndEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Queue data used by the current scene action.
|
||||
/// </summary>
|
||||
public readonly UnloadQueueData QueueData;
|
||||
/// <summary>
|
||||
/// Handles of scenes which were successfully unloaded.
|
||||
/// </summary>
|
||||
[Obsolete("Use UnloadedScenesV2")]
|
||||
public int[] UnloadedSceneHandles;
|
||||
/// <summary>
|
||||
/// Names of scenes which were successfully unloaded.
|
||||
/// </summary>
|
||||
[Obsolete("Use UnloadedScenesV2")]
|
||||
public string[] UnloadedSceneNames;
|
||||
|
||||
/// <summary>
|
||||
/// Scenes which were successfully unloaded.
|
||||
/// This collection may be populated with empty scenes depending on engine version.
|
||||
/// </summary>
|
||||
public List<Scene> UnloadedScenes;
|
||||
/// <summary>
|
||||
/// Unloaded scenes with names and handles cached.
|
||||
/// This will be renamed as UnloadedScenes in Fish-Networking version 4.
|
||||
/// </summary>
|
||||
public List<UnloadedScene> UnloadedScenesV2;
|
||||
|
||||
internal SceneUnloadEndEventArgs(UnloadQueueData sqd, List<Scene> unloadedScenes, List<UnloadedScene> newUnloadedScenes)
|
||||
{
|
||||
QueueData = sqd;
|
||||
UnloadedScenes = unloadedScenes;
|
||||
UnloadedScenesV2 = newUnloadedScenes;
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
UnloadedSceneNames = new string[newUnloadedScenes.Count];
|
||||
UnloadedSceneHandles = new int[newUnloadedScenes.Count];
|
||||
for (int i = 0; i < newUnloadedScenes.Count; i++)
|
||||
{
|
||||
UnloadedSceneNames[i] = newUnloadedScenes[i].Name;
|
||||
UnloadedSceneHandles[i] = newUnloadedScenes[i].Handle;
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c24765fea85b564aa331b529f324f92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: beefc84827a4af141aa1b326fca9084f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,39 @@
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings to apply when loading a scene.
|
||||
/// </summary>
|
||||
public class LoadOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// True if to automatically unload the loaded scenes when they are no longer being used by clients. This field only applies to scenes loaded for connections, not globally loaded scenes.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public bool AutomaticallyUnload = true;
|
||||
/// <summary>
|
||||
/// False if to only load scenes which are not yet loaded. When true a scene may load multiple times; this is known as scene stacking. Only the server is able to stack scenes; clients will load a single instance. Global scenes cannot be stacked.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public bool AllowStacking;
|
||||
/// <summary>
|
||||
/// LocalPhysics mode to use when loading this scene. Generally this will only be used when applying scene stacking. Only used by the server.
|
||||
/// https://docs.unity3d.com/ScriptReference/SceneManagement.LocalPhysicsMode.html
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public LocalPhysicsMode LocalPhysics = LocalPhysicsMode.None;
|
||||
/// <summary>
|
||||
/// True to reload a scene if it's already loaded.
|
||||
/// This does not function yet.
|
||||
/// </summary>
|
||||
[System.Obsolete("This feature is not functional yet but will be at a later release.")]
|
||||
public bool ReloadScenes;
|
||||
/// <summary>
|
||||
/// True if scenes should be loaded using addressables. This field only exists for optional use so the user may know if their queue data is using addressables.
|
||||
/// </summary>
|
||||
public bool Addressables;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1614453d3786b2a4eb18b69297da7dc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,19 @@
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Additional user-crafted data which can be included in scene load callbacks.
|
||||
/// </summary>
|
||||
public class LoadParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Objects which are included in callbacks on the server when loading a scene. Can be useful for including unique information about the scene, such as match id. These are not sent to clients; use ClientParams for this.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public object[] ServerParams = new object[0];
|
||||
/// <summary>
|
||||
/// Bytes which are sent to clients during scene loads. Can contain any information.
|
||||
/// </summary>
|
||||
public byte[] ClientParams = new byte[0];
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8b395f67f61b4e45830a70289a1901d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,51 @@
|
||||
using FishNet.Connection;
|
||||
using FishNet.Utility.Constant;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo(UtilityConstants.GENERATED_ASSEMBLY_NAME)]
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Data generated when loading a scene.
|
||||
/// </summary>
|
||||
public class LoadQueueData
|
||||
{
|
||||
/// <summary>
|
||||
/// Clients which receive this SceneQueueData. If Networked, all clients do. If Connections, only the specified Connections do.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public SceneScopeType ScopeType;
|
||||
/// <summary>
|
||||
/// Connections to load scenes for. Only valid on the server and when ScopeType is Connections.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public NetworkConnection[] Connections = new NetworkConnection[0];
|
||||
/// <summary>
|
||||
/// SceneLoadData to use.
|
||||
/// </summary>
|
||||
public SceneLoadData SceneLoadData = null;
|
||||
/// <summary>
|
||||
/// Current global scenes.
|
||||
/// </summary>
|
||||
public string[] GlobalScenes = new string[0];
|
||||
/// <summary>
|
||||
/// True if to iterate this queue data as server.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public readonly bool AsServer;
|
||||
|
||||
public LoadQueueData() { }
|
||||
internal LoadQueueData(SceneScopeType scopeType, NetworkConnection[] conns, SceneLoadData sceneLoadData, string[] globalScenes, bool asServer)
|
||||
{
|
||||
ScopeType = scopeType;
|
||||
Connections = conns;
|
||||
SceneLoadData = sceneLoadData;
|
||||
GlobalScenes = globalScenes;
|
||||
AsServer = asServer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fb4183af628f754b800dfdbb1ba9bf0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,25 @@
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// How to replace scenes when loading.
|
||||
/// </summary>
|
||||
public enum ReplaceOption : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Replace all scenes, online and offline.
|
||||
/// </summary>
|
||||
All,
|
||||
/// <summary>
|
||||
/// Only replace scenes loaded using the SceneManager.
|
||||
/// </summary>
|
||||
OnlineOnly,
|
||||
/// <summary>
|
||||
/// Do not replace any scenes, additional scenes will be loaded as additive.
|
||||
/// </summary>
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb8e2c0fe3b9d3344a05810936861555
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,201 @@
|
||||
using FishNet.Object;
|
||||
using FishNet.Serializing.Helping;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Data about which scenes to load.
|
||||
/// </summary>
|
||||
public class SceneLoadData
|
||||
{
|
||||
/// <summary>
|
||||
/// When specified this scene will be set as the active scene after loading occurs.
|
||||
/// </summary>
|
||||
public SceneLookupData PreferredActiveScene = null;
|
||||
/// <summary>
|
||||
/// SceneLookupData for each scene to load.
|
||||
/// </summary>
|
||||
public SceneLookupData[] SceneLookupDatas = new SceneLookupData[0];
|
||||
/// <summary>
|
||||
/// NetworkObjects to move to the new scenes. Objects will be moved to the first scene.
|
||||
/// </summary>
|
||||
public NetworkObject[] MovedNetworkObjects = new NetworkObject[0];
|
||||
/// <summary>
|
||||
/// How to replace current scenes with new ones. When replacing scenes the first scene loaded will be set as the active scene, and the rest additive.
|
||||
/// </summary>
|
||||
public ReplaceOption ReplaceScenes = ReplaceOption.None;
|
||||
/// <summary>
|
||||
/// Parameters which may be set and will be included in load callbacks.
|
||||
/// </summary>
|
||||
public LoadParams Params = new LoadParams();
|
||||
/// <summary>
|
||||
/// Additional options to use for loaded scenes.
|
||||
/// </summary>
|
||||
public LoadOptions Options = new LoadOptions();
|
||||
|
||||
public SceneLoadData() { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene to load.</param>
|
||||
public SceneLoadData(Scene scene) : this(new Scene[] { scene }, null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneName">Scene to load by name.</param>
|
||||
public SceneLoadData(string sceneName) : this(new string[] { sceneName }, null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneHandle">Scene to load by handle.</param>
|
||||
public SceneLoadData(int sceneHandle) : this(new int[] { sceneHandle }, null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneHandle">Scene to load by handle.</param>
|
||||
/// <param name="sceneName">Scene to load by name.</param>
|
||||
public SceneLoadData(int sceneHandle, string sceneName) : this(new SceneLookupData(sceneHandle, sceneName)) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneLookupData">Scene to load by SceneLookupData.</param>
|
||||
public SceneLoadData(SceneLookupData sceneLookupData) : this(new SceneLookupData[] { sceneLookupData }) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scenes">Scenes to load.</param>
|
||||
public SceneLoadData(List<Scene> scenes) : this(scenes.ToArray(), null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneNames">Scenes to load by name.</param>
|
||||
public SceneLoadData(List<string> sceneNames) : this(sceneNames.ToArray(), null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneHandles">Scenes to load by handle.</param>
|
||||
public SceneLoadData(List<int> sceneHandles) : this(sceneHandles.ToArray(), null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scenes">Scenes to load.</param>
|
||||
public SceneLoadData(Scene[] scenes) : this(scenes, null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneNames">Scenes to load by name.</param>
|
||||
public SceneLoadData(string[] sceneNames) : this(sceneNames, null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneHandles">Scenes to load by handle.</param>
|
||||
public SceneLoadData(int[] sceneHandles) : this(sceneHandles, null) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneLookupDatas">Scenes to load by SceneLookupDatas.</param>
|
||||
public SceneLoadData(SceneLookupData[] sceneLookupDatas) : this(sceneLookupDatas, null) { }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene to load.</param>
|
||||
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
|
||||
public SceneLoadData(Scene scene, NetworkObject[] movedNetworkObjects)
|
||||
{
|
||||
SceneLookupData data = SceneLookupData.CreateData(scene);
|
||||
Construct(new SceneLookupData[] { data }, movedNetworkObjects);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scenes">Scenes to load.</param>
|
||||
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
|
||||
public SceneLoadData(Scene[] scenes, NetworkObject[] movedNetworkObjects)
|
||||
{
|
||||
SceneLookupData[] datas = SceneLookupData.CreateData(scenes);
|
||||
Construct(datas, movedNetworkObjects);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneNames">Scenes to load by Name.</param>
|
||||
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
|
||||
public SceneLoadData(string[] sceneNames, NetworkObject[] movedNetworkObjects)
|
||||
{
|
||||
SceneLookupData[] datas = SceneLookupData.CreateData(sceneNames);
|
||||
Construct(datas, movedNetworkObjects);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneHandles">Scenes to load by handle.</param>
|
||||
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
|
||||
public SceneLoadData(int[] sceneHandles, NetworkObject[] movedNetworkObjects)
|
||||
{
|
||||
SceneLookupData[] datas = SceneLookupData.CreateData(sceneHandles);
|
||||
Construct(datas, movedNetworkObjects);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneLookupDatas">Scenes to load by SceneLookupDatas.</param>
|
||||
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
|
||||
public SceneLoadData(SceneLookupData[] sceneLookupDatas, NetworkObject[] movedNetworkObjects)
|
||||
{
|
||||
Construct(sceneLookupDatas, movedNetworkObjects);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called at the end of every constructor.
|
||||
/// </summary>
|
||||
private void Construct(SceneLookupData[] datas, NetworkObject[] movedNetworkObjects)
|
||||
{
|
||||
SceneLookupDatas = datas;
|
||||
if (movedNetworkObjects == null)
|
||||
movedNetworkObjects = new NetworkObject[0];
|
||||
MovedNetworkObjects = movedNetworkObjects;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first Scene in SceneLookupDatas.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Scene GetFirstLookupScene()
|
||||
{
|
||||
foreach (SceneLookupData sld in SceneLookupDatas)
|
||||
{
|
||||
Scene result = sld.GetScene(out _);
|
||||
if (!string.IsNullOrEmpty(result.name))
|
||||
return result;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns if any data is invalid, such as null entries.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal bool DataInvalid()
|
||||
{
|
||||
//Null values.
|
||||
if (Params == null || MovedNetworkObjects == null || SceneLookupDatas == null ||
|
||||
Options == null)
|
||||
return true;
|
||||
//No lookups.
|
||||
if (SceneLookupDatas.Length == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecd4065158ab62047a074c594f245d90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,18 @@
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of scopes for a scene load or unload.
|
||||
/// </summary>
|
||||
public enum SceneScopeType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Scene action occured for all clients.
|
||||
/// </summary>
|
||||
Global = 0,
|
||||
/// <summary>
|
||||
/// Scene action occurred for specified clients.
|
||||
/// </summary>
|
||||
Connections = 1
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2be621eb04519a14eb2297a666b1bc2c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,116 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Data about which scenes to unload.
|
||||
/// </summary>
|
||||
public class SceneUnloadData
|
||||
{
|
||||
/// <summary>
|
||||
/// When specified this scene will be set as the active scene after unloading occurs.
|
||||
/// </summary>
|
||||
public SceneLookupData PreferredActiveScene = null;
|
||||
/// <summary>
|
||||
/// SceneLookupData for each scene to load.
|
||||
/// </summary>
|
||||
public SceneLookupData[] SceneLookupDatas = new SceneLookupData[0];
|
||||
/// <summary>
|
||||
/// Parameters which may be set and will be included in load callbacks.
|
||||
/// </summary>
|
||||
public UnloadParams Params = new UnloadParams();
|
||||
/// <summary>
|
||||
/// Additional options to use for loaded scenes.
|
||||
/// </summary>
|
||||
public UnloadOptions Options = new UnloadOptions();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public SceneUnloadData() { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene to unload.</param>
|
||||
public SceneUnloadData(Scene scene) : this(new Scene[] { scene }) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneName">Scene to unload by name.</param>
|
||||
public SceneUnloadData(string sceneName) : this(new string[] { sceneName }) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneHandle">Scene to unload by handle.</param>
|
||||
public SceneUnloadData(int sceneHandle) : this(new int[] { sceneHandle }) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scenes">Scenes to unload.</param>
|
||||
public SceneUnloadData(List<Scene> scenes) : this(scenes.ToArray()) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneNames">Scenes to unload by names.</param>
|
||||
public SceneUnloadData(List<string> sceneNames) : this(sceneNames.ToArray()) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneHandles">Scenes to unload by handles.</param>
|
||||
public SceneUnloadData(List<int> sceneHandles) : this(sceneHandles.ToArray()) { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scenes">Scenes to unload.</param>
|
||||
public SceneUnloadData(Scene[] scenes)
|
||||
{
|
||||
SceneLookupDatas = SceneLookupData.CreateData(scenes);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneNames">Scenes to unload by names.</param>
|
||||
public SceneUnloadData(string[] sceneNames)
|
||||
{
|
||||
SceneLookupDatas = SceneLookupData.CreateData(sceneNames);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneHandles">Scenes to unload by handles.</param>
|
||||
public SceneUnloadData(int[] sceneHandles)
|
||||
{
|
||||
SceneLookupDatas = SceneLookupData.CreateData(sceneHandles);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sceneLookupDatas">Scenes to unload by SceneLookupDatas.</param>
|
||||
public SceneUnloadData(SceneLookupData[] sceneLookupDatas)
|
||||
{
|
||||
SceneLookupDatas = sceneLookupDatas;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns if any data is invalid, such as null entries.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal bool DataInvalid()
|
||||
{
|
||||
//Null values.
|
||||
if (Params == null || SceneLookupDatas == null ||
|
||||
Options == null)
|
||||
return true;
|
||||
//No lookups.
|
||||
if (SceneLookupDatas.Length == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77cbfeea232e4ab44a4315b003ce6742
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,36 @@
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings to apply when loading a scene.
|
||||
/// </summary>
|
||||
public class UnloadOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Conditions to unloading a scene on the server.
|
||||
/// </summary>
|
||||
public enum ServerUnloadMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Unloads the scene if no more connections are within it.
|
||||
/// </summary>
|
||||
UnloadUnused = 0,
|
||||
/// <summary>
|
||||
/// Unloads scenes for connections but keeps scene loaded on server even if no connections are within it.
|
||||
/// </summary>
|
||||
KeepUnused = 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How to unload scenes on the server. UnloadUnused will unload scenes which have no more clients in them. KeepUnused will not unload a scene even when empty. ForceUnload will unload a scene regardless of if clients are still connected to it.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public ServerUnloadMode Mode = ServerUnloadMode.UnloadUnused;
|
||||
/// <summary>
|
||||
/// True if scenes should be loaded using addressables. This field only exists for optional use so the user may know if their queue data is using addressables.
|
||||
/// </summary>
|
||||
public bool Addressables;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3de31d76de313bc49aefba61135fdffc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,19 @@
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Additional user-crafted data which can be included in scene unload callbacks.
|
||||
/// </summary>
|
||||
public class UnloadParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Objects which are included in callbacks on the server when unloading a scene. Can be useful for including unique information about the scene, such as match id. These are not sent to clients; use ClientParams for this.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public object[] ServerParams = new object[0];
|
||||
/// <summary>
|
||||
/// Bytes which are sent to clients during scene unloads. Can contain any information.
|
||||
/// </summary>
|
||||
public byte[] ClientParams = new byte[0];
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bba3fbbe6ffbae4bb18d50c8c9b3b30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,53 @@
|
||||
using FishNet.Connection;
|
||||
using FishNet.Utility.Constant;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo(UtilityConstants.GENERATED_ASSEMBLY_NAME)]
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Data generated when unloading a scene.
|
||||
/// </summary>
|
||||
public class UnloadQueueData
|
||||
{
|
||||
/// <summary>
|
||||
/// Clients which receive this SceneQueueData. If Networked, all clients do. If Connections, only the specified Connections do.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public readonly SceneScopeType ScopeType;
|
||||
/// <summary>
|
||||
/// Connections to unload scenes for. Only valid on the server and when ScopeType is Connections.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public NetworkConnection[] Connections;
|
||||
/// <summary>
|
||||
/// SceneUnloadData to use.
|
||||
/// </summary>
|
||||
public SceneUnloadData SceneUnloadData = null;
|
||||
/// <summary>
|
||||
/// Current global scenes.
|
||||
/// </summary>
|
||||
public string[] GlobalScenes = new string[0];
|
||||
/// <summary>
|
||||
/// True if to iterate this queue data as server.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public readonly bool AsServer;
|
||||
|
||||
public UnloadQueueData() { }
|
||||
internal UnloadQueueData(SceneScopeType scopeType, NetworkConnection[] conns, SceneUnloadData sceneUnloadData, string[] globalScenes, bool asServer)
|
||||
{
|
||||
ScopeType = scopeType;
|
||||
Connections = conns;
|
||||
SceneUnloadData = sceneUnloadData;
|
||||
GlobalScenes = globalScenes;
|
||||
AsServer = asServer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea9c20d60381ea74f974fb87a7e78297
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,322 @@
|
||||
using FishNet.Managing.Logging;
|
||||
using FishNet.Serializing.Helping;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions for SceneLookupData.
|
||||
/// </summary>
|
||||
internal static class SceneLookupDataExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns Names from SceneLookupData.
|
||||
/// </summary>
|
||||
/// <param name="datas"></param>
|
||||
/// <returns></returns>
|
||||
public static string[] GetNames(this SceneLookupData[] datas)
|
||||
{
|
||||
string[] names = new string[datas.Length];
|
||||
for (int i = 0; i < datas.Length; i++)
|
||||
names[i] = datas[i].Name;
|
||||
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data container for looking up, loading, or unloading a scene.
|
||||
/// </summary>
|
||||
public class SceneLookupData
|
||||
{
|
||||
/// <summary>
|
||||
/// Handle of the scene. If value is 0, then handle is not used.
|
||||
/// </summary>
|
||||
public int Handle;
|
||||
/// <summary>
|
||||
/// Name of the scene.
|
||||
/// </summary>
|
||||
public string Name = string.Empty;
|
||||
/// <summary>
|
||||
/// Returns the scene name without a directory path should one exist.
|
||||
/// </summary>
|
||||
public string NameOnly => System.IO.Path.GetFileNameWithoutExtension(Name);
|
||||
/// <summary>
|
||||
/// Returns if this data is valid for use.
|
||||
/// Being valid does not mean that the scene exist, rather that there is enough data to try and lookup a scene.
|
||||
/// </summary>
|
||||
public bool IsValid => (Name != string.Empty || Handle != 0);
|
||||
|
||||
#region Const
|
||||
/// <summary>
|
||||
/// String to display when scene data is invalid.
|
||||
/// </summary>
|
||||
private const string INVALID_SCENE = "One or more scene information entries contain invalid data and have been skipped.";
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public SceneLookupData() { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene to generate from.</param>
|
||||
public SceneLookupData(Scene scene)
|
||||
{
|
||||
Handle = scene.handle;
|
||||
Name = scene.name;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name">Scene name to generate from.</param>
|
||||
public SceneLookupData(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="handle">Scene handle to generate from.</param>
|
||||
public SceneLookupData(int handle)
|
||||
{
|
||||
Handle = handle;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="handle">Scene handle to generate from.</param>
|
||||
/// <param name="name">Name to generate from if handle is 0.</param>
|
||||
public SceneLookupData(int handle, string name)
|
||||
{
|
||||
Handle = handle;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
#region Comparers.
|
||||
public static bool operator ==(SceneLookupData sldA, SceneLookupData sldB)
|
||||
{
|
||||
//One is null while the other is not.
|
||||
if ((sldA is null) != (sldB is null))
|
||||
return false;
|
||||
|
||||
/*If here both are either null or have value. */
|
||||
if (!(sldA is null))
|
||||
return sldA.Equals(sldB);
|
||||
else if (!(sldB is null))
|
||||
return sldB.Equals(sldA);
|
||||
|
||||
//Fall through indicates both are null.
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool operator !=(SceneLookupData sldA, SceneLookupData sldB)
|
||||
{
|
||||
//One is null while the other is not.
|
||||
if ((sldA is null) != (sldB is null))
|
||||
return true;
|
||||
|
||||
/*If here both are either null or have value. */
|
||||
if (!(sldA is null))
|
||||
return !sldA.Equals(sldB);
|
||||
else if (!(sldB is null))
|
||||
return !sldB.Equals(sldA);
|
||||
|
||||
//Fall through indicates both are null.
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Equals(SceneLookupData sld)
|
||||
{
|
||||
//Comparing instanced against null.
|
||||
if (sld is null)
|
||||
return false;
|
||||
|
||||
//True if both handles are empty.
|
||||
bool bothHandlesEmpty = (
|
||||
(this.Handle == 0) &&
|
||||
(sld.Handle == 0)
|
||||
);
|
||||
|
||||
//If both have handles and they match.
|
||||
if (!bothHandlesEmpty && sld.Handle == this.Handle)
|
||||
return true;
|
||||
//If neither have handles and name matches.
|
||||
else if (bothHandlesEmpty && sld.Name == this.Name)
|
||||
return true;
|
||||
|
||||
//Fall through.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = 2053068273;
|
||||
hashCode = hashCode * -1521134295 + Handle.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateData.
|
||||
/// <summary>
|
||||
/// Returns a new SceneLookupData.
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData CreateData(Scene scene) => new SceneLookupData(scene);
|
||||
/// <summary>
|
||||
/// Returns a new SceneLookupData.
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene name to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData CreateData(string name) => new SceneLookupData(name);
|
||||
/// <summary>
|
||||
/// Returns a new SceneLookupData.
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene handle to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData CreateData(int handle) => new SceneLookupData(handle);
|
||||
/// <summary>
|
||||
/// Returns a SceneLookupData collection.
|
||||
/// </summary>
|
||||
/// <param name="scenes">Scenes to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData[] CreateData(List<Scene> scenes) => CreateData(scenes.ToArray());
|
||||
/// <summary>
|
||||
/// Returns a SceneLookupData collection.
|
||||
/// </summary>
|
||||
/// <param name="names">Scene names to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData[] CreateData(List<string> names) => CreateData(names.ToArray());
|
||||
/// <summary>
|
||||
/// Returns a SceneLookupData collection.
|
||||
/// </summary>
|
||||
/// <param name="handles">Scene handles to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData[] CreateData(List<int> handles) => CreateData(handles.ToArray());
|
||||
/// <summary>
|
||||
/// Returns a SceneLookupData collection.
|
||||
/// </summary>
|
||||
/// <param name="scenes">Scenes to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData[] CreateData(Scene[] scenes)
|
||||
{
|
||||
bool invalidFound = false;
|
||||
List<SceneLookupData> result = new List<SceneLookupData>();
|
||||
foreach (Scene item in scenes)
|
||||
{
|
||||
if (!item.IsValid())
|
||||
{
|
||||
invalidFound = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
result.Add(CreateData(item));
|
||||
}
|
||||
|
||||
if (invalidFound)
|
||||
NetworkManager.StaticLogWarning(INVALID_SCENE);
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a SceneLookupData collection.
|
||||
/// </summary>
|
||||
/// <param name="names">Scene names to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData[] CreateData(string[] names)
|
||||
{
|
||||
bool invalidFound = false;
|
||||
List<SceneLookupData> result = new List<SceneLookupData>();
|
||||
foreach (string item in names)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item))
|
||||
{
|
||||
invalidFound = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
string nameOnly = System.IO.Path.GetFileNameWithoutExtension(item);
|
||||
result.Add(CreateData(nameOnly));
|
||||
}
|
||||
|
||||
if (invalidFound)
|
||||
NetworkManager.StaticLogWarning(INVALID_SCENE);
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a SceneLookupData collection.
|
||||
/// </summary>
|
||||
/// <param name="handles">Scene handles to create from.</param>
|
||||
/// <returns></returns>
|
||||
public static SceneLookupData[] CreateData(int[] handles)
|
||||
{
|
||||
bool invalidFound = false;
|
||||
List<SceneLookupData> result = new List<SceneLookupData>();
|
||||
foreach (int item in handles)
|
||||
{
|
||||
if (item == 0)
|
||||
{
|
||||
invalidFound = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
result.Add(CreateData(item));
|
||||
}
|
||||
|
||||
if (invalidFound)
|
||||
NetworkManager.StaticLogWarning(INVALID_SCENE);
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns the first scene found using Handle or Name, preferring Handle.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <param name="foundByHandle">True if scene was found by handle. Handle is always checked first.</param>
|
||||
public Scene GetScene(out bool foundByHandle)
|
||||
{
|
||||
foundByHandle = false;
|
||||
|
||||
if (Handle == 0 && string.IsNullOrEmpty(Name))
|
||||
{
|
||||
NetworkManager.StaticLogWarning("Scene handle and name is unset; scene cannot be returned.");
|
||||
return default;
|
||||
}
|
||||
|
||||
Scene result = default;
|
||||
|
||||
//Lookup my handle.
|
||||
if (Handle != 0)
|
||||
{
|
||||
result = SceneManager.GetScene(Handle);
|
||||
if (result.handle != 0)
|
||||
foundByHandle = true;
|
||||
}
|
||||
|
||||
//If couldnt find handle try by string.
|
||||
if (!foundByHandle)
|
||||
result = SceneManager.GetScene(NameOnly);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df1ac9b164e75da46bc52f4dd4fe30ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
2138
Assets/Packages/FishNet/Runtime/Managing/Scened/SceneManager.cs
Normal file
2138
Assets/Packages/FishNet/Runtime/Managing/Scened/SceneManager.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15895a51081447d46bda466e7e830c08
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: bf9191e2e07d29749bca3a1ae44e4bc8, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,93 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityScene = UnityEngine.SceneManagement.Scene;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
|
||||
public abstract class SceneProcessorBase : MonoBehaviour
|
||||
{
|
||||
#region Protected.
|
||||
/// <summary>
|
||||
/// SceneManager for this processor.
|
||||
/// </summary>
|
||||
protected SceneManager SceneManager;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this script for use.
|
||||
/// </summary>
|
||||
/// <param name="manager">SceneManager which will be utilizing this class.</param>
|
||||
public virtual void Initialize(SceneManager manager)
|
||||
{
|
||||
SceneManager = manager;
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when scene loading has begun.
|
||||
/// </summary>
|
||||
public virtual void LoadStart(LoadQueueData queueData) { }
|
||||
/// <summary>
|
||||
/// Called when scene loading has ended.
|
||||
/// </summary>
|
||||
public virtual void LoadEnd(LoadQueueData queueData) { }
|
||||
/// <summary>
|
||||
/// Called when scene unloading has begun within a load operation.
|
||||
/// </summary>
|
||||
public virtual void UnloadStart(LoadQueueData queueData) { }
|
||||
/// <summary>
|
||||
/// Called when scene unloading has ended within a load operation.
|
||||
/// </summary>
|
||||
public virtual void UnloadEnd(LoadQueueData queueData) { }
|
||||
/// <summary>
|
||||
/// Called when scene unloading has begun within an unload operation.
|
||||
/// </summary>
|
||||
public virtual void UnloadStart(UnloadQueueData queueData) { }
|
||||
/// <summary>
|
||||
/// Called when scene unloading has ended within an unload operation.
|
||||
/// </summary>
|
||||
public virtual void UnloadEnd(UnloadQueueData queueData) { }
|
||||
/// <summary>
|
||||
/// Begin loading a scene using an async method.
|
||||
/// </summary>
|
||||
/// <param name="sceneName">Scene name to load.</param>
|
||||
public abstract void BeginLoadAsync(string sceneName, LoadSceneParameters parameters);
|
||||
/// <summary>
|
||||
/// Begin unloading a scene using an async method.
|
||||
/// </summary>
|
||||
/// <param name="sceneName">Scene name to unload.</param>
|
||||
public abstract void BeginUnloadAsync(Scene scene);
|
||||
/// <summary>
|
||||
/// Returns if a scene load or unload percent is done.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract bool IsPercentComplete();
|
||||
/// <summary>
|
||||
/// Returns the progress on the current scene load or unload.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract float GetPercentComplete();
|
||||
/// <summary>
|
||||
/// Adds a scene to loaded scenes.
|
||||
/// </summary>
|
||||
/// <param name="scene">Scene loaded.</param>
|
||||
public virtual void AddLoadedScene(Scene scene) { }
|
||||
/// <summary>
|
||||
/// Returns scenes which were loaded during a load operation.
|
||||
/// </summary>
|
||||
public abstract List<Scene> GetLoadedScenes();
|
||||
/// <summary>
|
||||
/// Activates scenes which were loaded.
|
||||
/// </summary>
|
||||
public abstract void ActivateLoadedScenes();
|
||||
/// <summary>
|
||||
/// Returns if all asynchronized tasks are considered IsDone.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract IEnumerator AsyncsIsDone();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de3f29952a63dc341a7542a1f898cb12
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
356
Assets/Packages/FishNet/Runtime/Managing/Scened/SceneSpawner.cs
Normal file
356
Assets/Packages/FishNet/Runtime/Managing/Scened/SceneSpawner.cs
Normal file
@ -0,0 +1,356 @@
|
||||
|
||||
//using FishNet.Managing.Scened.Data;
|
||||
//using System;
|
||||
//using UnityEngine;
|
||||
//using UnityEngine.SceneManagement;
|
||||
|
||||
//namespace FishNet.Managing.Scened
|
||||
//{
|
||||
|
||||
// public static class SceneSpawner
|
||||
// {
|
||||
|
||||
// #region Prefab.
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(Scene scene, GameObject prefab)
|
||||
// {
|
||||
// return Instantiate<GameObject>(scene, prefab);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(Scene scene, GameObject prefab)
|
||||
// {
|
||||
// return Instantiate<T>(scene, prefab, prefab.transform.position, prefab.transform.rotation, null, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneReferenceData, prefab);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(SceneReferenceData sceneReferenceData, GameObject prefab)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneReferenceData);
|
||||
// return Instantiate<T>(scene, prefab, prefab.transform.position, prefab.transform.rotation, null, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(int sceneHandle, GameObject prefab)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneHandle, prefab, prefab.transform.position, prefab.transform.rotation, null);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(int sceneHandle, GameObject prefab)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneHandle);
|
||||
// return Instantiate<T>(scene, prefab, prefab.transform.position, prefab.transform.rotation, null, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(string sceneName, GameObject prefab)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneName, prefab);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(string sceneName, GameObject prefab)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneName);
|
||||
// return Instantiate<T>(scene, prefab, prefab.transform.position, prefab.transform.rotation, null, true);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
|
||||
|
||||
|
||||
// #region Prefab, Parent, WorldSpace
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(Scene scene, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true)
|
||||
// {
|
||||
// return Instantiate<GameObject>(scene, prefab, parent, instantiateInWorldSpace);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(Scene scene, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true)
|
||||
// {
|
||||
// return Instantiate<T>(scene, prefab, prefab.transform.position, prefab.transform.rotation, parent, instantiateInWorldSpace);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneReferenceData, prefab, parent, instantiateInWorldSpace);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(SceneReferenceData sceneReferenceData, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneReferenceData);
|
||||
// return Instantiate<T>(scene, prefab, prefab.transform.position, prefab.transform.rotation, parent, instantiateInWorldSpace);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(int sceneHandle, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneHandle, prefab, parent, instantiateInWorldSpace);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(int sceneHandle, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneHandle);
|
||||
// return Instantiate<T>(scene, prefab, prefab.transform.position, prefab.transform.rotation, parent, instantiateInWorldSpace);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(string sceneName, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneName, prefab, parent, instantiateInWorldSpace);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(string sceneName, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneName);
|
||||
// return Instantiate<T>(scene, prefab, prefab.transform.position, prefab.transform.rotation, parent, instantiateInWorldSpace);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
|
||||
|
||||
|
||||
// #region Prefab, Position, Rotation.
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation)
|
||||
// {
|
||||
// return Instantiate<GameObject>(scene, prefab, position, rotation);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation)
|
||||
// {
|
||||
// return Instantiate<T>(scene, prefab, position, rotation, null, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Vector3 position, Quaternion rotation)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneReferenceData, prefab, position, rotation);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(SceneReferenceData sceneReferenceData, GameObject prefab, Vector3 position, Quaternion rotation)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneReferenceData);
|
||||
// return Instantiate<T>(scene, prefab, position, rotation, null, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(int sceneHandle, GameObject prefab, Vector3 position, Quaternion rotation)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneHandle, prefab, position, rotation);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(int sceneHandle, GameObject prefab, Vector3 position, Quaternion rotation)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneHandle);
|
||||
// return Instantiate<T>(scene, prefab, position, rotation, null, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(string sceneName, GameObject prefab, Vector3 position, Quaternion rotation)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneName, prefab, position, rotation);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(string sceneName, GameObject prefab, Vector3 position, Quaternion rotation)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneName);
|
||||
// return Instantiate<T>(scene, prefab, position, rotation, null, true);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
|
||||
|
||||
|
||||
// #region Prefab, Position, Rotation, Parent.
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent)
|
||||
// {
|
||||
// return Instantiate<GameObject>(scene, prefab, position, rotation, parent);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent)
|
||||
// {
|
||||
// return Instantiate<T>(scene, prefab, position, rotation, parent, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneReferenceData, prefab, position, rotation, parent);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(SceneReferenceData sceneReferenceData, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneReferenceData);
|
||||
// return Instantiate<T>(scene, prefab, position, rotation, parent, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(int sceneHandle, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneHandle, prefab, position, rotation, parent);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(int sceneHandle, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneHandle);
|
||||
// return Instantiate<T>(scene, prefab, position, rotation, parent, true);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static GameObject Instantiate(string sceneName, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent)
|
||||
// {
|
||||
// return Instantiate<GameObject>(sceneName, prefab, position, rotation, parent);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// public static T Instantiate<T>(string sceneName, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent)
|
||||
// {
|
||||
// Scene scene = SceneManager.ReturnScene(sceneName);
|
||||
// return Instantiate<T>(scene, prefab, position, rotation, parent, true);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
|
||||
// #region Instantiator.
|
||||
// /// <summary>
|
||||
// /// Instantiates a prefab and moves it to a scene.
|
||||
// /// </summary>
|
||||
// /// <returns>Instantiated prefab or script.</returns>
|
||||
// private static T Instantiate<T>(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent, bool instantiateInWorldSpace)
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(scene.name))
|
||||
// {
|
||||
// Debug.LogWarning("Scene does not exist. Prefab cannot be instantiated.");
|
||||
// return default(T);
|
||||
// }
|
||||
|
||||
// GameObject result = MonoBehaviour.Instantiate(prefab, position, rotation);
|
||||
// if (result != null)
|
||||
// {
|
||||
// //Move to new scene first.
|
||||
// UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(result, scene);
|
||||
|
||||
// //Set parent and spaces.
|
||||
// if (parent != null)
|
||||
// {
|
||||
// result.transform.SetParent(parent);
|
||||
// //If to not instantiate in world space then update pos/rot to localspace.
|
||||
// if (!instantiateInWorldSpace)
|
||||
// {
|
||||
// result.transform.localPosition = position;
|
||||
// result.transform.localRotation = rotation;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //If was a gameobject then return as GO.
|
||||
// if (typeof(T) == typeof(GameObject))
|
||||
// return (T)Convert.ChangeType(result, typeof(GameObject));
|
||||
// //Otherwise use getcomponent on the type.
|
||||
// else
|
||||
// return result.GetComponent<T>();
|
||||
// }
|
||||
// //Couldn't be instantiated, return default of T.
|
||||
// else
|
||||
// {
|
||||
// return default(T);
|
||||
// }
|
||||
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
//}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 405b031a6ef64b346ae8c5ccbf07d8e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,21 @@
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Managing.Scened
|
||||
{
|
||||
public struct UnloadedScene
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly int Handle;
|
||||
|
||||
public UnloadedScene(Scene s)
|
||||
{
|
||||
Name = s.name;
|
||||
Handle = s.handle;
|
||||
}
|
||||
public UnloadedScene(string name, int handle)
|
||||
{
|
||||
Name = name;
|
||||
Handle = handle;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a51fea764b1081c4ab6308101f160f10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user