unity Editor 序列化枚举颜色中文等

`
using System;
using UnityEngine;



//显示中文
[AttributeUsage(AttributeTargets.Field)]
public class InspectorShow : PropertyAttribute
{
    public string label;        //要显示的字符
    public string htmlColor;    //颜色
    public InspectorShow(string label,string htmlColor= "#FFFFFF")
    {
        this.label = label;
    }

}


//显示颜色
public class TitleAttribute : PropertyAttribute
{
    /// <summary> 标题名称 </summary>
    public string title;
    /// <summary> 标题颜色 </summary>
    public string htmlColor;

    /// <summary> 在属性上方添加一个标题 </summary>
    /// <param name="title">标题名称</param>
    /// <param name="htmlColor">标题颜色</param>
    public TitleAttribute(string title, string htmlColor = "#EE3B3B")
    {
        this.title = title;
        this.htmlColor = htmlColor;
    }

}


//显示枚举名称
[AttributeUsage(AttributeTargets.Field)]
public class EnumNameAttribute : PropertyAttribute
{
    /// <summary> 枚举名称 </summary>
    public string name;
    /// <summary> 标题颜色 </summary>
    public string htmlColor;
    public new int[] order = new int[0];

    public EnumNameAttribute(string name)
    {
        this.name = name;
        this.htmlColor = "#EE3B3B";
    }

    public EnumNameAttribute(string label, params int[] order)
    {
        this.name = label;
        this.order = order;
        this.htmlColor = "#EE3B3B";
    }

}
 	public GameObject XiufuTaiArrow = null;
    [TitleAttribute("此位置是否是区域解锁点")]
    public bool DisplayCloudUi = false;
    [TitleAttribute("此位置是否是修复台")]
    public bool XiufuTai = false;
    [TitleAttribute("解锁需要的治疗值")]
    public int Hp;
    [TitleAttribute("解锁时上升的顺序")]
    public int Shunxv = -1;
    [TitleAttribute("选择解锁属性")]
    [EnumNameAttribute("解锁属性:",new int[5] { 1,2,3,4,5})]
    public GrayType IsTeshu = GrayType.None;


效果图:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值