/// <summary> /// Checks the components. /// </summary> protected override void CheckComponents() { if (_drawer == null) { _drawer = new SceneEntityDrawer(PANEL_TITLE); } if (_favDrawer == null) { _favDrawer = new SceneEntityDrawer(PANEL_TITLE); } if (_screenshotDrawer == null) { _screenshotDrawer = new ScreenshotDrawer(); } if (_scrolls == null) { _scrolls = new ScrollableContainer(PANEL_TITLE, true); } if (_folders == null) { _folders = new FolderContainer(PANEL_TITLE, true); } if (_database == null) { _database = SceneDatabaseProvider.GetDatabase(this); } }
private void AddNetworkManagerToScene() { // Will add this new tag to the inspector if it doesn't already exist E_Helpers.AddInspectorTag("SpawnPoint"); GameObject _target = null; if (FindObjectOfType <NetworkManager>()) { _target = FindObjectOfType <NetworkManager>().gameObject; } if (!_target) { _target = new GameObject("Network Manager"); } if (!_target.GetComponent <NetworkManager>()) { _target.AddComponent <NetworkManager>(); } if (_target.GetComponent <NetworkManager>().defaultSpawnPoint == null) { GameObject spawnPoints = (GameObject.Find("Spawn Points")) ? GameObject.Find("Spawn Points") : new GameObject("Spawn Points"); GameObject spawnPoint = (GameObject.Find("Player Spawn Point")) ? GameObject.Find("Player Spawn Point") : new GameObject("Player Spawn Point"); E_Helpers.SetObjectIcon(spawnPoint, E_Core.h_spawnPointIcon); _target.GetComponent <NetworkManager>().defaultSpawnPoint = spawnPoint.transform; spawnPoints.layer = 2; spawnPoint.layer = 2; spawnPoint.tag = "SpawnPoint"; spawnPoint.transform.SetParent(spawnPoints.transform); } if (_target.GetComponent <NetworkManager>().database == null) { if (System.IO.File.Exists("Assets/Resources/ScenesDatabase/ScenesDatabase.asset")) { SceneDatabase database = AssetDatabase.LoadAssetAtPath <SceneDatabase>("Assets/Resources/ScenesDatabase/ScenesDatabase.asset"); if (database) { _target.GetComponent <NetworkManager>().database = database; } } else { Debug.LogWarning("Was unable to automatically add a \"SceneDatabase\" to the database entry on the NetworkManager. Remember to add one before making your final build!"); } } E_Helpers.SetObjectIcon(_target, E_Core.h_networkIcon); Selection.activeGameObject = _target; _target.layer = 2; // Ignore Raycast Layer if (!_target.GetComponent <PlayerRespawn>()) { _target.AddComponent <PlayerRespawn>(); } _target.GetComponent <PlayerRespawn>().visualCountdown = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/InvectorMultiplayer/UI/RespawnCounter.prefab"); if (EditorUtility.DisplayDialog("Friendly Reminder", "Remember to adjust the spawn point to where you want it to be. \r\n" + "\r\n", "Okay")) { Debug.Log("Successfully added the \"Network Manager\" gameobject and assigned a Spawn Point."); } }
/// <summary> /// Load scene from given dataset /// </summary> /// <param name="dataSet">dataset</param> /// <returns></returns> public List <Scene> LoadScene(DataSet dataSet) { SceneDatabase sceneDatabase = new SceneDatabase(); sceneDatabase.Merge(dataSet); List <Scene> sceneList = new List <Scene>(); DataRow[] rows = sceneDatabase._Scene.Select(); for (int i = 0; i < rows.Length; i++) { Scene scene = LoadScene(rows[i]); DataView cameraView = new DataView(sceneDatabase.Camera); DataView LightView = new DataView(sceneDatabase.Light); Camera camera = ParseCamera(cameraView, scene.ID); Light light = ParseLight(LightView, scene.ID); scene.SetCamera(camera); scene.SetLight(light); LoadObjects(sceneDatabase, scene); sceneList.Add(scene); } return(sceneList); }
public void computeCameraPositions(SceneDatabase sceneDB) { float shortestDist = float.MaxValue; float maxDist, minDist, curDist; for (int i = 0; i < sceneDB.GetNumGeom(); i++) { RTGeometry g = sceneDB.GetGeom(i); maxDist = (mEye - g.Max).Length(); minDist = (mEye - g.Min).Length(); if (maxDist < minDist) { curDist = maxDist; } else { curDist = minDist; } if (curDist < shortestDist) { shortestDist = curDist; } }// end for float eyeSeparation = (shortestDist / 30f);// +0.25f; leftCamera = mEye + mSideVec * eyeSeparation / 2f; rightCamera = mEye - mSideVec * eyeSeparation / 2f; }
protected override void OnEnable() { #region Properties autoTravel = serializedObject.FindProperty("autoTravel"); buttonToTravel = serializedObject.FindProperty("buttonToTravel"); activeOnEnter = serializedObject.FindProperty("activeOnEnter"); LoadSceneName = serializedObject.FindProperty("LoadSceneName"); SpawnAtPoint = serializedObject.FindProperty("SpawnAtPoint"); inspectorDatabase = serializedObject.FindProperty("database"); sendAllTogether = serializedObject.FindProperty("sendAllTogether"); OnOwnerEnterTrigger = serializedObject.FindProperty("OnOwnerEnterTrigger"); OnOwnerExitTrigger = serializedObject.FindProperty("OnOwnerExitTrigger"); OnAnyPlayerEnterTrigger = serializedObject.FindProperty("OnAnyPlayerEnterTrigger"); OnAnyPlayerExitTrigger = serializedObject.FindProperty("OnAnyPlayerExitTrigger"); BeforeTravel = serializedObject.FindProperty("BeforeTravel"); #endregion sceneNames.Clear(); database = (SceneDatabase)inspectorDatabase.objectReferenceValue; if (!database) { selectedDatabaseIndex = -1; } else { for (int i = 0; i < database.storedScenesData.Count; i++) { if (database.storedScenesData[i].sceneName == LoadSceneName.stringValue) { selectedDatabaseIndex = i; previous_selectedDatabaseIndex = i; } sceneNames.Add(database.storedScenesData[i].sceneName); } if (selectedDatabaseIndex != -1) { for (int i = 0; i < database.storedScenesData[selectedDatabaseIndex].entrancePoints.Count; i++) { if (database.storedScenesData[selectedDatabaseIndex].entrancePoints[i] == SpawnAtPoint.stringValue) { selectedEntrancePointIndex = i; break; } } } else { selectedEntrancePointIndex = 0; selectedEntrancePointIndex = -1; } } error = new GUIStyle(); error.normal.textColor = Color.red; //Get Available Buttons availableInputs.Clear(); availableInputs = E_Helpers.GetAllInputAxis(); base.OnEnable(); }
public static int InsertScene(SceneDatabase sceneDatabase) { SceneRow row = sceneDatabase._Scene.NewSceneRow(); sceneDatabase._Scene.Rows.Add(row); sceneDatabase._Scene.AcceptChanges(); return(row.id); }
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 CreateTestProject(SceneDatabase sceneDatabase) { int sceneID = InsertScene(sceneDatabase); sceneDatabase.Floor.Rows.Add(new Object[] { null, sceneID, "-10;0;-10", "10;0;10", 0.6, 0.4, 0, "1;1;1", "0;0;0" }); sceneDatabase.Sphere.Rows.Add(new Object[] { null, sceneID, "0;2;0", 2, 0.375, 0.125, 0.5, "0.25;0.5;1" }); sceneDatabase.Block.Rows.Add(new Object[] { null, sceneID, "-5;0.75;-5", "5;3.75;-6", 1, 0, 0, "1;0.5;0.25" }); //sceneDatabase.Camera.Rows.Add(new Object[] { null, sceneID, "0;15;0", "0;-1;0", "0;0;1", 60 }); // Top down look sceneDatabase.Camera.Rows.Add(new Object[] { null, sceneID, "5.3368;8.0531;9.8769", "-0.38363;-0.42482;-0.82", "-0.16485;0.90515;-0.391826", 60 }); sceneDatabase.Light.Rows.Add(new Object[] { null, sceneID, "-15;10;20", 1, "0;0;0" }); sceneDatabase.AcceptChanges(); }
private void OnEnable() { if (!_skin) { _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath); } //Make window title this.titleContent = new GUIContent("Scenes Database", null, "List Of All Transition Scenes/Points."); SceneDatabase database = (SceneDatabase)AssetDatabase.LoadAssetAtPath("Assets/Resources/ScenesDatabase/ScenesDatabase.asset", typeof(SceneDatabase)); databaseScenes.Clear(); if (database) { databaseScenes = database.storedScenesData; } }
public static void Save(Scene scene, string path) { SceneDatabase sceneDatabase = new SceneDatabase(); int sceneID = InsertScene(sceneDatabase); foreach (AObject aObject in scene.allObjects) { if (aObject.GetType() == typeof(Floor)) { Floor floor = (Floor)aObject; sceneDatabase.Floor.Rows.Add(new Object[] { null, sceneID, floor.a.X.ToString(CultureInfo.InvariantCulture) + ";" + floor.a.Y.ToString(CultureInfo.InvariantCulture) + ";" + floor.a.Z.ToString(CultureInfo.InvariantCulture), floor.c.X.ToString(CultureInfo.InvariantCulture) + ";" + floor.c.Y.ToString(CultureInfo.InvariantCulture) + ";" + floor.c.Z.ToString(CultureInfo.InvariantCulture), floor.kd, floor.ks, floor.kt, "1;1;1", "0;0;0" }); } else if (aObject.GetType() == typeof(Sphere)) { Sphere sphere = (Sphere)aObject; sceneDatabase.Sphere.Rows.Add(new Object[] { null, sceneID, sphere.xPos.ToString(CultureInfo.InvariantCulture) + ";" + sphere.yPos.ToString(CultureInfo.InvariantCulture) + ";" + sphere.zPos.ToString(CultureInfo.InvariantCulture), sphere.diameter.ToString(CultureInfo.InvariantCulture), sphere.kd, sphere.ks, sphere.kt, sphere.color.r.ToString(CultureInfo.InvariantCulture) + ";" + sphere.color.g.ToString(CultureInfo.InvariantCulture) + ";" + sphere.color.b.ToString(CultureInfo.InvariantCulture) }); } else if (aObject.GetType() == typeof(Block)) { Block block = (Block)aObject; sceneDatabase.Block.Rows.Add(new Object[] { null, sceneID, block.a.X.ToString(CultureInfo.InvariantCulture) + ";" + block.a.Y.ToString(CultureInfo.InvariantCulture) + ";" + block.a.Z.ToString(CultureInfo.InvariantCulture), block.c1.X.ToString(CultureInfo.InvariantCulture) + ";" + block.c1.Y.ToString(CultureInfo.InvariantCulture) + ";" + block.c1.Z.ToString(CultureInfo.InvariantCulture), block.kd, block.ks, block.kt, block.color.r.ToString(CultureInfo.InvariantCulture) + ";" + block.color.g.ToString(CultureInfo.InvariantCulture) + ";" + block.color.b.ToString(CultureInfo.InvariantCulture) }); } } Camera camera = scene.camera; sceneDatabase.Camera.Rows.Add(new Object[] { null, sceneID, camera.location.X.ToString(CultureInfo.InvariantCulture) + ";" + camera.location.Y.ToString(CultureInfo.InvariantCulture) + ";" + camera.location.Z.ToString(CultureInfo.InvariantCulture), camera.direction.x.ToString(CultureInfo.InvariantCulture) + ";" + camera.direction.y.ToString(CultureInfo.InvariantCulture) + ";" + camera.direction.z.ToString(CultureInfo.InvariantCulture), camera.up.x.ToString(CultureInfo.InvariantCulture) + ";" + camera.up.y.ToString(CultureInfo.InvariantCulture) + ";" + camera.up.z.ToString(CultureInfo.InvariantCulture), camera.fovy }); Light light = scene.light; sceneDatabase.Light.Rows.Add(new Object[] { null, sceneID, camera.location.X.ToString(CultureInfo.InvariantCulture) + ";" + camera.location.Y.ToString(CultureInfo.InvariantCulture) + ";" + camera.location.Z.ToString(CultureInfo.InvariantCulture), 1, "0;0;0" }); DatabaseHandler.Save(sceneDatabase, path); }
public void computeCameraPositions(SceneDatabase sceneDB) { float shortestDist = float.MaxValue; float maxDist, minDist, curDist; for (int i = 0; i < sceneDB.GetNumGeom(); i++) { RTGeometry g = sceneDB.GetGeom(i); maxDist = (mEye - g.Max).Length(); minDist = (mEye - g.Min).Length(); if (maxDist < minDist) curDist = maxDist; else curDist = minDist; if (curDist < shortestDist) shortestDist = curDist; }// end for float eyeSeparation = (shortestDist / 30f);// +0.25f; leftCamera = mEye + mSideVec * eyeSeparation / 2f; rightCamera = mEye - mSideVec * eyeSeparation / 2f; }
/// <summary> /// Loads objects from scene database /// </summary> /// <param name="sceneDatabase">scene database</param> /// <param name="scene">scene</param> private void LoadObjects(SceneDatabase sceneDatabase, Scene scene) { DataView blockView = new DataView(sceneDatabase.Block); DataView floorView = new DataView(sceneDatabase.Floor); DataView sphereView = new DataView(sceneDatabase.Sphere); List <Block> blocks = ParseBlocks(blockView, scene.ID); Floor floor = ParseFloor(floorView, scene.ID); List <Sphere> spheres = ParseSpheres(sphereView, scene.ID); foreach (Block block in blocks) { scene.allObjects.Add(block); } if (floor != null) { scene.allObjects.Add(floor); } foreach (Sphere sphere in spheres) { scene.allObjects.Add(sphere); } }
public RT3DCamera(RTCamera c, SceneDatabase sceneDB) : base(c) { computeCameraPositions(sceneDB); }
public RT3DCamera(CommandFileParser parser, SceneDatabase sceneDB) : base(parser) { computeCameraPositions(sceneDB); }
public ToolsDrawer() : base() { _database = SceneDatabaseProvider.GetDatabase(this); }
/// <summary> /// Used for automation. Sets the `database` variable with the input sceneDatabase. /// </summary> /// <param name="input">SceneDatabase type, the sceneDatabase to have this component reference</param> public virtual void SetDatabase(SceneDatabase input) { database = input; }
public RT3DCamera(RTCamera c, SceneDatabase sceneDB) : base(c) { computeCameraPositions(sceneDB); }
public RT3DCamera(CommandFileParser parser, SceneDatabase sceneDB) : base(parser) { computeCameraPositions(sceneDB); }