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;


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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章