Unity编译器扩展继承BaseEditorWindow脚本放在Editor文件夹下。

using Sirenix.OdinInspector.Editor;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;

///


/// Unity默认编译器扩展
///

public class TestEditor : BaseEditorWindow//主界面上栏显示
{
[Test1("Unituedi")]//自定义特性
public string s;
public ItemVO itemvo;

[MenuItem("Test/Open")]//主界面Test栏下的选项(静态方法点击后执行)
public static void Open()
{
    //打开窗口
    GetWindow<TestEditor>().Show();
    Debug.Log("Show");
}

}

public class Test1Attribute : Attribute
{
public string str;
public Test1Attribute(string s)
{
str = s;
}
}
——————————————————————————
///


/// 为类中的属性添加特性,并改变特性中属性值
///

public class TestEditorAttributeProcessor : OdinAttributeProcessor
{
public override void ProcessChildMemberAttributes(InspectorProperty parentProperty, MemberInfo member, List attributes)
{
base.ProcessChildMemberAttributes(parentProperty, member, attributes);
if (member.Name == nameof(TestEditor.s))
{
attributes.Add(new Test1Attribute("attr"));
}
}
}
——————————————————————————
//对特性属性进行绘制,反射获取对应特性中内容.右键选项拓展
public class Test1AttributeDrawer : OdinAttributeDrawer, IDefinesGenericMenuItems
{
///
/// 实现鼠标右键点击接口
///

///
///
public void PopulateGenericMenu(InspectorProperty property, GenericMenu genericMenu)
{
genericMenu.AddItem(new GUIContent("Rigth"), false, AAA);

}
//右键点击发方法
private void AAA()
{
    //throw new NotImplementedException();
    EditorWindow.GetWindow<EquipmentEffectWindow>().Show();
    Debug.Log(Attribute.str);
}

//重写Odin绘制方法
protected override void DrawPropertyLayout(GUIContent label)
{
    //绘制按钮
    //if (GUILayout.Button("Test"))
    //{
    //    Debug.Log(Attribute.str);
    //}
    //继续绘制链GUI元素(被特性编辑的属性)
    CallNextDrawer(label);
}

}