public static void CB_AddRespawnPoint() { // Will add this new tag to the inspector if it doesn't already exist E_Helpers.AddInspectorTag("RespawnPoint"); GameObject respawnPoint = new GameObject("Respawn Point"); respawnPoint.layer = 2; respawnPoint.tag = "RespawnPoint"; GameObject respawnPointParentGO = null; if (!GameObject.Find("Spawn Points")) { respawnPointParentGO = new GameObject("Spawn Points"); respawnPointParentGO.layer = 2; Debug.Log("Generated \"Spawn Points\" holder gameObject."); } else { respawnPointParentGO = GameObject.Find("Spawn Points"); } respawnPoint.transform.SetParent(respawnPointParentGO.transform); respawnPoint.transform.position = E_Helpers.PositionInFrontOfEditorCamera(); E_Helpers.SetObjectIcon(respawnPoint, E_Core.h_respawnPointIcon); Selection.activeGameObject = respawnPoint; Debug.Log("Added a new \"Respawn Point\" gameobject to the scene."); }
public static void CB_Scene_AddExit() { NetworkManager nm = GameObject.FindObjectOfType <NetworkManager>(); if (!nm) { if (EditorUtility.DisplayDialog("No Found Network Manager", "The \"NetworkManager\" component doesn't exist in this scene. Please add it before continuing.", "Okay")) { } return; } GameObject sceneManager = GameObject.Find("SceneManager"); if (!sceneManager) { sceneManager = new GameObject("SceneManager"); } GameObject exitPoint = new GameObject("Exit Point"); E_Helpers.SetObjectIcon(exitPoint, E_Core.h_sceneExitIcon); exitPoint.AddComponent <SceneTransition>(); exitPoint.AddComponent <SetLoadingScreen>(); SceneDatabase database = (SceneDatabase)AssetDatabase.LoadAssetAtPath(string.Format("Assets{0}Resources{0}ScenesDatabase{0}ScenesDatabase.asset", Path.DirectorySeparatorChar), typeof(SceneDatabase)); exitPoint.GetComponent <SceneTransition>().SetDatabase(database); exitPoint.GetComponent <SceneTransition>().sendAllTogether = nm.syncScenes; UnityEvent beforeTravel = (UnityEvent)exitPoint.GetComponent <SceneTransition>().GetType().GetField("BeforeTravel", E_Helpers.allBindings).GetValue(exitPoint.GetComponent <SceneTransition>()); if (beforeTravel == null) { exitPoint.GetComponent <SceneTransition>().GetType().GetField("BeforeTravel", E_Helpers.allBindings).SetValue(exitPoint.GetComponent <SceneTransition>(), new UnityEvent()); beforeTravel = (UnityEvent)exitPoint.GetComponent <SceneTransition>().GetType().GetField("BeforeTravel", E_Helpers.allBindings).GetValue(exitPoint.GetComponent <SceneTransition>()); } UnityEventTools.AddPersistentListener(beforeTravel, exitPoint.GetComponent <SetLoadingScreen>().EnableLoadingScreen); exitPoint.GetComponent <BoxCollider>().isTrigger = true; exitPoint.layer = 2; exitPoint.transform.SetParent(sceneManager.transform); exitPoint.transform.position = E_Helpers.PositionInFrontOfEditorCamera(); Selection.activeGameObject = exitPoint; Debug.Log("Successfully created scene exit point!"); }
public static void CB_AddSpawnPoint() { // Will add this new tag to the inspector if it doesn't already exist E_Helpers.AddInspectorTag("SpawnPoint"); GameObject spawnPoint = new GameObject("Player Spawn Point"); spawnPoint.layer = 2; spawnPoint.tag = "SpawnPoint"; if (!FindObjectOfType <NetworkManager>()) { if (EditorUtility.DisplayDialog("Missing Network Manager", "No NetworkManager object was found in this scene. Be sure to add one since that is what these spawn points are for. :) \r\n" + "\r\n" + "", "Okay")) { } } GameObject spawnPointParentGO = null; if (!GameObject.Find("Spawn Points")) { spawnPointParentGO = new GameObject("Spawn Points"); spawnPointParentGO.layer = 2; spawnPointParentGO.tag = "SpawnPoints"; Debug.Log("Generated \"Spawn Points\" holder gameObject."); } else { spawnPointParentGO = GameObject.Find("Spawn Points"); } spawnPoint.transform.SetParent(spawnPointParentGO.transform); spawnPoint.transform.position = E_Helpers.PositionInFrontOfEditorCamera(); E_Helpers.SetObjectIcon(spawnPoint, E_Core.h_spawnPointIcon); Selection.activeGameObject = spawnPoint; Debug.Log("Added a new \"Player Spawn Point\" gameobject to the scene."); }
public static void CB_Scene_AddEntrance() { GameObject sceneManager = GameObject.Find("SceneManager"); if (!sceneManager) { sceneManager = new GameObject("SceneManager"); } if (!E_Helpers.InspectorTagExists("LoadPoint")) { E_Helpers.AddInspectorTag("LoadPoint"); } GameObject entrancePoint = new GameObject("Scene Entrance Point"); E_Helpers.SetObjectIcon(entrancePoint, E_Core.h_sceneEntranceIcon); entrancePoint.layer = 2; entrancePoint.tag = "LoadPoint"; entrancePoint.transform.SetParent(sceneManager.transform); entrancePoint.transform.position = E_Helpers.PositionInFrontOfEditorCamera(); Selection.activeGameObject = entrancePoint; Debug.Log("Successfully created scene entrance point!"); }