UI 패널 활성화 토글 기능 개발
This commit is contained in:
60
Assets/WorkSpace/Personal/JYM/UI_DashboardCheckListBox.cs
Normal file
60
Assets/WorkSpace/Personal/JYM/UI_DashboardCheckListBox.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using WI;
|
||||
|
||||
namespace CHN
|
||||
{
|
||||
public class UI_DashboardCheckListBox : UIBase
|
||||
{
|
||||
public UI_DashboardCheckListItem prf_item;
|
||||
|
||||
private Dictionary<string, GameObject> originDashBoardItems = new();
|
||||
private Dictionary<string, UI_DashboardCheckListItem> dashboardItemList = new();
|
||||
public void Init(Dictionary<string, GameObject> items)
|
||||
{
|
||||
prf_item = Resources.Load<UI_DashboardCheckListItem>("Prefabs/UI/UI_DashboardCheckListItem");
|
||||
|
||||
originDashBoardItems.Clear();
|
||||
foreach (var item in items)
|
||||
{
|
||||
var dashboardItem = CreateItem();
|
||||
dashboardItemList.Add(item.Key, dashboardItem);
|
||||
originDashBoardItems.Add(item.Key, item.Value);
|
||||
}
|
||||
SetMenuItem(items);
|
||||
}
|
||||
private void SetMenuItem(Dictionary<string, GameObject> items)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
dashboardItemList[item.Key].SetItem(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCloseDashbordItem(string dahboardKey)
|
||||
{
|
||||
dashboardItemList[dahboardKey].ToggleOffItem();
|
||||
}
|
||||
private UI_DashboardCheckListItem CreateItem()
|
||||
{
|
||||
var item = Instantiate(prf_item, transform);
|
||||
item.transform.localScale = Vector3.one;
|
||||
return item;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject != null)
|
||||
return;
|
||||
transform.parent.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user