示例#1
0
        private void Start()
        {
            this.Sequence()
            .Delay(1.0f)
            .Event(() => Log.I("Sequence1 延时了 1s"))
            .Begin()
            .DisposeWhenFinished()                     // Default is DisposeWhenGameObjDestroyed
            .OnDisposed(() => { Log.I("Sequence1 destroyed"); });

            var sequenceNode2 = SequenceNode.Allocate(DelayNode.Allocate(1.5f));

            sequenceNode2.Append(EventNode.Allocate(() => Log.I("Sequence2 延时 1.5s")));
            sequenceNode2.Append(DelayNode.Allocate(0.5f));
            sequenceNode2.Append(EventNode.Allocate(() => Log.I("Sequence2 延时 2.0s")));

            this.ExecuteNode(sequenceNode2);

            /* 这种方式需要自己手动进行销毁
             * sequenceNode2.Dispose();
             * sequenceNode2 = null;
             */

            // 或者 OnDestroy 触发时进行销毁
            sequenceNode2.AddTo(this);
        }
 public static IExecuteNodeChain Event(this IExecuteNodeChain selfChain, params Action[] onEvents)
 {
     return(selfChain.Append(EventNode.Allocate(onEvents)));
 }