更新至unity6并且更改Scriptable完成

This commit is contained in:
2025-11-25 10:52:39 +08:00
parent 2e0d16db49
commit 5d6acc1001
482 changed files with 2314 additions and 47257 deletions

View File

@@ -16,11 +16,6 @@ namespace Demo.Game
protected override abstract void UpdateData(float data);
public override IEnumerator LoadScript(string script)
{
yield return base.LoadScript(script);
}
public override IEnumerator UnloadScript()
{
MySplineCore = null;
@@ -34,26 +29,19 @@ namespace Demo.Game
/// <param name="value"></param>
/// <param name="curveType">可取值为30种缓动曲线</param>
[Convention.RScript.Variable.Attr.Method]
public void Add(string time, string value, string curveType)
public void Add(float time, float value, MathExtension.EaseCurveType curveType)
{
ManualAddEntry(time, float.Parse(value), Enum.Parse<MathExtension.EaseCurveType>(curveType));
ManualAddEntry(time, value, curveType);
}
/// <summary>
/// 如未加载则加载,然后绑定到样条线
/// 绑定到样条线
/// </summary>
/// <param name="path">脚本位置</param>
[Convention.RScript.Variable.Attr.Method]
public IEnumerator Load(string path)
public void Load(SplineCore splineCore)
{
MySplineCore = FindWithPath(path, false) as SplineCore;
if (MySplineCore == null)
{
yield return DoLoadSubScriptAsync(nameof(SplineCore), path, x =>
{
MySplineCore = x as SplineCore;
});
}
MySplineCore = splineCore;
}
}
}

View File

@@ -1,109 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using Convention;
using Convention.WindowsUI.Variant;
using Dreamteck.Splines;
using UnityEngine;
namespace Demo.Game
{
public class SplineHeadObject : BasicSplineJustFollow
{
public static SplineHeadObject Make()
{
return new GameObject().AddComponent<SplineHeadObject>();
}
private SplineRenderer MySplineRenderer;
/// <summary>
/// 设置为仅跟随将会被动的跟随spline运动
/// 这在多个脚本都绑定在同一个spline计算核心上时非常有用
/// </summary>
[Content, SerializeField] private bool IsJustFollow = false;
[Content, SerializeField] private double Cache = 0;
protected override void UpdateData(float data)
{
var sample = MySplineCore.MySplineComputer.Evaluate(data);
Cache = sample.percent;
UpdateTarget.transform.SetPositionAndRotation(sample.position, sample.rotation);
//UpdateTarget.transform.localScale = Vector3.one * sample.size;
}
private SceneGameWindow SceneStats;
public override IEnumerator LoadScript(string script)
{
SceneStats = FindObjectOfType<SceneGameWindow>();
yield return base.LoadScript(script);
if (GetRoot().RootGameController.IsHideTrackRender == false)
{
if (MySplineCore == null)
yield break;
var splineGameObject = MySplineCore.gameObject;
splineGameObject.GetOrAddComponent<MeshFilter>();
var meshRenderer = splineGameObject.GetOrAddComponent<MeshRenderer>();
meshRenderer.enabled = true;
meshRenderer.material = Resources.Load<Material>("Line/Dash");
MySplineRenderer = splineGameObject.AddComponent<SplineRenderer>();
MySplineRenderer.spline = MySplineCore.MySplineComputer;
MySplineRenderer.uvMode = MeshGenerator.UVMode.UniformClip;
MySplineRenderer.Rebuild();
}
}
protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType)
{
base.UpdateTicks(currentTime, deltaTime, tickType);
if (GetRoot().RootGameController.IsHideTrackRender == false)
{
if (IsJustFollow == false)
{
if (SceneStats.IsSelectSceneCamera || tickType == TickType.Pause || tickType == TickType.Reset)
{
MySplineCore.gameObject.GetComponent<MeshRenderer>().enabled = true;
MySplineCore.gameObject.GetComponent<SplineRenderer>().Rebuild();
}
else if (tickType == TickType.Start)
{
MySplineCore.gameObject.GetComponent<MeshRenderer>().enabled = false;
}
//不为跟随模式时需要自己更新clip
if (tickType == TickType.Update || tickType == TickType.Reset)
{
MySplineRenderer.clipFrom = Cache;
}
}
else
{
}
}
}
public override IEnumerator UnloadScript()
{
if (GetRoot().RootGameController.IsHideTrackRender == false)
{
var splineGameObject = MySplineCore.gameObject;
Destroy(splineGameObject.GetComponent<SplineRenderer>());
Destroy(splineGameObject.GetComponent<MeshRenderer>());
Destroy(splineGameObject.GetComponent<MeshFilter>());
MySplineCore = null;
MySplineRenderer = null;
}
yield return base.UnloadScript();
}
/// <summary>
/// 设置为仅跟随将会被动的跟随spline运动
/// 这在多个脚本都绑定在同一个spline计算核心上时非常有用
/// </summary>
[Convention.RScript.Variable.Attr.Method]
public void JustFollow()
{
IsJustFollow = true;
}
}
}

