37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using SK.Framework;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ActionExample : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject cube;
|
|
[SerializeField] private GameObject sphere;
|
|
private TimelineActionChain timeline;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
timeline = this.Timeline()
|
|
//通过Append添加时间轴事件
|
|
//第一个参数表示该事件开始的时间节点
|
|
//第二个参数表示该事件的时长
|
|
.Append(0f, 5f, s => cube.transform.position = Vector3.Lerp(Vector3.zero, new Vector3(0, 0, 5f), s))
|
|
.Append(2f, 4f, s => sphere.transform.position = Vector3.Lerp(Vector3.zero, Vector3.up * 2f, s))
|
|
.Begin() as TimelineActionChain;
|
|
|
|
//2倍速
|
|
timeline.Speed = 0f;
|
|
//timeline.Pause();
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.Label("时间轴");
|
|
//通过Slider调整CurrentTime 实现从指定的时间节点执行
|
|
timeline.CurrentTime = GUILayout.HorizontalSlider(timeline.CurrentTime, 0f, 5f, GUILayout.Width(300f), GUILayout.Height(50f));
|
|
GUILayout.EndHorizontal();
|
|
}
|
|
|
|
}
|