//using FishNet.Managing.Scened.Data; //using System; //using UnityEngine; //using UnityEngine.SceneManagement; //namespace FishNet.Managing.Scened //{ // public static class SceneSpawner // { // #region Prefab. // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(Scene scene, GameObject prefab) // { // return Instantiate(scene, prefab); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(Scene scene, GameObject prefab) // { // return Instantiate(scene, prefab, prefab.transform.position, prefab.transform.rotation, null, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab) // { // return Instantiate(sceneReferenceData, prefab); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab) // { // Scene scene = SceneManager.ReturnScene(sceneReferenceData); // return Instantiate(scene, prefab, prefab.transform.position, prefab.transform.rotation, null, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(int sceneHandle, GameObject prefab) // { // return Instantiate(sceneHandle, prefab, prefab.transform.position, prefab.transform.rotation, null); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(int sceneHandle, GameObject prefab) // { // Scene scene = SceneManager.ReturnScene(sceneHandle); // return Instantiate(scene, prefab, prefab.transform.position, prefab.transform.rotation, null, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(string sceneName, GameObject prefab) // { // return Instantiate(sceneName, prefab); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(string sceneName, GameObject prefab) // { // Scene scene = SceneManager.ReturnScene(sceneName); // return Instantiate(scene, prefab, prefab.transform.position, prefab.transform.rotation, null, true); // } // #endregion // #region Prefab, Parent, WorldSpace // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(Scene scene, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true) // { // return Instantiate(scene, prefab, parent, instantiateInWorldSpace); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(Scene scene, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true) // { // return Instantiate(scene, prefab, prefab.transform.position, prefab.transform.rotation, parent, instantiateInWorldSpace); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true) // { // return Instantiate(sceneReferenceData, prefab, parent, instantiateInWorldSpace); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true) // { // Scene scene = SceneManager.ReturnScene(sceneReferenceData); // return Instantiate(scene, prefab, prefab.transform.position, prefab.transform.rotation, parent, instantiateInWorldSpace); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(int sceneHandle, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true) // { // return Instantiate(sceneHandle, prefab, parent, instantiateInWorldSpace); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(int sceneHandle, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true) // { // Scene scene = SceneManager.ReturnScene(sceneHandle); // return Instantiate(scene, prefab, prefab.transform.position, prefab.transform.rotation, parent, instantiateInWorldSpace); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(string sceneName, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true) // { // return Instantiate(sceneName, prefab, parent, instantiateInWorldSpace); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(string sceneName, GameObject prefab, Transform parent, bool instantiateInWorldSpace = true) // { // Scene scene = SceneManager.ReturnScene(sceneName); // return Instantiate(scene, prefab, prefab.transform.position, prefab.transform.rotation, parent, instantiateInWorldSpace); // } // #endregion // #region Prefab, Position, Rotation. // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation) // { // return Instantiate(scene, prefab, position, rotation); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation) // { // return Instantiate(scene, prefab, position, rotation, null, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Vector3 position, Quaternion rotation) // { // return Instantiate(sceneReferenceData, prefab, position, rotation); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Vector3 position, Quaternion rotation) // { // Scene scene = SceneManager.ReturnScene(sceneReferenceData); // return Instantiate(scene, prefab, position, rotation, null, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(int sceneHandle, GameObject prefab, Vector3 position, Quaternion rotation) // { // return Instantiate(sceneHandle, prefab, position, rotation); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(int sceneHandle, GameObject prefab, Vector3 position, Quaternion rotation) // { // Scene scene = SceneManager.ReturnScene(sceneHandle); // return Instantiate(scene, prefab, position, rotation, null, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(string sceneName, GameObject prefab, Vector3 position, Quaternion rotation) // { // return Instantiate(sceneName, prefab, position, rotation); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(string sceneName, GameObject prefab, Vector3 position, Quaternion rotation) // { // Scene scene = SceneManager.ReturnScene(sceneName); // return Instantiate(scene, prefab, position, rotation, null, true); // } // #endregion // #region Prefab, Position, Rotation, Parent. // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) // { // return Instantiate(scene, prefab, position, rotation, parent); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(Scene scene, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) // { // return Instantiate(scene, prefab, position, rotation, parent, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) // { // return Instantiate(sceneReferenceData, prefab, position, rotation, parent); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(SceneReferenceData sceneReferenceData, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) // { // Scene scene = SceneManager.ReturnScene(sceneReferenceData); // return Instantiate(scene, prefab, position, rotation, parent, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(int sceneHandle, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) // { // return Instantiate(sceneHandle, prefab, position, rotation, parent); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(int sceneHandle, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) // { // Scene scene = SceneManager.ReturnScene(sceneHandle); // return Instantiate(scene, prefab, position, rotation, parent, true); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static GameObject Instantiate(string sceneName, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) // { // return Instantiate(sceneName, prefab, position, rotation, parent); // } // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // public static T Instantiate(string sceneName, GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) // { // Scene scene = SceneManager.ReturnScene(sceneName); // return Instantiate(scene, prefab, position, rotation, parent, true); // } // #endregion // #region Instantiator. // /// // /// Instantiates a prefab and moves it to a scene. // /// // /// Instantiated prefab or script. // private static T Instantiate(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(); // } // //Couldn't be instantiated, return default of T. // else // { // return default(T); // } // } // #endregion // } //}