63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using Demo.Game;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Demo.Game
|
|||
|
|
{
|
|||
|
|
public class SplineAnchor : ScriptableObject,IDependOnSplineCore, IDependOnSplineRenderer
|
|||
|
|
{
|
|||
|
|
public static SplineAnchor Make()
|
|||
|
|
{
|
|||
|
|
return new GameObject().AddComponent<SplineAnchor>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public SplineCore MySplineCore { get; set; }
|
|||
|
|
public BasicSplineRenderer MySplineRenderer { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 加载并绑定到新样条线
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="path">对象路径, 不存在时则立刻加载</param>
|
|||
|
|
[ScriptableCall(DependOnSplineCoreUtility.LoadSplineDescription)]
|
|||
|
|
public void LoadSpline(string path)
|
|||
|
|
{
|
|||
|
|
this.LoadSplineTool(path);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 必须先执行LoadSpline加载样条线
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="value">百分比所在位置,取值范围是[0,1]</param>
|
|||
|
|
[ScriptableCall(@"
|
|||
|
|
<summary>
|
|||
|
|
必须先执行LoadSpline加载样条线
|
|||
|
|
</summary>
|
|||
|
|
<param name=""value"">百分比所在位置,取值范围是[0,1]</param>
|
|||
|
|
")]
|
|||
|
|
public void EvaluatePosition(string value)
|
|||
|
|
{
|
|||
|
|
transform.position = MySplineCore.MySplineComputer.EvaluatePosition(Parse(value));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定到样条线渲染器上(必须已经加载),
|
|||
|
|
/// 并设置位置为指定时间的时刻渲染器所生成的头部位置
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="path">对象路径, 不存在时则立刻加载</param>
|
|||
|
|
/// <param name="time">时刻</param>
|
|||
|
|
[ScriptableCall(@"
|
|||
|
|
<summary>
|
|||
|
|
绑定到样条线渲染器上(必须已经加载),
|
|||
|
|
并设置位置为指定时间的时刻渲染器所生成的头部位置
|
|||
|
|
</summary>
|
|||
|
|
<param name=""path"">对象路径, 不存在时则立刻加载</param>
|
|||
|
|
<param name=""time"">时刻</param>
|
|||
|
|
")]
|
|||
|
|
public void LoadSplineRenderer(string path, string time)
|
|||
|
|
{
|
|||
|
|
transform.position = this.LoadSplineRendererTool(path).EvaluateClipToPosition(Parse(time));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|