fix 씬 이동 작업

This commit is contained in:
njh
2026-02-09 11:27:58 +09:00
parent 04af85f189
commit c781c03b4f
11 changed files with 179 additions and 76 deletions

View File

@@ -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);
}
}

View File

@@ -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<MachineInfoItemManager>();
if (manager != null)
manager.ActiveIcons(uiIsActive);
//Ä«¸Þ¶ó À̵¿½Ã۰ÚÀ½.
//var building = ChunilENGSceneMain.Instance.building;
//building.SetFloor(floorIndex);

View File

@@ -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);
}
}
}
}

View File

@@ -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);
}
}

View File

@@ -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}

View File

@@ -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}

View File

@@ -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}

View File

@@ -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;
}
}
/// <summary>
/// Home일 경우 메인 systemScene 제외한 나머지 씬 언로드
/// </summary>
public async void OnClickHome()
{
await PrevSceneUnLoad();
curSceneStatus = SceneStatus.None;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7806010f2ede23e408c867597ef3f285

View File

@@ -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<Object> sceneAssets;
[Header("LightMaps")]
public List<LightmapData> lightmapDatas;
[Header("VolumeProfile")]
public List<VolumeProfile> volumeProfiles;

View File

@@ -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<Object> 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)
{