Exemple #1
0
        void Start()
        {
            var timelineNode = new TimelineNode();

            // 第一秒输出 HelloWorld
            timelineNode.Append(1.0f, EventAction.Allocate(() => Debug.Log("HelloWorld")));

            // 第二秒输出 延时了 2 秒
            timelineNode.Append(2.0f, EventAction.Allocate(() => Debug.Log("延时了 2 秒")));

            // 第三秒发送 一个事件
            timelineNode.Append(3.0f, new KeyEventAction("someEventA", timelineNode));

            // 第四秒发送 一个事件
            timelineNode.Append(4.0f, new KeyEventAction("someEventB", timelineNode));

            // 监听 timeline 的 key 事件
            timelineNode.OnKeyEventsReceivedCallback = keyEvent => Debug.Log(keyEvent);

            // 执行 timeline
            this.ExecuteNode(timelineNode);
        }
Exemple #2
0
        public static void PlayRecordAction(string fileName)
        {
            var actionFile = SerializeHelper.LoadJson <ActionRecordFile>(Application.dataPath.CombinePath("131576376315678780"));

            var timelineNode = new TimelineNode();

            foreach (var recordData in actionFile.RecordData)
            {
                var actionName = recordData.ActionName;
                timelineNode.Append(new TimelineNode.TimelinePair(recordData.ExecuteTime, EventAction.Allocate(() =>
                {
                    PTUIManager.Instance.SendMsg(new ActionMsg(actionName));
                })));
            }

            Instance.ExecuteNode(timelineNode);
        }