YanCheng_Metrology/Assets/Scripts/Project/UI/UI_Panel/UI_MenuPanel.cs

92 lines
2.0 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 右侧菜单按钮
/// </summary>
public class UI_MenuPanel : BasePanel
{
/// <summary>
/// 存储创建出来的btn
/// </summary>
private List<GameObject> itemObjs =new List<GameObject>();
/// <summary>
/// 初始化
/// </summary>
public void Init()
{
CreateMenuBtn(E_SceneType.Office);
}
/// <summary>
/// 创建菜单按钮
/// 根据所属空间创建 对应的按钮,
/// 还需要根据需求设定是否激活
/// </summary>
private void CreateMenuBtn(E_SceneType type)
{
//清空已经穿件出来的
ClearMenuBtn();
//获取所在场景中的btn数据
switch (type)
{
case E_SceneType.Office:
break;
case E_SceneType.TooLRoom:
break;
case E_SceneType.Site:
break;
}
//根据所在场景 创建新的btn 并记录
}
/// <summary>
/// 清空创建出来的
/// </summary>
private void ClearMenuBtn()
{
if (itemObjs.Count == 0)
return;
for (int i = 0; i < itemObjs.Count; i++)
{
Destroy(itemObjs[i]);
}
itemObjs.Clear();
}
/// <summary>
/// 显示面板
/// </summary>
public override void ShowMe()
{
GameManager.EventMgr.AddEventListener<E_SceneType>(Enum_EventType.SwitchScene, CreateMenuBtn);
}
/// <summary>
/// 隐藏面板
/// </summary>
public override void HideMe()
{
GameManager.EventMgr.RemoveEventListener<E_SceneType>(Enum_EventType.SwitchScene, CreateMenuBtn);
}
/// <summary>
/// 按钮点击
/// </summary>
/// <param name="btnName"></param>
protected override void OnClick(string btnName)
{
switch (btnName)
{
case "":
break;
}
}
}