异步加载已修复, Config更新正推动
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user