异步加载已修复, Config更新正推动

This commit is contained in:
2025-12-18 15:11:33 +08:00
parent 1436080fd6
commit ab60b35be2
20 changed files with 190 additions and 132 deletions

View File

@@ -1,16 +1,17 @@
using System;
using Convention;
using Demo.Game.ConfigType;
using Dreamteck.Splines;
using System.Collections;
using System.IO;
using Convention;
using Dreamteck.Splines;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Rendering;
namespace Demo.Game
{
namespace ConfigType
{
public class BasicSplineRendererConfig : UpdatementVec2Config
public class BasicSplineRendererConfig : UpdatementConfig<SplineClipDuration>
{
public int MySplineCore;
public string LinesAssetBundlePath;
@@ -31,11 +32,38 @@ namespace Demo.Game
BinarySerializeUtility.WriteString(writer, MyDefaultMaterial);
base.Serialize(writer);
}
protected override void DeserializePositions(BinaryReader reader, ref NativeArray<SplineClipDuration> positions)
{
NativeArray<Vector2> temp = new(0, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
int e = BinarySerializeUtility.DeserializeNativeArray(reader, ref temp);
positions.ResizeArray(e);
for (int i = 0; i < e; i++)
{
positions[i] = new(temp[i].x, temp[i].y);
}
temp.Dispose();
}
protected override void SerializePositions(BinaryWriter writer, in NativeArray<SplineClipDuration> positions)
{
NativeArray<Vector2> temp = new(positions.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
for (int i = 0, e=positions.Length; i < e; i++)
{
temp[i] = new(positions[i].ClipFrom, positions[i].ClipTo);
}
BinarySerializeUtility.SerializeNativeArray(writer, temp);
temp.Dispose();
}
}
}
public abstract class BasicSplineRenderer : Updatement<SplineClipDuration>, IAssetBundleLoader, IDependOnSplineCore
{
protected override ConfigType.ScriptLoadableConfig MakeConfig()
{
return new BasicSplineRendererConfig();
}
/// <summary>
/// 加载并绑定到新样条线
/// </summary>

View File

@@ -1,5 +1,6 @@
using Convention;
using Demo.Game.Attr;
using Demo.Game.ConfigType;
using Dreamteck.Splines;
using System;
using System.Collections;
@@ -36,6 +37,10 @@ namespace Demo.Game
[Scriptable]
public class SplineTubeRenderer : BasicSplineRenderer<TubeGenerator>
{
protected override ScriptLoadableConfig MakeConfig()
{
return new SplineTubeRendererConfig();
}
public static SplineTubeRenderer Make()
{
return new GameObject().AddComponent<SplineTubeRenderer>();

View File

@@ -76,14 +76,6 @@ namespace Demo.Game
public bool IsClose = false;
public SplineComputer MySplineComputer => m_MySplineComputer;
//{
// get
// {
// if (m_MySplineComputer == null)
// m_MySplineComputer = this.GetComponent<SplineComputer>();
// return m_MySplineComputer;
// }
//}
/// <summary>
/// <see cref="SplineCore"/>需要在子<see cref="SplineNode"/>都添加后再应用脚本才能使得节点生效

View File

@@ -75,6 +75,7 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method]
public void SetNodeSize(float size)
{
SetLocalScaling(size, size, size);
NodeSize = size;
}

View File

@@ -1,14 +1,15 @@
using Convention;
using Demo.Game.ConfigType;
using System;
using System.Collections;
using System.IO;
using Convention;
using UnityEngine;
namespace Demo.Game
{
namespace ConfigType
{
public class BasicSplineJustFollowConfig : ScriptLoadableConfig
public class BasicSplineJustFollowConfig : UpdatementFloatConfig
{
public int MySplineCore;
public override void Deserialize(BinaryReader reader)
@@ -27,6 +28,10 @@ namespace Demo.Game
public abstract class BasicSplineJustFollow : Updatement<float>, IDependOnSplineCore
{
protected override ConfigType.ScriptLoadableConfig MakeConfig()
{
return new BasicSplineJustFollowConfig();
}
/// <summary>
/// 加载并绑定到新样条线
/// </summary>

View File

@@ -1,8 +1,4 @@
using Convention;
using Convention.WindowsUI.Variant;
using Demo.Game.Attr;
using Dreamteck.Splines;
using System.Collections;
using UnityEngine;
namespace Demo.Game

View File

@@ -1,9 +1,4 @@
using Convention;
using Convention.WindowsUI.Variant;
using Demo.Game.Attr;
using Dreamteck.Splines;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Demo.Game

View File

@@ -1,7 +1,4 @@
using Convention;
using Demo.Game.Attr;
using System;
using System.Collections;
using UnityEngine;
namespace Demo.Game