2025-09-25 19:04:05 +08:00
|
|
|
|
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)]
|
2025-10-06 16:09:52 +08:00
|
|
|
|
public IEnumerator LoadSpline(string path)
|
2025-09-25 19:04:05 +08:00
|
|
|
|
{
|
2025-10-06 16:09:52 +08:00
|
|
|
|
yield return this.LoadSplineTool(path);
|
2025-09-25 19:04:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|