72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using Convention;
|
|
using UnityEngine;
|
|
|
|
namespace Demo.Game
|
|
{
|
|
public abstract class BasicSplineJustFollow : Updatement<float>
|
|
{
|
|
public SplineCore MySplineCore;
|
|
|
|
protected override float Lerp(float begin, float end, float t)
|
|
{
|
|
return Mathf.Lerp(begin, end, t);
|
|
}
|
|
|
|
protected override abstract void UpdateData(float data);
|
|
|
|
public override IEnumerator LoadScript(string script)
|
|
{
|
|
yield return base.LoadScript(script);
|
|
}
|
|
|
|
public override IEnumerator UnloadScript()
|
|
{
|
|
MySplineCore = null;
|
|
yield return base.UnloadScript();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增
|
|
/// </summary>
|
|
/// <param name="time">插值时间</param>
|
|
/// <param name="value"></param>
|
|
/// <param name="curveType">可取值为30种缓动曲线</param>
|
|
[ScriptableCall(@"
|
|
<summary>
|
|
新增
|
|
</summary>
|
|
<param name=""time"">插值时间</param>
|
|
<param name=""value""></param>
|
|
<param name=""curveType"">可取值为30种缓动曲线</param>
|
|
")]
|
|
public void Add(string time, string value, string curveType)
|
|
{
|
|
ManualAddEntry(time, float.Parse(value), Enum.Parse<MathExtension.EaseCurveType>(curveType));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 如未加载则加载,然后绑定到样条线
|
|
/// </summary>
|
|
/// <param name="path">脚本位置</param>
|
|
[ScriptableCall(@"
|
|
<summary>
|
|
如未加载则加载,然后绑定到样条线
|
|
</summary>
|
|
<param name=""path"">脚本位置</param>
|
|
")]
|
|
public IEnumerator Load(string path)
|
|
{
|
|
MySplineCore = FindWithPath(path, false) as SplineCore;
|
|
if (MySplineCore == null)
|
|
{
|
|
yield return LoadSubScriptAsync(nameof(SplineCore), path, x =>
|
|
{
|
|
MySplineCore = x as SplineCore;
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|