View File

@@ -13,94 +13,9 @@ namespace Demo.Game
return new GameObject().AddComponent<SplineMovement>();
}
private SplineRenderer MySplineRenderer;
/// <summary>
/// 设置为仅跟随将会被动的跟随spline运动
/// 这在多个脚本都绑定在同一个spline计算核心上时非常有用
/// </summary>
[Content, SerializeField] private bool IsJustFollow = false;
[Content, SerializeField] private double Cache = 0;
protected override void UpdateData(float data)
{
Cache = MySplineCore.MySplineComputer.Evaluate(data).percent;
UpdateTarget.transform.position = MySplineCore.MySplineComputer.EvaluatePosition(data);
}
private SceneGameWindow SceneStats;
public override IEnumerator LoadScript(string script)
{
SceneStats = FindObjectOfType<SceneGameWindow>();
yield return base.LoadScript(script);
if (GetRoot().RootGameController.IsHideTrackRender == false)
{
if (MySplineCore == null)
yield break;
var splineGameObject = MySplineCore.gameObject;
splineGameObject.GetOrAddComponent<MeshFilter>();
var meshRenderer = splineGameObject.GetOrAddComponent<MeshRenderer>();
meshRenderer.enabled = true;
meshRenderer.material = Resources.Load<Material>("Line/Dash");
MySplineRenderer = splineGameObject.AddComponent<SplineRenderer>();
MySplineRenderer.spline = MySplineCore.MySplineComputer;
MySplineRenderer.uvMode = MeshGenerator.UVMode.UniformClip;
MySplineRenderer.Rebuild();
}
}
protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType)
{
base.UpdateTicks(currentTime, deltaTime, tickType);
if (GetRoot().RootGameController.IsHideTrackRender == false)
{
if (IsJustFollow == false)
{
if (SceneStats.IsSelectSceneCamera || tickType == TickType.Pause || tickType == TickType.Reset)
{
MySplineCore.gameObject.GetComponent<MeshRenderer>().enabled = true;
MySplineCore.gameObject.GetComponent<SplineRenderer>().Rebuild();
}
else if (tickType == TickType.Start)
{
MySplineCore.gameObject.GetComponent<MeshRenderer>().enabled = false;
}
//不为跟随模式时需要自己更新clip
if (tickType == TickType.Update || tickType == TickType.Reset)
{
MySplineRenderer.clipFrom = Cache;
}
}
else
{
}
}
}
public override IEnumerator UnloadScript()
{
if (GetRoot().RootGameController.IsHideTrackRender == false)
{
var splineGameObject = MySplineCore.gameObject;
Destroy(splineGameObject.GetComponent<SplineRenderer>());
Destroy(splineGameObject.GetComponent<MeshRenderer>());
Destroy(splineGameObject.GetComponent<MeshFilter>());
MySplineCore = null;
MySplineRenderer = null;
}
yield return base.UnloadScript();
}
/// <summary>
/// 设置为仅跟随将会被动的跟随spline运动
/// 这在多个脚本都绑定在同一个spline计算核心上时非常有用
/// </summary>
[Convention.RScript.Variable.Attr.Method]
public void JustFollow()
{
IsJustFollow = true;
}
}
}

View File

@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using Convention;
using Convention.WindowsUI.Variant;
using Dreamteck.Splines;
using UnityEngine;
namespace Demo.Game
{
public class SplinePointerObject : BasicSplineJustFollow
{
public static SplinePointerObject Make()
{
return new GameObject().AddComponent<SplinePointerObject>();
}
protected override void UpdateData(float data)
{
var sample = MySplineCore.MySplineComputer.Evaluate(data);
UpdateTarget.transform.SetPositionAndRotation(sample.position, sample.rotation);
}
}
}