增加快捷菜单

This commit is contained in:
MuHua-123
2025-09-13 15:33:27 +08:00
parent 6bc06bcd8c
commit 91a40e097b
25 changed files with 447 additions and 99 deletions
@@ -35,7 +35,7 @@
"actions": [ "actions": [
{ {
"name": "MouseLeft", "name": "MouseLeft",
"type": "Button", "type": "PassThrough",
"id": "1eaab500-f97a-4e25-8e55-bd9ba394a9fa", "id": "1eaab500-f97a-4e25-8e55-bd9ba394a9fa",
"expectedControlType": "Button", "expectedControlType": "Button",
"processors": "", "processors": "",
@@ -2,20 +2,28 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using MuHua;
/// <summary> /// <summary>
/// 菜单 - 输入 /// 菜单 - 输入
/// </summary> /// </summary>
public class InputMenu : InputControl { public class InputMenu : InputControl {
private UIMenuPanel menu;
protected override void ModuleInput_OnInputMode(InputMode mode) { protected override void ModuleInput_OnInputMode(InputMode mode) {
// throw new System.NotImplementedException(); // throw new System.NotImplementedException();
} }
#region #region
/// <summary> 鼠标左键 </summary>
public void OnMouseLeft(InputValue inputValue) {
if (inputValue.isPressed) return;
ManagerMenu.I.Close();
}
/// <summary> 鼠标右键 </summary> /// <summary> 鼠标右键 </summary>
public void OnMouseRight(InputValue inputValue) { public void OnMouseRight(InputValue inputValue) {
UIMenuManager.I.Open(); ManagerMenu.I.Open();
} }
#endregion #endregion
} }
@@ -0,0 +1,81 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MuHua;
/// <summary>
/// 菜单管理器
/// </summary>
public class ManagerMenu : ModuleSingle<ManagerMenu> {
private List<DataMenuItem> datas = new List<DataMenuItem>();
protected override void Awake() => NoReplace(false);
private void Start() {
// 初始化菜单项数据
Add("建筑/伐木场", () => Debug.Log("伐木场"));
Add("建筑/农场", () => Debug.Log("农场"));
Add("建筑/矿场", () => Debug.Log("矿场"));
Add("建筑/房屋/木屋", () => Debug.Log("木屋"));
Add("建筑/房屋/豪宅", () => Debug.Log("豪宅"));
Add("单位/步兵", () => Debug.Log("步兵"));
Add("单位/骑兵", () => Debug.Log("骑兵"));
Add("拆除", () => Debug.Log("拆除"));
}
public void Open() => UIShortcutMenu.I.Open(datas);
public void Close() => UIShortcutMenu.I.Close();
/// <summary> 添加菜单项(方法) </summary>
public void Add(string name, Action callback) {
string[] names = name.Split('/');
List<DataMenuItem> datas = this.datas;
for (int i = 0; i < names.Length; i++) {
string menu = names[i];
DataMenuItem item = datas.Find(obj => obj.name == menu);
if (item == null) {
item = new DataMenuItem { name = menu };
if (i == names.Length - 1) { item.callback = callback; }
datas.Add(item);
}
datas = item.items;
}
}
/// <summary> 移除菜单项 </summary>
public void Remove(string name) {
string[] names = name.Split('/');
List<DataMenuItem> datas = this.datas;
DataMenuItem parent = null;
DataMenuItem target = null;
for (int i = 0; i < names.Length; i++) {
string menu = names[i];
target = datas.Find(obj => obj.name == menu);
if (target == null) return; // 未找到,直接返回
if (i == names.Length - 1) {
// 找到要移除的项
datas.Remove(target);
return;
}
parent = target;
datas = target.items;
}
}
}
/// <summary>
/// 菜单项目
/// </summary>
public class DataMenuItem {
/// <summary> 名称 </summary>
public string name;
/// <summary> 回调 </summary>
public Action callback;
/// <summary> 子菜单项 </summary>
public List<DataMenuItem> items = new List<DataMenuItem>();
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4fbad1b7bdd1ba34da55091f94b08438
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fcb666edf8774b643830fdbb6a3973bd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,123 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using MuHua;
/// <summary>
/// UI快捷菜单
/// </summary>
public class UIShortcutMenu : ModuleUISingle<UIShortcutMenu> {
/// <summary> 菜单模板 </summary>
public VisualTreeAsset menuTreeAsset;
/// <summary> 项目模板 </summary>
public VisualTreeAsset itemTreeAsset;
/// <summary> 控件列表 </summary>
public static List<UIControl> controls = new List<UIControl>();
public override VisualElement Element => root.Q<VisualElement>("ShortcutMenu");
protected override void Awake() => NoReplace(false);
private void Update() => controls.ForEach(control => control.Update());
private void OnDestroy() => controls.ForEach(control => control.Dispose());
/// <summary> 打开菜单 </summary>
public void Open(List<DataMenuItem> datas) {
Close();
Vector3 position = UITool.GetMousePosition(Element);
UIMenuPanel menuPanel = Create();
menuPanel.Settings(position, datas);
}
/// <summary> 关闭菜单 </summary>
public void Close() {
controls.ForEach(control => control.Dispose());
controls.Clear();
Element.Clear();
}
/// <summary> 创建子菜单 </summary>
public UIMenuPanel Create() {
// 创建菜单元素
VisualElement element = menuTreeAsset.Instantiate();
element.EnableInClassList("menu", true);
Element.Add(element);
UIMenuPanel menuPanel = new UIMenuPanel(element, itemTreeAsset);
AddControl(menuPanel);
return menuPanel;
}
/// <summary> 添加控件 </summary>
public static void AddControl(UIControl control) => controls.Add(control);
/// <summary> 移除控件 </summary>
public static void RemoveControl(UIControl control) => controls.Remove(control);
}
/// <summary>
/// UI快捷菜单面板
/// </summary>
public class UIMenuPanel : ModuleUIPanel, UIControl {
public UIMenuPanel menuPanel;
public VisualElement submenu;
public ModuleUIItems<UIItem, DataMenuItem> items;
public VisualElement Container => Q<VisualElement>("Container");
public UIMenuPanel(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
items = new ModuleUIItems<UIItem, DataMenuItem>(Container, templateAsset,
(data, element) => new UIItem(data, element, this));
}
public void Update() {
// throw new NotImplementedException();
}
public void Dispose() {
items.Release();
}
public void Settings(Vector3 position, List<DataMenuItem> datas) {
items.Create(datas);
element.transform.position = position;
}
/// <summary> 打开子菜单 </summary>
public void Open(VisualElement submenu, List<DataMenuItem> datas) {
if (this.submenu == submenu) { return; }
// 更新子菜单
this.submenu = submenu;
if (menuPanel == null) { menuPanel = UIShortcutMenu.I.Create(); }
float x = submenu.worldBound.position.x + submenu.resolvedStyle.width;
float y = submenu.worldBound.position.y - 5;
Vector3 position = new Vector3(x, y, 0);
menuPanel.Settings(position, datas);
bool isEnable = datas != null && datas.Count > 0;
menuPanel.OpenSubmenu(isEnable);
}
public void OpenSubmenu(bool open) {
element.EnableInClassList("menu-hide", !open);
menuPanel?.OpenSubmenu(false);
}
/// <summary> UI项目 </summary>
public class UIItem : ModuleUIItem<DataMenuItem> {
public readonly UIMenuPanel parent;
public Label Name => element.Q<Label>("Name");
public VisualElement Arrow => element.Q<VisualElement>("Arrow");
public UIItem(DataMenuItem value, VisualElement element, UIMenuPanel parent) : base(value, element) {
this.parent = parent;
Name.text = value.name;
Arrow.EnableInClassList("menu-arrow-hide", value.items == null || value.items.Count == 0);
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
element.RegisterCallback<MouseMoveEvent>(MouseMoveEvent);
}
private void MouseDownEvent(MouseDownEvent evt) {
value.callback?.Invoke();
UIShortcutMenu.I.Close();
}
private void MouseMoveEvent(MouseMoveEvent evt) {
parent.Open(element, value.items);
}
}
}
@@ -1,73 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using MuHua;
/// <summary>
/// UI菜单管理器
/// </summary>
public class UIMenuManager : ModuleUISingle<UIMenuManager> {
/// <summary> 菜单模板 </summary>
public VisualTreeAsset menuTreeAsset;
/// <summary> 项目模板 </summary>
public VisualTreeAsset itemTreeAsset;
private UIMenuPanel menu;
public override VisualElement Element => root.Q<VisualElement>("Menu");
protected override void Awake() => NoReplace(false);
public void Open() {
if (menu != null) { Close(); }
Vector3 mousePosition = UITool.GetMousePosition(Element);
menu = BuildMenu(mousePosition);
}
public void Close() {
Element.Clear();
}
public void Settings() {
}
/// <summary> 创建菜单 </summary>
public UIMenuPanel BuildMenu(Vector3 position) {
VisualElement element = menuTreeAsset.Instantiate();
Element.Add(element);
element.transform.position = position;
return new UIMenuPanel(element, itemTreeAsset);
}
}
/// <summary>
/// UI菜单面板
/// </summary>
public class UIMenuPanel : ModuleUIPanel {
public ModuleUIItems<UIItem, DataMenuItem> items;
public VisualElement Container => Q<VisualElement>("Container");
public UIMenuPanel(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
items = new ModuleUIItems<UIItem, DataMenuItem>(Container, templateAsset,
(data, element) => new UIItem(data, element));
}
public void Release() => items.Release();
/// <summary> UI项目 </summary>
public class UIItem : ModuleUIItem<DataMenuItem> {
public UIItem(DataMenuItem value, VisualElement element) : base(value, element) {
}
}
}
/// <summary>
/// 菜单项目
/// </summary>
public class DataMenuItem {
/// <summary> 名称 </summary>
public string name;
/// <summary> 回调 </summary>
public Action callback;
}
@@ -122,6 +122,38 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1 &411988549
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 411988550}
m_Layer: 0
m_Name: "----\u76F8\u673A\u7BA1\u7406----"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &411988550
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411988549}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 963194228}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &670296962 --- !u!1 &670296962
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -279,7 +311,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 1439912283} m_Father: {fileID: 1335608360}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &705507996 --- !u!114 &705507996
MonoBehaviour: MonoBehaviour:
@@ -315,6 +347,7 @@ GameObject:
- component: {fileID: 963194228} - component: {fileID: 963194228}
- component: {fileID: 963194227} - component: {fileID: 963194227}
- component: {fileID: 963194226} - component: {fileID: 963194226}
- component: {fileID: 963194229}
m_Layer: 0 m_Layer: 0
m_Name: Main Camera m_Name: Main Camera
m_TagString: MainCamera m_TagString: MainCamera
@@ -394,7 +427,83 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 1439912283} m_Father: {fileID: 411988550}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &963194229
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 0
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_AllowHDROutput: 1
m_UseScreenCoordOverride: 0
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
m_TaaSettings:
m_Quality: 3
m_FrameInfluence: 0.1
m_JitterScale: 1
m_MipBias: 0
m_VarianceClampScale: 0.9
m_ContrastAdaptiveSharpening: 0
--- !u!1 &1335608359
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1335608360}
m_Layer: 0
m_Name: "----\u706F\u5149\u8BBE\u7F6E----"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1335608360
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335608359}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 705507995}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1439912282 --- !u!1 &1439912282
GameObject: GameObject:
@@ -426,8 +535,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 963194228} - {fileID: 1646925906}
- {fileID: 705507995}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1439912284 --- !u!114 &1439912284
@@ -581,6 +689,50 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
document: {fileID: 670296963} document: {fileID: 670296963}
SlideButtonTemplate: {fileID: 9197481963319205126, guid: 9452bd34d4b5bff4084d975753638b86, type: 3} SlideButtonTemplate: {fileID: 9197481963319205126, guid: 9452bd34d4b5bff4084d975753638b86, type: 3}
--- !u!1 &1646925905
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1646925906}
- component: {fileID: 1646925907}
m_Layer: 0
m_Name: ManagerMenu
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1646925906
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1646925905}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1439912283}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1646925907
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1646925905}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4fbad1b7bdd1ba34da55091f94b08438, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1922845062 --- !u!1 &1922845062
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -784,5 +936,7 @@ SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_Roots: m_Roots:
- {fileID: 1439912283} - {fileID: 1439912283}
- {fileID: 411988550}
- {fileID: 670296964} - {fileID: 670296964}
- {fileID: 1586181182} - {fileID: 1586181182}
- {fileID: 1335608360}
+2 -1
View File
@@ -1,4 +1,5 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:Template name="ShortcutMenu" src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ShortcutMenu.uxml?fileID=9197481963319205126&amp;guid=531a74f84d51b5d49a048079629e13e0&amp;type=3#ShortcutMenu" />
<Style src="project://database/Assets/UI%20Toolkit/Document/Document.uss?fileID=7433441132597879392&amp;guid=9205939af30a4394f8f2e34232b27890&amp;type=3#Document" /> <Style src="project://database/Assets/UI%20Toolkit/Document/Document.uss?fileID=7433441132597879392&amp;guid=9205939af30a4394f8f2e34232b27890&amp;type=3#Document" />
<ui:VisualElement name="Menu" picking-mode="Ignore" class="document-page" style="flex-grow: 1; align-items: flex-start;" /> <ui:Instance template="ShortcutMenu" name="ShortcutMenu" picking-mode="Ignore" class="document-page" />
</ui:UXML> </ui:UXML>
@@ -1,7 +0,0 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/UI%20Toolkit/GamePanel/Menu/Menu.uss?fileID=7433441132597879392&amp;guid=a53da9fc389948e40ac96af14dd02c10&amp;type=3#Menu" />
<ui:VisualElement class="menu-unit" style="flex-grow: 0; flex-direction: row; align-self: flex-start;">
<ui:Label tabindex="-1" text="Label" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label" class="menu-label" style="-unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; height: 30px;" />
<ui:VisualElement name="Arrow" style="flex-grow: 0; height: 30px; width: 30px; background-image: url(&quot;project://database/Assets/UI%20Toolkit/DefaultTheme/UnityDefaultRuntimeTheme.tss?fileID=-1087164816274819069&amp;guid=05f864e67ee1ecb4bbe67427564d394c&amp;type=3#arrow-right@2x&quot;); -unity-background-image-tint-color: rgb(51, 51, 51);" />
</ui:VisualElement>
</ui:UXML>
-10
View File
@@ -1,10 +0,0 @@
.menu-unit {
}
.menu-unit:hover {
background-color: rgba(0, 0, 0, 0.2);
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
@@ -0,0 +1,7 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ShortcutMenu.uss?fileID=7433441132597879392&amp;guid=a53da9fc389948e40ac96af14dd02c10&amp;type=3#ShortcutMenu" />
<ui:VisualElement class="menu-unit">
<ui:Label tabindex="-1" text="Label" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Name" style="-unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; height: 30px;" />
<ui:VisualElement name="Arrow" class="menu-arrow" />
</ui:VisualElement>
</ui:UXML>
@@ -1,6 +1,6 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:Template name="Item" src="project://database/Assets/UI%20Toolkit/GamePanel/Menu/Item.uxml?fileID=9197481963319205126&amp;guid=1ee167986f6e9a840a45450b4b6adfc2&amp;type=3#Item" /> <ui:Template name="Item" src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ItemTemplate.uxml?fileID=9197481963319205126&amp;guid=1ee167986f6e9a840a45450b4b6adfc2&amp;type=3#ItemTemplate" />
<Style src="project://database/Assets/UI%20Toolkit/GamePanel/Menu/Menu.uss?fileID=7433441132597879392&amp;guid=a53da9fc389948e40ac96af14dd02c10&amp;type=3#Menu" /> <Style src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ShortcutMenu.uss?fileID=7433441132597879392&amp;guid=a53da9fc389948e40ac96af14dd02c10&amp;type=3#ShortcutMenu" />
<ui:VisualElement name="Container" style="background-color: rgb(255, 255, 255); border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; align-self: flex-start;"> <ui:VisualElement name="Container" style="background-color: rgb(255, 255, 255); border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; align-self: flex-start;">
<ui:Instance template="Item" name="Item" /> <ui:Instance template="Item" name="Item" />
<ui:Instance template="Item" name="Item" /> <ui:Instance template="Item" name="Item" />
@@ -0,0 +1,32 @@
.menu {
position: absolute;
}
.menu-hide {
display: none;
}
.menu-unit {
flex-direction: row;
align-self: flex-start;
}
.menu-unit:hover {
background-color: rgba(0, 0, 0, 0.2);
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
.menu-arrow {
flex-grow: 0;
height: 30px;
width: 30px;
background-image: url("project://database/Assets/UI%20Toolkit/DefaultTheme/UnityDefaultRuntimeTheme.tss?fileID=-1087164816274819069&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#arrow-right@2x");
-unity-background-image-tint-color: rgb(51, 51, 51);
}
.menu-arrow-hide {
display: none;
}
@@ -0,0 +1,3 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ShortcutMenu.uss?fileID=7433441132597879392&amp;guid=a53da9fc389948e40ac96af14dd02c10&amp;type=3#ShortcutMenu" />
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 531a74f84d51b5d49a048079629e13e0
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}