Tz2/Assets/Zion/Scripts/Editor/TreeMenuData.cs

56 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace Zion.Scripts.Editor
{
/// <summary>
/// 定义树状菜单项
/// </summary>
[Serializable]
public class TreeMenuItem
{
public string name; // 菜单项名称
public string icon; // 菜单项图标
public string action; // 点击动作/事件名称
public List<TreeMenuItem> children; // 子菜单项
public bool isExpanded = true; // 编辑器中是否展开
public TreeMenuItem()
{
name = "新菜单项";
children = new List<TreeMenuItem>();
}
public TreeMenuItem(string name)
{
this.name = name;
children = new List<TreeMenuItem>();
}
}
/// <summary>
/// 定义树状菜单配置
/// </summary>
[CreateAssetMenu(fileName = "TreeMenuData", menuName = "Zion/树状菜单数据", order = 1)]
public class TreeMenuData : ScriptableObject
{
public string menuTitle = "树状菜单"; // 菜单标题
public List<TreeMenuItem> menuItems; // 根菜单项列表
public Color backgroundColor = Color.white; // 背景颜色
public Color textColor = Color.black; // 文本颜色
public Color highlightColor = new Color(0.2f, 0.4f, 0.8f); // 高亮颜色
public Font menuFont; // 菜单字体
public int fontSize = 14; // 字体大小
public float itemHeight = 30f; // 每个菜单项的高度
public float indentWidth = 20f; // 子菜单缩进宽度
private void OnEnable()
{
if (menuItems == null)
{
menuItems = new List<TreeMenuItem>();
}
}
}
}