侧边栏菜单迭代
This commit is contained in:
parent
68ccd15ac1
commit
076efd01dc
@ -377,7 +377,7 @@ MonoBehaviour:
|
|||||||
m_Right: 20
|
m_Right: 20
|
||||||
m_Top: 20
|
m_Top: 20
|
||||||
m_Bottom: 20
|
m_Bottom: 20
|
||||||
m_ChildAlignment: 4
|
m_ChildAlignment: 3
|
||||||
m_Spacing: 12
|
m_Spacing: 12
|
||||||
m_ChildForceExpandWidth: 0
|
m_ChildForceExpandWidth: 0
|
||||||
m_ChildForceExpandHeight: 0
|
m_ChildForceExpandHeight: 0
|
||||||
@ -494,7 +494,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_IgnoreLayout: 0
|
m_IgnoreLayout: 0
|
||||||
m_MinWidth: 400
|
m_MinWidth: 300
|
||||||
m_MinHeight: -1
|
m_MinHeight: -1
|
||||||
m_PreferredWidth: -1
|
m_PreferredWidth: -1
|
||||||
m_PreferredHeight: -1
|
m_PreferredHeight: -1
|
||||||
|
@ -23,7 +23,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
public override bool Enable => m_bPoped;
|
public override bool Enable => m_bPoped;
|
||||||
|
|
||||||
private bool m_bPoped = false;
|
private bool m_bPoped = false;
|
||||||
private List<MonoBehaviour> m_runtimeMenuItems = new List<MonoBehaviour>();
|
private List<OptionUI_MenuItem> m_runtimeMenuItems = new List<OptionUI_MenuItem>();
|
||||||
|
|
||||||
private int m_selectIndex = -1;
|
private int m_selectIndex = -1;
|
||||||
public int SelectIndex
|
public int SelectIndex
|
||||||
@ -36,7 +36,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
m_selectIndex = value;
|
m_selectIndex = value;
|
||||||
|
|
||||||
var itemUIRect = m_runtimeMenuItems[m_selectIndex].transform as RectTransform;
|
OptionUI_MenuItem optionUI_MenuItem = m_runtimeMenuItems[m_selectIndex];
|
||||||
|
optionUI_MenuItem.OnFocus();
|
||||||
|
var itemUIRect = optionUI_MenuItem.transform as RectTransform;
|
||||||
SelectBorder.pivot = itemUIRect.pivot;
|
SelectBorder.pivot = itemUIRect.pivot;
|
||||||
SelectBorder.sizeDelta = itemUIRect.rect.size;
|
SelectBorder.sizeDelta = itemUIRect.rect.size;
|
||||||
DOTween.To(() => SelectBorder.position, (value) => SelectBorder.position = value, itemUIRect.position, 0.125f);
|
DOTween.To(() => SelectBorder.position, (value) => SelectBorder.position = value, itemUIRect.position, 0.125f);
|
||||||
@ -61,21 +63,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
MenuRoot.anchoredPosition = temp;
|
MenuRoot.anchoredPosition = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
public void Pop(List<OptionMenu> menus, int defaultIndex = 0)
|
||||||
{
|
|
||||||
if (Input.GetKeyDown(KeyCode.T))
|
|
||||||
{
|
|
||||||
if (m_bPoped) Hide();
|
|
||||||
else Pop(new List<OptionMenu>
|
|
||||||
{
|
|
||||||
new ExecuteMenu("²âÊԲ˵¥1"),
|
|
||||||
new ExecuteMenu("Copilot"),
|
|
||||||
new ExecuteMenu("ChatGPT 4o"),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Pop(IEnumerable<OptionMenu> menus)
|
|
||||||
{
|
{
|
||||||
ReleaseRuntimeMenus();
|
ReleaseRuntimeMenus();
|
||||||
foreach (var menu in menus) CreateRuntimeMenuItem(menu);
|
foreach (var menu in menus) CreateRuntimeMenuItem(menu);
|
||||||
@ -85,7 +73,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
Canvas.ForceUpdateCanvases();
|
Canvas.ForceUpdateCanvases();
|
||||||
|
|
||||||
m_selectIndex = 0;
|
m_selectIndex = 0;
|
||||||
var itemUIRect = m_runtimeMenuItems[m_selectIndex].transform as RectTransform;
|
OptionUI_MenuItem optionUI_MenuItem = m_runtimeMenuItems[defaultIndex];
|
||||||
|
optionUI_MenuItem.OnFocus();
|
||||||
|
var itemUIRect = optionUI_MenuItem.transform as RectTransform;
|
||||||
SelectBorder.pivot = itemUIRect.pivot;
|
SelectBorder.pivot = itemUIRect.pivot;
|
||||||
SelectBorder.position = itemUIRect.position;
|
SelectBorder.position = itemUIRect.position;
|
||||||
SelectBorder.sizeDelta = itemUIRect.rect.size;
|
SelectBorder.sizeDelta = itemUIRect.rect.size;
|
||||||
@ -161,6 +151,17 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
SelectIndex--;
|
SelectIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnCmdBack()
|
||||||
|
{
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnCmdEnter()
|
||||||
|
{
|
||||||
|
m_runtimeMenuItems[SelectIndex].OnExecute();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class OptionMenu
|
public abstract class OptionMenu
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
public class OptionUI_ExecuteItem : MonoBehaviour
|
public class OptionUI_ExecuteItem : OptionUI_MenuItem<ExecuteMenu>
|
||||||
{
|
{
|
||||||
[SerializeField] Text m_MenuNameTxt;
|
public override void OnExecute()
|
||||||
[SerializeField] Image m_Icon;
|
|
||||||
|
|
||||||
public void SetData(ExecuteMenu executeMenu)
|
|
||||||
{
|
{
|
||||||
m_MenuNameTxt.text = executeMenu.Name;
|
MenuData.OnExcute();
|
||||||
if (executeMenu.Icon == null) m_Icon.gameObject.SetActiveEx(false);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Icon.gameObject.SetActiveEx(true);
|
|
||||||
m_Icon.sprite = executeMenu.Icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnFocus()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace AxibugEmuOnline.Client
|
||||||
|
{
|
||||||
|
public abstract class OptionUI_MenuItem : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] Text m_MenuNameTxt;
|
||||||
|
[SerializeField] Image m_Icon;
|
||||||
|
|
||||||
|
protected OptionMenu m_Menu;
|
||||||
|
|
||||||
|
public void SetData(OptionMenu menuData)
|
||||||
|
{
|
||||||
|
m_Menu = menuData;
|
||||||
|
m_MenuNameTxt.text = menuData.Name;
|
||||||
|
if (menuData.Icon == null) m_Icon.gameObject.SetActiveEx(false);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Icon.gameObject.SetActiveEx(true);
|
||||||
|
m_Icon.sprite = menuData.Icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnSetData(menuData);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnSetData(OptionMenu menuData) { }
|
||||||
|
|
||||||
|
public abstract void OnExecute();
|
||||||
|
public abstract void OnFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class OptionUI_MenuItem<T> : OptionUI_MenuItem
|
||||||
|
where T : OptionMenu
|
||||||
|
{
|
||||||
|
protected T MenuData => m_Menu as T;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8bba0d5ebcd10fb459209fb11e4d274d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user