karsion / ActionSequenceSystem

A Unity3D C# multifunctional chaining timer system 一个U3D C# 多功能链式计时器
MIT License
68 stars 15 forks source link

Question about usage #4

Open MostHated opened 3 years ago

MostHated commented 3 years ago

Hello, I was wondering if you happen to know if this works in the editor or if it is only for runtime code? Such as, could I used it to perform sequential/timed events within editor scripts?

Thanks, -MH

karsion commented 3 years ago

Editor mode is not supported at the moment. This requirement will be added later. In fact, you can implement it yourself, just put the update in the editor's update driver. e.g.

if UNITY_EDITOR

    [UnityEditor.InitializeOnLoadMethod]
    static void InitializeEditor()
    {
        UnityEditor.EditorApplication.update += () =>
        {
            if (!Application.isPlaying)
            {
                unitedUpdate?.Invoke();

                if (unitedUpdateOnce != null)
                {
                    var call = unitedUpdateOnce;
                    unitedUpdateOnce = null;
                    call();
                }
            }
        };
    }

endif