IEnumerator loadMap() { yield return(null); MapGenScriptiable gen = Instantiate(mapGen); //Instantiate new copies of the rooms into the gen gen.GenMap(); mapGen = gen; DontDestroyOnLoad(mapGen); currentRoom = gen.rooms[0]; player = Instantiate(playerPrefab); player.transform.position = new Vector3(-100, -100, -100); DontDestroyOnLoad(player); }
public override void OnInspectorGUI() { MapGenScriptiable gen = target as MapGenScriptiable; serializedObject.Update(); usableRooms.DoLayoutList(); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); SpecialRooms.DoLayoutList(); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); targetWeapons.DoLayoutList(); serializedObject.ApplyModifiedProperties(); EditorGUI.BeginChangeCheck(); RoomScriptable startRoom = (RoomScriptable)EditorGUILayout.ObjectField(gen.startRoom, typeof(RoomScriptable), false); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(gen, "gen changed"); gen.startRoom = startRoom; EditorUtility.SetDirty(gen); } EditorGUI.BeginChangeCheck(); Vector3 size = EditorGUILayout.Vector2Field("Room Size", gen.Size); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(gen, "gen changed"); gen.Size = new Vector2(Mathf.Clamp(Mathf.Round(size.x), 1, 128), Mathf.Clamp(Mathf.Round(size.y), 1, 128)); EditorUtility.SetDirty(gen); } EditorGUI.BeginChangeCheck(); int iterations = EditorGUILayout.IntField("Iterations", gen.iterations); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(gen, "gen changed"); gen.iterations = iterations; EditorUtility.SetDirty(gen); } EditorGUI.BeginChangeCheck(); int enemies = EditorGUILayout.IntField("Target enemies", gen.targetEnemies); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(gen, "gen changed"); gen.targetEnemies = enemies; EditorUtility.SetDirty(gen); } EditorGUI.BeginChangeCheck(); int items = EditorGUILayout.IntField("Target Consumables", gen.targetConsumables); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(gen, "gen changed"); gen.targetConsumables = items; EditorUtility.SetDirty(gen); } if (GUILayout.Button("Generate Map")) { Undo.RecordObject(gen, "gen changed"); gen.GenMap(); EditorUtility.SetDirty(gen); } AssetDatabase.SaveAssets(); }