Merge pull request '[정영민] 설비 Icon 기능 수정' (#12) from jym/260129_00 into main
Reviewed-on: http://220.90.135.190:3000/UVCXR/OCTOPUS_TWIN-Demo/pulls/12
This commit was merged in pull request #12.
This commit is contained in:
56377
Assets/Scenes/Demo_ProejctSelect.unity
Normal file
56377
Assets/Scenes/Demo_ProejctSelect.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fd7483052fa04144a94966bd4915708
|
||||
guid: 2de942676c02859479c03d56bc58f63d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChunilENG
|
||||
namespace OCTOPUS_TWIN
|
||||
{
|
||||
public enum ViewMode
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChunilENG
|
||||
namespace OCTOPUS_TWIN
|
||||
{
|
||||
public class OrbitalControllerTarget : MonoBehaviour
|
||||
{
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6451148b055de754fb30fc15d65fe211
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d0a1fba871007a4e9c3c2c041b47c66
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,5 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using OCTOPUS_TWIN;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UVC.Core;
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace ChunilENG
|
||||
{
|
||||
public Building building;
|
||||
MQTT mqttManager;
|
||||
HTTPRequester httpManager;
|
||||
|
||||
DataManager dataManager;
|
||||
ViewManager viewManager;
|
||||
@@ -26,11 +25,7 @@ namespace ChunilENG
|
||||
|
||||
public Action Initialized;
|
||||
|
||||
/// <summary>
|
||||
/// 초기 화 메서드입니다.
|
||||
/// Awake 메서드에서 호출되며, MonoBehaviour가 생성될 때 한 번만 실행됩니다.
|
||||
/// </summary>
|
||||
protected override void Init()
|
||||
public void InitSceneMain()
|
||||
{
|
||||
if (!TooltipManager.Instance.IsInitialized) TooltipManager.Instance.Initialize();
|
||||
ChunilENGAppMain.Instance.Initialized += OnAppInitialized;
|
||||
@@ -38,8 +33,6 @@ namespace ChunilENG
|
||||
|
||||
private async void OnAppInitialized()
|
||||
{
|
||||
|
||||
|
||||
//await requestDataAsync();
|
||||
building = FindAnyObjectByType<Building>();
|
||||
await building.Init();
|
||||
@@ -50,7 +43,6 @@ namespace ChunilENG
|
||||
viewManager = await LoadManager<ViewManager>();
|
||||
mqttManager = FindAnyObjectByType<MQTT>();
|
||||
dataManager = await LoadManager<DataManager>();
|
||||
httpManager = FindAnyObjectByType<HTTPRequester>();
|
||||
|
||||
SetupDataSetting();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ChunilENG.Management;
|
||||
using OCTOPUS_TWIN;
|
||||
using UVC.UI.Commands;
|
||||
|
||||
namespace ChunilENG.UI.Command
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34463bb3bb3778042840b9c96fa1d69e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2ff38edba234b245af6af096a33daff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fa7fe8cadbf5fe42a3b5dae43b2ed3d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,59 +0,0 @@
|
||||
using UnityEngine;
|
||||
using Best.HTTP;
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
|
||||
namespace ChunilENG
|
||||
{
|
||||
public class HTTPRequester : MonoBehaviour
|
||||
{
|
||||
public Action<MachineKPIData> onMachineKPIData;
|
||||
string httpSetting;
|
||||
string apiKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwiZW1haWwiOiJjaHVuaWxlbmdAdXZjLmNvLmtyIiwiZ3JvdXBJZCI6MiwiZ3JvdXBDb2RlIjoiY2h1bmlsZW5nIiwicm9sZSI6IlRlbmFudEFkbWluIiwibmFtZSI6IuyynOydvOyXlOyngOuLiOyWtOungSIsImxpY2Vuc2UiOiJidXNpbmVzcyIsInBob25lIjoiMDEwMDAwMDAwMDAiLCJpYXQiOjE3MTgxNjI2MjksImV4cCI6MjAzMzUyMjYyOX0.zdlNswh_88M44oxs1HuaoA-rFdUoS50tHQ1-xNqWzIc";
|
||||
string httpServer = "http://106.247.236.204:8863";
|
||||
string kpiAPI = "/api/usp_ppmr020/list/facilityKpi";
|
||||
|
||||
public void Start()
|
||||
{
|
||||
HTTPConnect();
|
||||
}
|
||||
public void HTTPConnect()
|
||||
{
|
||||
var path = httpServer + kpiAPI;
|
||||
|
||||
var yesterday = DateTime.Now.AddDays(-1);
|
||||
var yesterdayTime = yesterday.ToString("yyyyMMdd");
|
||||
var todayTime = DateTime.Now.ToString("yyyyMMdd");
|
||||
|
||||
var query = $"?&p_frdt={yesterdayTime}&p_todt={todayTime}&limit={100}";
|
||||
|
||||
var request = HTTPRequest.CreateGet(path + query, RequestFinishedCallback);
|
||||
request.AddHeader("access-token", apiKey);
|
||||
|
||||
request.Send();
|
||||
}
|
||||
private void RequestFinishedCallback(HTTPRequest req, HTTPResponse resp)
|
||||
{
|
||||
switch (req.State)
|
||||
{
|
||||
case HTTPRequestStates.Finished:
|
||||
if (resp.IsSuccess)
|
||||
{
|
||||
var payload = Encoding.UTF8.GetString(resp.Data);
|
||||
var response = JsonConvert.DeserializeObject<MachineKPIData>(payload);
|
||||
|
||||
onMachineKPIData?.Invoke(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bb0663cd975cee4d9afe138bb32a810
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,192 +3,133 @@ using ChunilENG.Constants;
|
||||
using ChunilENG.UI;
|
||||
using ChunilENG.UI.Command;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using OCTOPUS_TWIN;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace ChunilENG.Management
|
||||
{
|
||||
public class MachineInfoItemManager : Manager
|
||||
{
|
||||
private OrbitalController cam;
|
||||
private Building building;
|
||||
public MachineInfoItem machineInfoItem;
|
||||
|
||||
private List<Machine> machines;
|
||||
private List<Machine> matchingMachines = new();
|
||||
private Dictionary<string, MachineInfoItem> machineKPIs = new();
|
||||
private Dictionary<MachineInfoItem, Machine> kpiToMachines = new();
|
||||
private Dictionary<MachineInfoItem, Machine> itemToMachines = new();
|
||||
|
||||
public Action<Machine> onClickKPIToMachine;
|
||||
|
||||
public float defaultNameHeight = 2f;
|
||||
[Range(0.1f, 2f)] public float updateInterval = 0.05f;
|
||||
//public Vector3 originScale;
|
||||
|
||||
[Header("Scale Settings")]
|
||||
[Range(0.1f, 0.8f)] public float minScale;
|
||||
[Range(0.5f, 1.5f)] public float maxScale;
|
||||
[Range(0.1f, 2f)] public float scaleClamp;
|
||||
|
||||
private List<RectTransform> activeUIElements = new();
|
||||
private Vector3[] worldCorners = new Vector3[4]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: GC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20≯<EFBFBD> <20>Ҵ<EFBFBD>
|
||||
|
||||
public override async UniTask Init()
|
||||
{
|
||||
cam = ChunilENGAppMain.Instance.cameraController; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Start<72><74><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD>Ͽ<EFBFBD> ij<><C4B3>
|
||||
building = ChunilENGSceneMain.Instance.building;
|
||||
|
||||
machineInfoItem = Resources.Load<MachineInfoItem>($"{ResourceURL.uiPrefabFolderPath}{nameof(MachineInfoItem)}");
|
||||
machines = building.GetMachines();
|
||||
// <20>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ſ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> (<28><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> X)
|
||||
StartCoroutine(UpdateLoop());
|
||||
machines = ChunilENGSceneMain.Instance.building.GetMachines();
|
||||
|
||||
foreach (var machine in machines)
|
||||
{
|
||||
var infoItem = Instantiate(machineInfoItem, transform);
|
||||
infoItem.Init();
|
||||
machine.machineKPI = infoItem;
|
||||
infoItem.onClickItem += OnClickMachineInfoItem;
|
||||
itemToMachines.Add(infoItem, machine);
|
||||
}
|
||||
|
||||
await UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
private System.Collections.IEnumerator UpdateLoop()
|
||||
public void Update()
|
||||
{
|
||||
var wait = new WaitForSeconds(updateInterval); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> updateInterval<61><6C><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
while (true)
|
||||
if (machines == null || machines.Count == 0)
|
||||
return;
|
||||
|
||||
IconPositionSetting();
|
||||
RangeDetection();
|
||||
}
|
||||
private void IconPositionSetting()
|
||||
{
|
||||
foreach (var machine in machines)
|
||||
{
|
||||
Profiler.BeginSample("MachineKPI_TotalUpdate");
|
||||
if (matchingMachines.Count > 0)
|
||||
var machineCenterPos = machine.centerPos;
|
||||
var screenPos = Camera.main.WorldToScreenPoint(new Vector3(machineCenterPos.x, machineCenterPos.y + defaultNameHeight, machineCenterPos.z));
|
||||
|
||||
machine.machineKPI.transform.position = screenPos;
|
||||
}
|
||||
}
|
||||
void RangeDetection()
|
||||
{
|
||||
float t = Mathf.InverseLerp(cam.maxDistance, 0f, cam.currentDistance);
|
||||
float scale = Mathf.Lerp(minScale, maxScale, t);
|
||||
var newScale = new Vector3(scale, scale, scale);
|
||||
|
||||
foreach (var machine in machines)
|
||||
{
|
||||
MachineIconsActive(machine);
|
||||
var machineInfoItem = machine.machineKPI;
|
||||
machineInfoItem.transform.localScale = newScale;
|
||||
}
|
||||
}
|
||||
void MachineIconsActive(Machine machine)
|
||||
{
|
||||
var currentFloor = ChunilENGSceneMain.Instance.building.GetCurFloor();
|
||||
var machineInFloor = machine.GetComponentInParent<Floor>();
|
||||
|
||||
if (machineInFloor != currentFloor)
|
||||
{
|
||||
machine.machineKPI.Deactive();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsScreenRange(machine))
|
||||
{
|
||||
UpdateMachineVisibilityAndScale();
|
||||
GroupOverlappingUIElements();
|
||||
machine.machineKPI.Active();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
machine.machineKPI.Deactive();
|
||||
return;
|
||||
}
|
||||
Profiler.EndSample();
|
||||
yield return wait; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD> <20>ۿ<EFBFBD><DBBF><EFBFBD> <20><> <20>ѹ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> ij<><C4B3><EFBFBD>ص<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> -> <20><EFBFBD> <20>Ҵ<EFBFBD> 0
|
||||
}
|
||||
}
|
||||
|
||||
#region Machine
|
||||
public void SetMachineKPI(List<CompleteInfo> machineData)
|
||||
{
|
||||
Clear();
|
||||
|
||||
foreach (var data in machineData)
|
||||
{
|
||||
var targetMachine = machines.Find(m => m.code == data.workcd);
|
||||
if (targetMachine == null) continue;
|
||||
|
||||
if (!machineKPIs.TryGetValue(data.workcd, out var infoItem))
|
||||
{
|
||||
infoItem = Instantiate(machineInfoItem, transform);
|
||||
infoItem.Init();
|
||||
infoItem.onClickItem += OnClickMachineInfoItem;
|
||||
infoItem.name = data.workcd;
|
||||
machineKPIs.Add(data.workcd, infoItem);
|
||||
}
|
||||
|
||||
infoItem.SetData(data, targetMachine.machineName);
|
||||
infoItem.gameObject.SetActive(false);
|
||||
targetMachine.machineKPI.SetData(data, targetMachine.machineName);
|
||||
targetMachine.machineKPI.gameObject.SetActive(false);
|
||||
targetMachine.SetAnimationSpeed();
|
||||
}
|
||||
|
||||
foreach (var machine in machines)
|
||||
{
|
||||
if (machineKPIs.TryGetValue(machine.code, out var kpi))
|
||||
{
|
||||
machine.machineKPI = kpi;
|
||||
matchingMachines.Add(machine);
|
||||
kpiToMachines.Add(kpi, machine);
|
||||
machine.SetAnimationSpeed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateMachineVisibilityAndScale()
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD> RangeDetection <20>Լ<EFBFBD> -> <20>ڷ<EFBFBD>ƾ <20>ȿ<EFBFBD><C8BF><EFBFBD> <20><><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD>ü<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
int layerMask = LayerMask.GetMask("Camera", "Floor Wall");
|
||||
float t = Mathf.InverseLerp(cam.maxDistance, 0f, cam.currentDistance);
|
||||
float scaleValue = Mathf.Lerp(minScale, maxScale, t);
|
||||
Vector3 newScale = new Vector3(scaleValue, scaleValue, scaleValue);
|
||||
|
||||
Floor currentFloor = building.GetCurFloor();
|
||||
activeUIElements.Clear();
|
||||
|
||||
foreach (var machine in matchingMachines)
|
||||
{
|
||||
bool shouldBeActive = IsMachineVisible(machine, currentFloor, layerMask);
|
||||
|
||||
if (shouldBeActive)
|
||||
{
|
||||
machine.machineKPI.Active();
|
||||
machine.machineKPI.transform.localScale = newScale;
|
||||
// <20><><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD><C7A5> <20><>ũ<EFBFBD><C5A9> <20><>ǥ<EFBFBD><C7A5> <20><>ȯ<EFBFBD>Ͽ<EFBFBD> 1<><31> <20><>ġ
|
||||
Vector3 screenPos = Camera.main.WorldToScreenPoint(machine.centerPos + Vector3.up * defaultNameHeight);
|
||||
machine.machineKPI.transform.position = screenPos;
|
||||
activeUIElements.Add(machine.machineKPI.rectTransform);
|
||||
}
|
||||
else
|
||||
{
|
||||
machine.machineKPI.Deactive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsMachineVisible(Machine machine, Floor currentFloor, int layerMask)
|
||||
{
|
||||
if (machine.GetComponentInParent<Floor>() != currentFloor)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
void GroupOverlappingUIElements()
|
||||
{
|
||||
if (activeUIElements.Count == 0) return;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: uncheckedElements.Where(...) <20><><EFBFBD><EFBFBD> <20>Ҵ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> -> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD>: Y<><59>ǥ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> (LINQ <20><><EFBFBD> List.Sort<72><74> <20>Ҵ<EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||
activeUIElements.Sort((a, b) => a.position.y.CompareTo(b.position.y));
|
||||
|
||||
// <20>ܼ<EFBFBD>ȭ<EFBFBD><C8AD> <20><>ø <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> (<28><EFBFBD><D7B8>峪 <20><EFBFBD><D7B7><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> üũ)
|
||||
for (int i = 0; i < activeUIElements.Count; i++)
|
||||
{
|
||||
for (int j = i + 1; j < activeUIElements.Count; j++)
|
||||
{
|
||||
RectTransform rectA = activeUIElements[i];
|
||||
RectTransform rectB = activeUIElements[j];
|
||||
|
||||
if (AreRectsOverlapping(rectA, rectB))
|
||||
{
|
||||
// <20><>ġ<EFBFBD><C4A1> B<><42> A <20><><EFBFBD><EFBFBD> <20>ø<EFBFBD>
|
||||
float offset = rectA.rect.height * rectA.lossyScale.y;
|
||||
rectB.position = new Vector3(rectB.position.x, rectA.position.y + offset, rectB.position.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool AreRectsOverlapping(RectTransform rectA, RectTransform rectB)
|
||||
{
|
||||
return GetWorldRect(rectA).Overlaps(GetWorldRect(rectB));
|
||||
}
|
||||
private Rect GetWorldRect(RectTransform rectTransform)
|
||||
{
|
||||
rectTransform.GetWorldCorners(worldCorners); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: worldCorners<72><73> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ij<><C4B3> -> GetWorldRect ȣ<><C8A3> <20>ø<EFBFBD><C3B8><EFBFBD> <20><EFBFBD><DFBB>ϴ<EFBFBD> <20>迭 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
return new Rect(worldCorners[0], worldCorners[2] - worldCorners[0]);
|
||||
}
|
||||
|
||||
private void OnClickMachineInfoItem(MachineInfoItem machineInfoItem)
|
||||
{
|
||||
machineInfoItem.transform.SetAsLastSibling();
|
||||
if (kpiToMachines.TryGetValue(machineInfoItem, out var machine))
|
||||
{
|
||||
onClickKPIToMachine?.Invoke(machine);
|
||||
CommandManager.Instance.Execute(new OpenMachineDashBoardCommand(machine, machineInfoItem.data));
|
||||
}
|
||||
CommandManager.Instance.Execute(new OpenMachineDashBoardCommand(itemToMachines[machineInfoItem], machineInfoItem.data));
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
bool IsScreenRange(Machine machine)
|
||||
{
|
||||
activeUIElements.Clear();
|
||||
matchingMachines.Clear();
|
||||
kpiToMachines.Clear();
|
||||
Vector3 viewPos = Camera.main.WorldToViewportPoint(machine.centerPos);
|
||||
|
||||
if (viewPos.x >= 0 && viewPos.x <= 1 && viewPos.y >= 0 && viewPos.y <= 1 && viewPos.z > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using ChunilENG.Constants;
|
||||
using ChunilENG.UI;
|
||||
using ChunilENG.UI.Command;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using OCTOPUS_TWIN;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -57,7 +58,6 @@ namespace ChunilENG.Management
|
||||
if (thermostats == null || thermostats.Count == 0)
|
||||
return;
|
||||
|
||||
|
||||
IconPositionSetting();
|
||||
RangeDetection();
|
||||
}
|
||||
@@ -96,10 +96,28 @@ namespace ChunilENG.Management
|
||||
}
|
||||
else
|
||||
{
|
||||
thermostat.thermostatIcon.Active();
|
||||
return;
|
||||
if (IsScreenRange(thermostat))
|
||||
{
|
||||
thermostat.thermostatIcon.Active();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
thermostat.thermostatIcon.Deactive();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool IsScreenRange(Thermostat thermostat)
|
||||
{
|
||||
Vector3 viewPos = Camera.main.WorldToViewportPoint(thermostat.centerPos);
|
||||
|
||||
if (viewPos.x >= 0 && viewPos.x <= 1 && viewPos.y >= 0 && viewPos.y <= 1 && viewPos.z > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using ChunilENG.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using OCTOPUS_TWIN;
|
||||
|
||||
namespace ChunilENG.Management
|
||||
{
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace ChunilENG
|
||||
|
||||
public Animator[] animators;
|
||||
|
||||
public HighLighter highLighter;
|
||||
public float animSpeed;
|
||||
|
||||
public float focusDistance;
|
||||
@@ -31,7 +30,6 @@ namespace ChunilENG
|
||||
centerPos = transform.GetMeshCenter();
|
||||
animators = GetComponentsInChildren<Animator>();
|
||||
|
||||
highLighter = GetComponentInChildren<HighLighter>(true);
|
||||
originScale = gameObject.transform.localScale;
|
||||
|
||||
await UniTask.CompletedTask;
|
||||
@@ -65,20 +63,20 @@ namespace ChunilENG
|
||||
}
|
||||
}
|
||||
|
||||
public void ActiveHighLighter()
|
||||
{
|
||||
if (highLighter == null)
|
||||
return;
|
||||
//public void ActiveHighLighter()
|
||||
//{
|
||||
// if (highLighter == null)
|
||||
// return;
|
||||
|
||||
highLighter.gameObject.SetActive(true);
|
||||
}
|
||||
public void DeactiveHighLighter()
|
||||
{
|
||||
if (highLighter == null)
|
||||
return;
|
||||
// highLighter.gameObject.SetActive(true);
|
||||
//}
|
||||
//public void DeactiveHighLighter()
|
||||
//{
|
||||
// if (highLighter == null)
|
||||
// return;
|
||||
|
||||
highLighter.gameObject.SetActive(false);
|
||||
}
|
||||
// highLighter.gameObject.SetActive(false);
|
||||
//}
|
||||
|
||||
|
||||
public int GetMachineFloorIndex()
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e810e33d00cc1da4fa310d4ee09975b6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,7 @@
|
||||
using ChunilENG.Management;
|
||||
using ChunilENG.UI.Command;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using OCTOPUS_TWIN;
|
||||
using UnityEngine;
|
||||
using UVC.UI.Toolbar;
|
||||
using UVC.UI.Toolbar.Model;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f90ea24f70852cd4d8684e0a68fbd206
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc8919f98ade6704f9bb2eb3938245ac
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,52 +0,0 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ChunilENG.Management
|
||||
{
|
||||
public class HighLighterManager : Manager
|
||||
{
|
||||
private List<Machine> machines;
|
||||
private int curIndex;
|
||||
|
||||
public override async UniTask Init()
|
||||
{
|
||||
var building = ChunilENGSceneMain.Instance.building;
|
||||
machines = building.GetMachines();
|
||||
|
||||
await UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public void ClickMachinToHighlight(Machine highLightMachine)
|
||||
{
|
||||
ActiveHighLighter(highLightMachine);
|
||||
}
|
||||
|
||||
public void ClickArea()
|
||||
{
|
||||
if (machines[curIndex] == null)
|
||||
return;
|
||||
|
||||
machines[curIndex].DeactiveHighLighter();
|
||||
}
|
||||
|
||||
public void ActiveHighLighter(Machine highLightMachine)
|
||||
{
|
||||
foreach (var machine in machines)
|
||||
{
|
||||
machine.DeactiveHighLighter();
|
||||
}
|
||||
|
||||
machines[curIndex] = highLightMachine;
|
||||
machines[curIndex].ActiveHighLighter();
|
||||
}
|
||||
|
||||
public void ResetAllHighLighter()
|
||||
{
|
||||
foreach (var machine in machines)
|
||||
{
|
||||
machine.DeactiveHighLighter();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 273ea45119e7530468f4e74e379c570b
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f36536ca7b2646346aad6aba4a5d7267
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class HighLighter : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3698aa2d3eb96784a9a843d0bb35040c
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4cdc34f82117844f8c8d34d44321ce7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class MachineKPIData
|
||||
{
|
||||
public string status;
|
||||
public string code;
|
||||
public string message;
|
||||
public Data data;
|
||||
public string remark;
|
||||
}
|
||||
[Serializable]
|
||||
public class Data
|
||||
{
|
||||
public string count;
|
||||
public KPIData[] rows;
|
||||
}
|
||||
[Serializable]
|
||||
public class KPIData
|
||||
{
|
||||
public string workcd;
|
||||
public string worknm;
|
||||
public string pjtcd;
|
||||
public string itemcd;
|
||||
public string itemdesc;
|
||||
public string porate;
|
||||
public string goodqtyrate;
|
||||
public string eorate;
|
||||
public string lct;
|
||||
public string wct;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3dbcba03a7e89204e945d3ad46f03da3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -13,5 +13,22 @@ namespace OCTOPUS_TWIN
|
||||
|
||||
[Header("3D Model")]
|
||||
public GameObject modelPrefab; // 로딩 후 켜질 실제 3D 모델 프리팹
|
||||
|
||||
[Header("StaticCanvas")]
|
||||
public GameObject staticCanvasPrefab; // 로딩 후 켜질 실제 static canvas 프리팹
|
||||
|
||||
[Header("PopupCanvas")]
|
||||
public GameObject popupCanvasPrefab; // 로딩 후 켜질 실제 static canvas 프리팹
|
||||
|
||||
[Header("SceneMain")]
|
||||
public GameObject sceneMain; // 로딩 후 켜질 실제 SceneMain 프리팹
|
||||
|
||||
public void SetActiveProjectPrefabs(bool isOn)
|
||||
{
|
||||
modelPrefab.gameObject.SetActive(isOn);
|
||||
staticCanvasPrefab.gameObject.SetActive(isOn);
|
||||
popupCanvasPrefab.gameObject.SetActive(isOn);
|
||||
sceneMain.gameObject.SetActive(isOn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using ChunilENG;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -16,13 +17,32 @@ namespace OCTOPUS_TWIN
|
||||
[Header("References")]
|
||||
[SerializeField] private GameObject homeRoot; // 홈 화면
|
||||
|
||||
[Tooltip("Chunil, KEPCO 등의 SceneMain들이 자식으로 있는 부모 오브젝트")]
|
||||
[SerializeField] private Transform sceneMainRoot;
|
||||
|
||||
[Tooltip("Chunil, KEPCO 등의 모델들이 자식으로 있는 부모 오브젝트")]
|
||||
[SerializeField] private Transform modelRoot;
|
||||
|
||||
[Tooltip("Chunil, KEPCO 등의 StaticCanvas들이 자식으로 있는 부모 오브젝트")]
|
||||
[SerializeField] private Transform staticCanvasRoot;
|
||||
|
||||
[Tooltip("Chunil, KEPCO 등의 PopupCanvas들이 자식으로 있는 부모 오브젝트")]
|
||||
[SerializeField] private Transform popupCanvasRoot;
|
||||
|
||||
ProjectData currentProjectData;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GenerateList();
|
||||
|
||||
if (sceneMainRoot != null)
|
||||
{
|
||||
foreach (Transform child in sceneMainRoot)
|
||||
{
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (modelRoot != null)
|
||||
{
|
||||
foreach (Transform child in modelRoot)
|
||||
@@ -30,6 +50,22 @@ namespace OCTOPUS_TWIN
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (staticCanvasRoot != null)
|
||||
{
|
||||
foreach (Transform child in staticCanvasRoot)
|
||||
{
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (popupCanvasRoot != null)
|
||||
{
|
||||
foreach (Transform child in popupCanvasRoot)
|
||||
{
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateList()
|
||||
@@ -84,24 +120,18 @@ namespace OCTOPUS_TWIN
|
||||
private void SwitchModel(ProjectData data)
|
||||
{
|
||||
// 기존에 켜져 있던 모델들 모두 끄기 (초기화)
|
||||
foreach (Transform child in modelRoot)
|
||||
if (currentProjectData != null)
|
||||
{
|
||||
child.gameObject.SetActive(false);
|
||||
currentProjectData.SetActiveProjectPrefabs(false);
|
||||
}
|
||||
currentProjectData = data;
|
||||
currentProjectData.SetActiveProjectPrefabs(true);
|
||||
|
||||
// 데이터에 연결된 프리팹의 이름을 가져옴
|
||||
string targetName = data.modelPrefab.name;
|
||||
|
||||
// Contents 밑에서 targetName을 가진 자식을 찾음
|
||||
Transform targetModel = modelRoot.Find(targetName);
|
||||
|
||||
if (targetModel != null)
|
||||
switch (currentProjectData.projectName)
|
||||
{
|
||||
targetModel.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"'{modelRoot.name}' 아래에서 '{targetName}' 오브젝트를 찾을 수 없습니다. 이름을 확인해주세요.");
|
||||
case "Chunil":
|
||||
ChunilENGSceneMain.Instance.InitSceneMain();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user