From c781c03b4fe1b480b3f4b7645cc30211129eed18 Mon Sep 17 00:00:00 2001 From: njh Date: Mon, 9 Feb 2026 11:27:58 +0900 Subject: [PATCH] =?UTF-8?q?fix=20=EC=94=AC=20=EC=9D=B4=EB=8F=99=20?= =?UTF-8?q?=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UVC/UI/Commands/MoveToLineCommnad.cs | 8 +- .../ObjectCommand/ChangedFloorCommand.cs | 45 +++++++++- .../Managements/MachineInfoItemManager.cs | 7 ++ Assets/Scripts/ChunilENG/Objects/Building.cs | 4 +- Assets/Scripts/Data/Data_Chunil.asset | 3 + Assets/Scripts/Data/Data_HyundaiWIA.asset | 3 + Assets/Scripts/Data/Data_KEPCO.asset | 3 + Assets/Scripts/Manager/SceneController.cs | 84 +++++++++++++++++ .../Scripts/Manager/SceneController.cs.meta | 2 + Assets/Scripts/UI/ProjectData.cs | 7 +- Assets/Scripts/UI/ProjectListController.cs | 89 +++++-------------- 11 files changed, 179 insertions(+), 76 deletions(-) create mode 100644 Assets/Scripts/Manager/SceneController.cs create mode 100644 Assets/Scripts/Manager/SceneController.cs.meta diff --git a/Assets/DownloadAssets/XRLib/Scripts/UVC/UI/Commands/MoveToLineCommnad.cs b/Assets/DownloadAssets/XRLib/Scripts/UVC/UI/Commands/MoveToLineCommnad.cs index 4eae058d..450c7781 100644 --- a/Assets/DownloadAssets/XRLib/Scripts/UVC/UI/Commands/MoveToLineCommnad.cs +++ b/Assets/DownloadAssets/XRLib/Scripts/UVC/UI/Commands/MoveToLineCommnad.cs @@ -31,11 +31,11 @@ namespace UVC.UI.Commands //var building = ChunilENGSceneMain.Instance.building; //var floorIndex = target.y > 5f ? 2 : 1; //building.SetFloor(floorIndex); - //controller.currentDistance = curDistance; - //controller.currentElevation = curElevation; - //controller.currentAzimuth = curAzimuth; + controller.currentDistance = curDistance; + controller.currentElevation = curElevation; + controller.currentAzimuth = curAzimuth; - //controller.SetTargetPos(target); + controller.SetTargetPos(target); } } diff --git a/Assets/Scripts/ChunilENG/Command/ObjectCommand/ChangedFloorCommand.cs b/Assets/Scripts/ChunilENG/Command/ObjectCommand/ChangedFloorCommand.cs index 07bdabe0..f9e4e585 100644 --- a/Assets/Scripts/ChunilENG/Command/ObjectCommand/ChangedFloorCommand.cs +++ b/Assets/Scripts/ChunilENG/Command/ObjectCommand/ChangedFloorCommand.cs @@ -1,18 +1,59 @@ -using UVC.UI.Commands; +using ChunilENG.Management; using OCTOPUS_TWIN; +using UnityEngine; +using UnityEngine.InputSystem.XR; +using UVC.UI.Commands; namespace ChunilENG.Command { public class ChangedFloorCommand : ICommand { private int floorIndex; + private OrbitalController controller; public ChangedFloorCommand(int floorIndex) { this.floorIndex = floorIndex; + controller = OctopusTwinAppMain.Instance.cameraController; } - public void Execute(object? parameter = null) + public async void Execute(object? parameter = null) { + var projectCotnroller = OctopusTwinAppMain.Instance.projectListController; + if (UILoading.Instance != null) + { + UILoading.Instance.LoadProject(() => projectCotnroller.SceneTransition(floorIndex)); + } + var uiIsActive = floorIndex == 2 ? true : false; + var targetPos = Vector3.zero; + var curDistance = 0f; + var curElevation = 0f; + var curAzimuth= 0f; + if (uiIsActive) + { + targetPos = new Vector3(17f, 0.05f, -2.806954f); + curDistance = 10f; + curElevation = 23f; + curAzimuth = 305f; + + } + else + { + targetPos = new Vector3(26.7f, 20f, 205.3f); + curDistance = 60f; + curElevation = 56; + curAzimuth = 136f; + + } + controller.currentDistance = curDistance; + controller.currentElevation = curElevation; + controller.currentAzimuth = curAzimuth; + + controller.SetTargetPos(targetPos); + var manager = ChunilENGSceneMain.Instance.GetManager(); + if (manager != null) + manager.ActiveIcons(uiIsActive); + //ī޶ ̵Ű. + //var building = ChunilENGSceneMain.Instance.building; //building.SetFloor(floorIndex); diff --git a/Assets/Scripts/ChunilENG/Managements/MachineInfoItemManager.cs b/Assets/Scripts/ChunilENG/Managements/MachineInfoItemManager.cs index fa72483c..2b053508 100644 --- a/Assets/Scripts/ChunilENG/Managements/MachineInfoItemManager.cs +++ b/Assets/Scripts/ChunilENG/Managements/MachineInfoItemManager.cs @@ -148,5 +148,12 @@ namespace ChunilENG.Management return viewPos.x > -0.1f && viewPos.x < 1.1f && viewPos.y > -0.1f && viewPos.y < 1.1f; } + public void ActiveIcons(bool isActive) + { + foreach(var icon in itemToMachines.Keys) + { + icon.gameObject.SetActive(isActive); + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/ChunilENG/Objects/Building.cs b/Assets/Scripts/ChunilENG/Objects/Building.cs index fd2b56d1..1a830702 100644 --- a/Assets/Scripts/ChunilENG/Objects/Building.cs +++ b/Assets/Scripts/ChunilENG/Objects/Building.cs @@ -92,10 +92,12 @@ namespace ChunilENG { if (OctopusTwinAppMain.Instance.cameraController == null) return; - + if (hideObject == null) + return; var cam = OctopusTwinAppMain.Instance.cameraController.Camera; //if(>) var isActive = cam.transform.position.y<8f ? true : false; + hideObject.gameObject.SetActive(isActive); } } diff --git a/Assets/Scripts/Data/Data_Chunil.asset b/Assets/Scripts/Data/Data_Chunil.asset index cc554132..0d877ff8 100644 --- a/Assets/Scripts/Data/Data_Chunil.asset +++ b/Assets/Scripts/Data/Data_Chunil.asset @@ -16,10 +16,13 @@ MonoBehaviour: description: "Location: \uC778\uCC9C\uAD11\uC5ED\uC2DC \uB0A8\uB3D9\uAD6C \uACE0\uC794\uB3D9 727-4\nFile Size: 14.4MB \nLast Updated: 2026.02.11" thumbnail: {fileID: 21300000, guid: 205401cea8bd275449563f2073f42a43, type: 3} + curSceneStatus: 1 modelPrefab: {fileID: 1600303972707744018, guid: 02de84299dbbd354fa8fe07b680d5d8c, type: 3} sceneAssets: - {fileID: 102900000, guid: eda0b8fb7e8c03642a26d0c819eb1630, type: 3} + - {fileID: 102900000, guid: 4496a3dbb8d263043a4460bac5382ac5, type: 3} volumeProfiles: + - {fileID: 11400000, guid: effb784cf609a224abefb3ce73fa5e37, type: 2} - {fileID: 11400000, guid: acb38c230e250d64fbb3abdd5aeac83c, type: 2} staticCanvasPrefab: {fileID: 2790366768964733958, guid: 8d9932723a4c65b43b24708f39835e52, type: 3} popupCanvasPrefab: {fileID: 6863753461202511297, guid: 0312eabdb9db59f41b04acd492040a66, type: 3} diff --git a/Assets/Scripts/Data/Data_HyundaiWIA.asset b/Assets/Scripts/Data/Data_HyundaiWIA.asset index e4b8c775..c409ab39 100644 --- a/Assets/Scripts/Data/Data_HyundaiWIA.asset +++ b/Assets/Scripts/Data/Data_HyundaiWIA.asset @@ -16,7 +16,10 @@ MonoBehaviour: description: "Location: \uACBD\uC0C1\uB0A8\uB3C4 \uCC3D\uC6D0\uC2DC \uC131\uC0B0\uAD6C \uC815\uB3D9\uB85C 153 ?\nFile Size: 15MB\nLast Updated: 2026.02.11" thumbnail: {fileID: 21300000, guid: eb13fc16ac6f16049acb9ccdd516c757, type: 3} + curSceneStatus: 3 modelPrefab: {fileID: 7895599977219415672, guid: 1640d857ae03ade4f958a521e19f11cd, type: 3} + sceneAssets: [] + volumeProfiles: [] staticCanvasPrefab: {fileID: 8033998068328256001, guid: 257ded03459cccb49b84a69fb54037de, type: 3} popupCanvasPrefab: {fileID: 3178617709267424133, guid: f26776b9f8433c34b9e254b2a145b73b, type: 3} sceneMain: {fileID: 3953432803056626161, guid: a35446b7bf8d6bf4595dac237037fcbd, type: 3} diff --git a/Assets/Scripts/Data/Data_KEPCO.asset b/Assets/Scripts/Data/Data_KEPCO.asset index 8b0ebf32..2fc3ce7f 100644 --- a/Assets/Scripts/Data/Data_KEPCO.asset +++ b/Assets/Scripts/Data/Data_KEPCO.asset @@ -16,7 +16,10 @@ MonoBehaviour: description: "Location: \uACBD\uAE30\uB3C4 \uC758\uC815\uBD80\uC2DC \uC790\uC77C\uB3D9\nFile Size: 13MB\nLast Updated: 2026.02.11" thumbnail: {fileID: 21300000, guid: 27104938b8e6c48428b4267d662a7299, type: 3} + curSceneStatus: 2 modelPrefab: {fileID: 1364758469199115521, guid: 423036aa0a8d7e54896acc2d79cf08b5, type: 3} + sceneAssets: [] + volumeProfiles: [] staticCanvasPrefab: {fileID: 9115987721486925841, guid: df39e435fbc6b27458c0ced9b20b0bd7, type: 3} popupCanvasPrefab: {fileID: 6944805395147841475, guid: 211ab265afe9f854bae51f1a2602c3f5, type: 3} sceneMain: {fileID: 5850141579646257595, guid: 2b7f55830958f804aaad00ae1d4bbe6a, type: 3} diff --git a/Assets/Scripts/Manager/SceneController.cs b/Assets/Scripts/Manager/SceneController.cs new file mode 100644 index 00000000..42d01159 --- /dev/null +++ b/Assets/Scripts/Manager/SceneController.cs @@ -0,0 +1,84 @@ +using Cysharp.Threading.Tasks; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace OCTOPUS_TWIN.Management +{ + public enum SceneStatus + { + None, + Chunil, + KepCo, + HyundaiWia + } + public class SceneController + { + private Object currScene; + private Object PrevScene; + private SceneStatus curSceneStatus; + public async UniTask SceneChange(Object scene, SceneStatus sceneStatus) + { + if (currScene == scene) + return; + + await PrevSceneUnLoad(); + + var operation = SceneManager.LoadSceneAsync(scene.name, LoadSceneMode.Additive); + while (!operation.isDone) + { + // float progress = Mathf.Clamp01(t.progress / 0.9f); + + //if (progressBar != null) + //{ + // progressBar.value = progress; + //} + + //if (percentageText != null) + //{ + // percentageText.text = Mathf.RoundToInt(progress * 100f) + "%"; + //} + + //// Check if the loading is nearly complete (at 90%) + //if (operation.progress >= 0.9f) + //{ + // // This is the final 10% where the scene is ready but not yet active + // // You can add a manual delay or wait for a user input here + + // // For a smooth transition to 100% and activation: + // progressBar.value = 1f; + // if (percentageText != null) + // { + // percentageText.text = "100%"; + // } + + // // Allow the scene to activate, completing the loading process + // t.allowSceneActivation = true; + //} + //prevSceneAssets.Add(scene); + await UniTask.NextFrame(); + } + currScene = scene; + PrevScene = scene; + curSceneStatus = sceneStatus; + } + + private async UniTask PrevSceneUnLoad() + { + if (PrevScene != null) + { + await SceneManager.UnloadSceneAsync(PrevScene.name); + PrevScene = null; + } + } + + /// + /// Home systemScene ε + /// + public async void OnClickHome() + { + await PrevSceneUnLoad(); + curSceneStatus = SceneStatus.None; + } + } + +} diff --git a/Assets/Scripts/Manager/SceneController.cs.meta b/Assets/Scripts/Manager/SceneController.cs.meta new file mode 100644 index 00000000..068a9511 --- /dev/null +++ b/Assets/Scripts/Manager/SceneController.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 7806010f2ede23e408c867597ef3f285 \ No newline at end of file diff --git a/Assets/Scripts/UI/ProjectData.cs b/Assets/Scripts/UI/ProjectData.cs index f4204eff..99728e96 100644 --- a/Assets/Scripts/UI/ProjectData.cs +++ b/Assets/Scripts/UI/ProjectData.cs @@ -1,4 +1,5 @@ using NUnit.Framework; +using OCTOPUS_TWIN.Management; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; @@ -14,15 +15,15 @@ namespace OCTOPUS_TWIN [TextArea] public string description; // 설명 public Sprite thumbnail; // 썸네일 이미지 + [Header("SceneType")] + public SceneStatus curSceneStatus; + [Header("3D Model")] public GameObject modelPrefab; // 로딩 후 켜질 실제 3D 모델 프리팹 [Header("Scenes")] public List sceneAssets; - [Header("LightMaps")] - public List lightmapDatas; - [Header("VolumeProfile")] public List volumeProfiles; diff --git a/Assets/Scripts/UI/ProjectListController.cs b/Assets/Scripts/UI/ProjectListController.cs index df3a0c9e..1f743f07 100644 --- a/Assets/Scripts/UI/ProjectListController.cs +++ b/Assets/Scripts/UI/ProjectListController.cs @@ -2,6 +2,7 @@ using Cysharp.Threading.Tasks; using HyundaiWIA; using KEPCO; +using OCTOPUS_TWIN.Management; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; @@ -41,8 +42,7 @@ namespace OCTOPUS_TWIN public ProjectData currentProjectData; [SerializeField] private Volume volume; - private List prevSceneAssets = new(); - + private SceneController sceneController =new(); private void Start() { GenerateList(); @@ -175,82 +175,45 @@ namespace OCTOPUS_TWIN private async UniTask SwitchModel(ProjectData data) { // 기존에 켜져 있던 모델들 모두 끄기 (초기화) - - await LoadActiveProjectScene(data); - currentProjectData = data; + CanvasReset(); - //SetActiveProgjectDataObject(modelRoot, currentProjectData.modelPrefab.name, true); + await LoadActiveProjectScene(data.sceneAssets[0],data.curSceneStatus); + + currentProjectData = data; SetActiveProgjectDataObject(staticCanvasRoot, currentProjectData.staticCanvasPrefab.name, true); SetActiveProgjectDataObject(sceneMainRoot, currentProjectData.sceneMain.name, true); SetActiveProgjectDataObject(popupCanvasRoot, currentProjectData.popupCanvasPrefab.name, true); SetActiveProgjectDataObject(labelCanvasRoot, currentProjectData.labelCanvas.name, true); - switch (currentProjectData.projectName) + + switch (data.curSceneStatus) { - case "Chunil": + case SceneStatus.Chunil: ChunilENGSceneMain.Instance.InitSceneMain(); break; - case "KEPCO": + case SceneStatus.KepCo: KEPCOSceneMain.Instance.InitSceneMain(); break; - case "HyundaiWIA": + case SceneStatus.HyundaiWia: HyundaiWIASceneMain.Instance.InitSceneMain(); break; } } - private async UniTask LoadActiveProjectScene(ProjectData data) + public async UniTask SceneTransition(int index) { - //이전 씬 UnLoad - if (prevSceneAssets.Count != 0) + var sceneIndex = index == 2 ? 0 : 1; + if (currentProjectData.sceneAssets.Count > sceneIndex) { - foreach (var unloadAsset in prevSceneAssets) - { - await SceneManager.UnloadSceneAsync(unloadAsset.name); - } - prevSceneAssets.Clear(); - } - - foreach (var scene in data.sceneAssets) - { - //로딩바 만들어줘야함 - AsyncOperation t = SceneManager.LoadSceneAsync(scene.name, LoadSceneMode.Additive); - - while (!t.isDone) - { - float progress = Mathf.Clamp01(t.progress / 0.9f); - - //if (progressBar != null) - //{ - // progressBar.value = progress; - //} - - //if (percentageText != null) - //{ - // percentageText.text = Mathf.RoundToInt(progress * 100f) + "%"; - //} - - //// Check if the loading is nearly complete (at 90%) - //if (operation.progress >= 0.9f) - //{ - // // This is the final 10% where the scene is ready but not yet active - // // You can add a manual delay or wait for a user input here - - // // For a smooth transition to 100% and activation: - // progressBar.value = 1f; - // if (percentageText != null) - // { - // percentageText.text = "100%"; - // } - - // // Allow the scene to activate, completing the loading process - // t.allowSceneActivation = true; - //} - prevSceneAssets.Add(scene); - await UniTask.NextFrame(); - } - + var transitionScene = currentProjectData.sceneAssets[sceneIndex]; + await LoadActiveProjectScene(transitionScene, currentProjectData.curSceneStatus); } } + + private async UniTask LoadActiveProjectScene(Object mainScene, SceneStatus status) + { + await sceneController.SceneChange(mainScene, status); + } + private void SetActiveProgjectDataObject(Transform parent, string targetName, bool isOn) { Transform targetModel = FindInChildren(parent, targetName); @@ -277,13 +240,7 @@ namespace OCTOPUS_TWIN public void ReturnHome() { CanvasReset(); - if (prevSceneAssets.Count > 0) - { - foreach (var scene in prevSceneAssets) - { - SceneManager.UnloadSceneAsync(scene.name); - } - } + sceneController.OnClickHome(); // 모델 다 끄기 if (modelRoot != null) {