using DungeonGenerator; using UnityEditor; using UnityEditor.SceneTemplate; using UnityEngine; using UnityEngine.SceneManagement; public class NewDungeonTemplatePipeline : ISceneTemplatePipeline { public virtual bool IsValidTemplateForInstantiation(SceneTemplateAsset sceneTemplateAsset) { return true; } public virtual void BeforeTemplateInstantiation(SceneTemplateAsset sceneTemplateAsset, bool isAdditive, string sceneName) { } public virtual void AfterTemplateInstantiation(SceneTemplateAsset sceneTemplateAsset, Scene scene, bool isAdditive, string sceneName) { Debug.Log("Scene Template Instantiated: " + sceneName); // Load a prefab from the Resources folder GameObject roomsParent = Resources.Load("RoomsParent"); if (roomsParent != null) { // Instantiate the prefab inside the scene GameObject instantiatedRoomsParent = Object.Instantiate(roomsParent); SceneManager.MoveGameObjectToScene(instantiatedRoomsParent, scene); // Ensure it's part of the scene DungeonMapLoader mapLoader = new DungeonMapLoader(); string dungeonMapPath = EditorUtility.OpenFilePanel("Select Dungeon", "Assets", "json"); mapLoader.AddDungeonRoomsToGameObject(instantiatedRoomsParent, dungeonMapPath); Debug.Log("Dungeon loaded from file."); } else { Debug.LogError("DungeonPrefab not found in Resources!"); } } }