Odin Inspector 系列教程 — On Inspector Dispose Attribute

当重新创建、销毁、置空时,都会执行对应的Dispose操作

using Sirenix.OdinInspector;
using UnityEngine;

public class OnInspectorDisposeAttributeExample : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    [OnInspectorDispose("@UnityEngine.Debug.Log(\"Dispose event invoked!\")")]
    [ShowInInspector, InfoBox("当重新创建、销毁、置空时,都会执行对应的Dispose操作."), DisplayAsString]
    public BaseClass PolymorphicField;

    public abstract class BaseClass { public override string ToString() { return this.GetType().Name; } }
    public class A : BaseClass { }
    public class B : BaseClass { }
    public class C : BaseClass { }
}

更多教程内容详见:革命性Unity 编辑器扩展工具 — Odin Inspector 系列教程

发表评论