Config类新增
This commit is contained in:
Submodule Assets/Convention updated: 32f0038e34...a530eba460
@@ -1,9 +1,5 @@
|
|||||||
using Convention;
|
using Convention;
|
||||||
using Convention.RScript;
|
|
||||||
using Convention.WindowsUI.Variant;
|
using Convention.WindowsUI.Variant;
|
||||||
using Demo.Game.Attr;
|
|
||||||
using Demo.Game;
|
|
||||||
using Dreamteck.Splines;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -11,9 +7,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Unity.Collections;
|
using Unity.Collections;
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
namespace Demo.Game
|
namespace Demo.Game
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,11 +3,109 @@ using Demo.Editor.UI;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using Unity.Collections;
|
using Unity.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Demo.Game
|
namespace Demo.Game
|
||||||
{
|
{
|
||||||
|
namespace ConfigType
|
||||||
|
{
|
||||||
|
public abstract class UpdatementConfig<DataType>: ScriptLoadableConfig where DataType : struct
|
||||||
|
{
|
||||||
|
public NativeArray<float> TimePoints;
|
||||||
|
public NativeArray<DataType> Positions;
|
||||||
|
public NativeArray<MathExtension.EaseCurveType> EaseCurveTypes;
|
||||||
|
|
||||||
|
protected abstract void DeserializePositions(BinaryReader reader, ref NativeArray<DataType> positions);
|
||||||
|
protected abstract void SerializePositions(BinaryWriter writer, in NativeArray<DataType> positions);
|
||||||
|
|
||||||
|
public override void Deserialize(BinaryReader reader)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.DeserializeNativeArray(reader, ref TimePoints);
|
||||||
|
DeserializePositions(reader, ref Positions);
|
||||||
|
{
|
||||||
|
NativeArray<int> temp = new(EaseCurveTypes.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
|
||||||
|
BinarySerializeUtility.DeserializeNativeArray(reader, ref temp);
|
||||||
|
for (int i = 0, e = EaseCurveTypes.Length; i < e; i++)
|
||||||
|
{
|
||||||
|
EaseCurveTypes[i] = (MathExtension.EaseCurveType)temp[i];
|
||||||
|
}
|
||||||
|
temp.Dispose();
|
||||||
|
}
|
||||||
|
base.Deserialize(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Serialize(BinaryWriter writer)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.SerializeNativeArray(writer, TimePoints);
|
||||||
|
SerializePositions(writer, Positions);
|
||||||
|
{
|
||||||
|
NativeArray<int> temp = new(EaseCurveTypes.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
|
||||||
|
for (int i = 0, e = EaseCurveTypes.Length; i < e; i++)
|
||||||
|
{
|
||||||
|
temp[i] = (int)EaseCurveTypes[i];
|
||||||
|
}
|
||||||
|
BinarySerializeUtility.SerializeNativeArray(writer, temp);
|
||||||
|
temp.Dispose();
|
||||||
|
}
|
||||||
|
base.Serialize(writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdatementIntConfig : UpdatementConfig<int>
|
||||||
|
{
|
||||||
|
protected override void DeserializePositions(BinaryReader reader, ref NativeArray<int> positions)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SerializePositions(BinaryWriter writer, in NativeArray<int> positions)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.SerializeNativeArray(writer, positions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdatementFloatConfig : UpdatementConfig<float>
|
||||||
|
{
|
||||||
|
protected override void DeserializePositions(BinaryReader reader, ref NativeArray<float> positions)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SerializePositions(BinaryWriter writer, in NativeArray<float> positions)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.SerializeNativeArray(writer, positions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdatementVec2Config : UpdatementConfig<Vector2>
|
||||||
|
{
|
||||||
|
protected override void DeserializePositions(BinaryReader reader, ref NativeArray<Vector2> positions)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SerializePositions(BinaryWriter writer, in NativeArray<Vector2> positions)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.SerializeNativeArray(writer, positions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdatementVec3Config : UpdatementConfig<Vector3>
|
||||||
|
{
|
||||||
|
protected override void DeserializePositions(BinaryReader reader, ref NativeArray<Vector3> positions)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SerializePositions(BinaryWriter writer, in NativeArray<Vector3> positions)
|
||||||
|
{
|
||||||
|
BinarySerializeUtility.SerializeNativeArray(writer, positions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class Updatement<DataType> : TimelineScriptObject where DataType : struct
|
public abstract class Updatement<DataType> : TimelineScriptObject where DataType : struct
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|||||||
Reference in New Issue
Block a user