From ab60b35be25fa16e5f7418a1ce373a55485f4dad Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Thu, 18 Dec 2025 15:11:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=8A=A0=E8=BD=BD=E5=B7=B2?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D,=20Config=E6=9B=B4=E6=96=B0=E6=AD=A3?= =?UTF-8?q?=E6=8E=A8=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Environment/SkyUpdatement.cs | 5 + .../Framework/GameContent/GameController.cs | 24 +++- Assets/Scripts/Framework/ScriptableObject.cs | 26 +++-- .../DefaultScriptableObjectInstantiate.cs | 40 ++++--- Assets/Scripts/Framework/SubWorld.cs | 9 +- Assets/Scripts/Framework/Updatement.cs | 106 +++++++----------- Assets/Scripts/LookAtAnchor.cs | 7 +- Assets/Scripts/MaterialUpdatement.cs | 6 +- .../BaseOnMaterialUpdatement.cs | 7 +- .../PointBaseRenderer/BasicSplineRenderer.cs | 36 +++++- .../PointBaseRenderer/SplineTubeRenderer.cs | 5 + Assets/Scripts/MoreSpline/SplineCore.cs | 8 -- Assets/Scripts/MoreSpline/SplineNode.cs | 1 + .../Updatement/BasicSplineJustFollow.cs | 9 +- .../MoreSpline/Updatement/SplineMovement.cs | 4 - .../Updatement/SplinePointerObject.cs | 5 - .../MoreSpline/Updatement/SplineRotation.cs | 3 - Assets/Scripts/TickMovement.cs | 9 +- Assets/Scripts/TickRotation.cs | 6 +- Assets/Scripts/TickScaling.cs | 6 +- 20 files changed, 190 insertions(+), 132 deletions(-) diff --git a/Assets/Scripts/Environment/SkyUpdatement.cs b/Assets/Scripts/Environment/SkyUpdatement.cs index 4757219..7552b27 100644 --- a/Assets/Scripts/Environment/SkyUpdatement.cs +++ b/Assets/Scripts/Environment/SkyUpdatement.cs @@ -1,5 +1,6 @@ using Convention; using Demo.Game.Attr; +using Demo.Game.ConfigType; using System.Collections; using System.Collections.Generic; using System.IO; @@ -37,6 +38,10 @@ namespace Demo.Game [Scriptable] public class SkyUpdatement : Updatement, IAssetBundleLoader { + protected override ScriptLoadableConfig MakeConfig() + { + return new SkyUpdatementConfig(); + } public static SkyUpdatement Make() { return new GameObject().AddComponent(); diff --git a/Assets/Scripts/Framework/GameContent/GameController.cs b/Assets/Scripts/Framework/GameContent/GameController.cs index a5da736..612dea9 100644 --- a/Assets/Scripts/Framework/GameContent/GameController.cs +++ b/Assets/Scripts/Framework/GameContent/GameController.cs @@ -250,7 +250,7 @@ namespace Demo.Game } yield break; } - yield return Foo(rootGameObject.ParseFromScriptFile2Expr(rootObject));//ConventionUtility.AvoidFakeStop(rootGameObject.ParseFromScriptFile2Expr(rootObject)); + yield return ConventionUtility.AvoidFakeStop(rootGameObject.ParseFromScriptFile2Expr(rootObject));//Foo(rootGameObject.ParseFromScriptFile2Expr(rootObject)); int applyDownCount = 0; void NDFS(ScriptableObject current) { @@ -264,6 +264,7 @@ namespace Demo.Game IEnumerator NDFSFoo() { yield return current.ApplyScript(); + current.ResetEnterGameStatus(); applyDownCount--; } ConventionUtility.StartCoroutine(NDFSFoo()); @@ -291,6 +292,27 @@ namespace Demo.Game using var stream = new FileInfo(projectBinaryFile).OpenRead(); using var reader = new BinaryReader(stream); rootGameObject.Config.Deserialize(reader); + int applyDownCount = 0; + void NDFS(ScriptableObject current) + { + foreach (var child in current.Childs) + { + NDFS(child); + } + if (current.IsScriptApply == false) + { + applyDownCount++; + IEnumerator NDFSFoo() + { + yield return current.ApplyScript(); + current.ResetEnterGameStatus(); + applyDownCount--; + } + ConventionUtility.StartCoroutine(NDFSFoo()); + } + } + NDFS(rootGameObject); + yield return new WaitUntil(() => applyDownCount == 0); } float loadRootObjectEndTime = Time.realtimeSinceStartup; float loadRootObjectElapsed = (loadRootObjectEndTime - loadRootObjectStartTime) * 1000f; diff --git a/Assets/Scripts/Framework/ScriptableObject.cs b/Assets/Scripts/Framework/ScriptableObject.cs index e62660d..4ca81c6 100644 --- a/Assets/Scripts/Framework/ScriptableObject.cs +++ b/Assets/Scripts/Framework/ScriptableObject.cs @@ -38,12 +38,12 @@ namespace Demo.Game public class ScriptLoadableConfig { [Content] public int UID = -1; - [Content] public Vector3 EnterGameLocalPosition = Vector3.zero, EnterGameEulerAngles = Vector3.zero, EnterGameLocalScaling = Vector3.zero; + [Content] public Vector3 EnterGameLocalPosition = Vector3.zero, EnterGameEulerAngles = Vector3.zero, EnterGameLocalScaling = Vector3.one; [Content] public bool IsSetObjectDisable = false; [Content] public int UpdatePerFrame = 1; [Setting] public string ScriptName = ""; - private string[] ChildTypes = null; + private int[] ChildTypes = null; private ScriptLoadableConfig[] childs = null; [Setting] public ScriptableObject target; @@ -57,12 +57,12 @@ namespace Demo.Game IsSetObjectDisable = BinarySerializeUtility.ReadBool(reader); UpdatePerFrame = BinarySerializeUtility.ReadInt(reader); ScriptName = BinarySerializeUtility.ReadString(reader); - ChildTypes = BinarySerializeUtility.DeserializeStringArray(reader); + ChildTypes = BinarySerializeUtility.DeserializeIntArray(reader); int childCount = ChildTypes.Length; childs = new ScriptLoadableConfig[childCount]; for (int i = 0; i < childCount; i++) { - var scriptObject = DefaultInstantiate.GetScriptableObjectInstantiate()[ChildTypes[i]].Invoke(); + var scriptObject = DefaultInstantiate.GetScriptableObjectInstantiate()[DefaultInstantiate.ScriptableObjectID2Typename[ChildTypes[i]]].Invoke(); scriptObject.EnableScript(target); childs[i] = scriptObject.Config; childs[i].Deserialize(reader); @@ -78,7 +78,7 @@ namespace Demo.Game BinarySerializeUtility.WriteInt(writer, UpdatePerFrame); BinarySerializeUtility.WriteString(writer, ScriptName); childs = (from child in target.Childs select child.Config).ToArray(); - ChildTypes = (from child in childs select child.GetType().Name).ToArray(); + ChildTypes = (from child in childs select DefaultInstantiate.ScriptableObjectTypename2ID[child.target.GetType().Name]).ToArray(); BinarySerializeUtility.SerializeArray(writer, ChildTypes); foreach (var child in childs) { @@ -133,7 +133,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetLocalPosition(float x, float y, float z) { - Config.EnterGameLocalPosition = new(x, y, z); + Config.EnterGameLocalPosition = transform.localPosition = new(x, y, z); } /// /// 设置欧拉角 @@ -144,7 +144,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetLocalEulerAngles(float x, float y, float z) { - Config.EnterGameEulerAngles = new(x, y, z); + Config.EnterGameEulerAngles = transform.localEulerAngles = new(x, y, z); } /// /// 设置缩放 @@ -155,7 +155,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetLocalScaling(float x, float y, float z) { - Config.EnterGameLocalScaling = new(x, y, z); + Config.EnterGameLocalScaling = transform.localScale= new(x, y, z); } /// @@ -166,6 +166,7 @@ namespace Demo.Game public void SetObjectDisable() { Config.IsSetObjectDisable = true; + gameObject.SetActive(false); } /// @@ -678,9 +679,12 @@ namespace Demo.Game MyHierarchyItem.Release(); MyHierarchyItem = null; } - this.isEnableScript = false; - this.Parent = null; - this.name = ""; + if (this /*防假空*/) + { + this.isEnableScript = false; + this.Parent = null; + this.name = ""; + } } } diff --git a/Assets/Scripts/Framework/ScriptableObjectInstantiate/DefaultScriptableObjectInstantiate.cs b/Assets/Scripts/Framework/ScriptableObjectInstantiate/DefaultScriptableObjectInstantiate.cs index 8c4ce09..d159f5d 100644 --- a/Assets/Scripts/Framework/ScriptableObjectInstantiate/DefaultScriptableObjectInstantiate.cs +++ b/Assets/Scripts/Framework/ScriptableObjectInstantiate/DefaultScriptableObjectInstantiate.cs @@ -7,6 +7,7 @@ using Dreamteck.Splines; using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Reflection; using UnityEngine; @@ -32,26 +33,33 @@ namespace Demo SharedModule.instance.OpenCustomMenu(item, result.ToArray()); } + static DefaultInstantiate() + { + s_ScriptableObjectInstantiate = new(); + ScriptableObjectTypename2ID = new(); + ScriptableObjectID2Typename = new(); + int cnt = 0; + foreach (var type in Utility.SeekType(x => x.IsSubclassOf(typeof(ScriptableObject)) && x.GetCustomAttribute() != null)) + { + var attr = type.GetCustomAttribute(); + s_ScriptableObjectInstantiate.Add(type.Name, () => (ScriptableObject)ConventionUtility.InvokeMember(type.GetMethod(attr.generaterName), null)); + } + var typelist = s_ScriptableObjectInstantiate.Keys.ToList(); + typelist.Sort(); + foreach (var type in typelist) + { + ScriptableObjectTypename2ID.Add(type, cnt); + ScriptableObjectID2Typename.Add(cnt, type); + cnt++; + } + } + private static Dictionary> s_ScriptableObjectInstantiate; + public readonly static Dictionary ScriptableObjectTypename2ID; + public readonly static Dictionary ScriptableObjectID2Typename; public static Dictionary> GetScriptableObjectInstantiate() { - //return s_ScriptableObjectInstantiate ??= new Dictionary>(GameObjectInstantiate - // .Union(DDTInstantiate) - // .Union(TickUpdatementInstantiate) - // .Union(MaterialUpdatementInstantiate) - // .Union(SplineInstantiate) - // .Union(JudgementInstantiate) - // .Union(SingleVolumeInstantiate)); - if (s_ScriptableObjectInstantiate == null) - { - s_ScriptableObjectInstantiate = new(); - foreach (var type in Utility.SeekType(x => x.IsSubclassOf(typeof(ScriptableObject)) && x.GetCustomAttribute() != null)) - { - var attr = type.GetCustomAttribute(); - s_ScriptableObjectInstantiate.Add(type.Name, () => (ScriptableObject)ConventionUtility.InvokeMember(type.GetMethod(attr.generaterName), null)); - } - } return s_ScriptableObjectInstantiate; } } diff --git a/Assets/Scripts/Framework/SubWorld.cs b/Assets/Scripts/Framework/SubWorld.cs index 9018a74..bd6269c 100644 --- a/Assets/Scripts/Framework/SubWorld.cs +++ b/Assets/Scripts/Framework/SubWorld.cs @@ -32,12 +32,15 @@ namespace Demo.Game [Scriptable] public class SubWorld : ScriptableObject { + protected override ConfigType.ScriptLoadableConfig MakeConfig() + { + return new ConfigType.SubWorldConfig(); + } public static SubWorld Make() { return new GameObject().AddComponent(); } - [Content, SerializeField] private string project; [Content, SerializeField] private GameController SubWorldGameController; protected override IEnumerator DoSomethingDuringApplyScript() @@ -47,7 +50,7 @@ namespace Demo.Game ir.completed += x => { SubWorldGameController = (from controller in FindObjectsByType(FindObjectsSortMode.None) - where controller.RootSourcePath == project + where controller.RootSourcePath == GetConfig().project select controller).First(); ConventionUtility.StartCoroutine(SubWorldGameController.GameInitBySubWorld(GetRoot().InputCatch)); }; @@ -66,7 +69,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void Load(string project) { - this.project = project; + GetConfig().project = project; } } } diff --git a/Assets/Scripts/Framework/Updatement.cs b/Assets/Scripts/Framework/Updatement.cs index 48f77e1..b87f99f 100644 --- a/Assets/Scripts/Framework/Updatement.cs +++ b/Assets/Scripts/Framework/Updatement.cs @@ -1,5 +1,6 @@ using Convention; using Demo.Editor.UI; +using Demo.Game.ConfigType; using System; using System.Collections; using System.Collections.Generic; @@ -115,39 +116,9 @@ namespace Demo.Game public DataType Position = default; public MathExtension.EaseCurveType easeCurveType = MathExtension.EaseCurveType.Linear; } - [Serializable] - public struct UpdatementCompiledEntries: IDisposable - { - public NativeArray TimePoints; - public NativeArray Positions; - public NativeArray EaseCurveTypes; - public readonly int Count; - - public UpdatementCompiledEntries(NativeArray timePoints, - NativeArray positions, - NativeArray easeCurveTypes, - int count) - { - TimePoints = timePoints; - Positions = positions; - EaseCurveTypes = easeCurveTypes; - Count = count; - } - - public void Dispose() - { - if (TimePoints.IsCreated) - TimePoints.Dispose(); - if (Positions.IsCreated) - Positions.Dispose(); - if (EaseCurveTypes.IsCreated) - EaseCurveTypes.Dispose(); - } - } public int Content = 0; private readonly List Entries = new(); - public UpdatementCompiledEntries CompiledEntries; protected abstract void UpdateData(DataType data); protected abstract DataType Lerp(DataType begin, DataType end, float t); @@ -170,18 +141,15 @@ namespace Demo.Game private void BuildupCompiledEntriesAndReleaseEntries() { Entries.Sort((x, y) => x.TimePoint.CompareTo(y.TimePoint)); - CompiledEntries = new( - new NativeArray(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory), - new NativeArray(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory), - new NativeArray(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory), - Entries.Count - ); + GetConfig>().TimePoints = new NativeArray(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); + GetConfig>().Positions = new NativeArray(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); + GetConfig>().EaseCurveTypes = new NativeArray(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); int index = 0; foreach (var item in Entries) { - CompiledEntries.TimePoints[index] = item.TimePoint; - CompiledEntries.Positions[index] = item.Position; - CompiledEntries.EaseCurveTypes[index] = item.easeCurveType; + GetConfig>().TimePoints[index] = item.TimePoint; + GetConfig>().Positions[index] = item.Position; + GetConfig>().EaseCurveTypes[index] = item.easeCurveType; index++; } Entries.Clear(); @@ -190,10 +158,10 @@ namespace Demo.Game private void UpdateEntry(int start, float percent) { int head = start; - int tail = Mathf.Min(start + 1, CompiledEntries.Count - 1); - UpdateData(Lerp(CompiledEntries.Positions[start], - CompiledEntries.Positions[tail], - MathExtension.Evaluate(Mathf.Clamp01(percent), CompiledEntries.EaseCurveTypes[head]))); + int tail = Mathf.Min(start + 1, GetConfig>().TimePoints.Length - 1); + UpdateData(Lerp(GetConfig>().Positions[start], + GetConfig>().Positions[tail], + MathExtension.Evaluate(Mathf.Clamp01(percent), GetConfig>().EaseCurveTypes[head]))); } protected override IEnumerator DoSomethingDuringApplyScript() @@ -209,7 +177,7 @@ namespace Demo.Game public override void ResetEnterGameStatus() { base.ResetEnterGameStatus(); - if (CompiledEntries.Count <= 1) + if (GetConfig>().TimePoints.Length <= 1) return; UpdateEntry(0, 0); } @@ -217,7 +185,9 @@ namespace Demo.Game public override IEnumerator UnloadScript() { Content = 0; - CompiledEntries = default; + GetConfig>().TimePoints.Dispose(); + GetConfig>().Positions.Dispose(); + GetConfig>().EaseCurveTypes.Dispose(); yield return base.UnloadScript(); } @@ -227,12 +197,12 @@ namespace Demo.Game float GetPercentValue() { - if (Content + 1 == CompiledEntries.Count) + if (Content + 1 == GetConfig>().TimePoints.Length) return 1; - return (currentTime - CompiledEntries.TimePoints[Content]) / (CompiledEntries.TimePoints[Content + 1] - CompiledEntries.TimePoints[Content]); + return (currentTime - GetConfig>().TimePoints[Content]) / (GetConfig>().TimePoints[Content + 1] - GetConfig>().TimePoints[Content]); } - if (CompiledEntries.Count <= 1) + if (GetConfig>().TimePoints.Length <= 1) return; switch (tickType) { @@ -240,17 +210,17 @@ namespace Demo.Game case TickType.Start: { Content = 0; - while (Content + 1 < CompiledEntries.Count && CompiledEntries.TimePoints[Content + 1] < currentTime) + while (Content + 1 < GetConfig>().TimePoints.Length && GetConfig>().TimePoints[Content + 1] < currentTime) Content++; UpdateEntry(Content, GetPercentValue()); } break; default: - if (CompiledEntries.TimePoints[0] > currentTime) + if (GetConfig>().TimePoints[0] > currentTime) return; - if (Content + 1 < CompiledEntries.Count && CompiledEntries.TimePoints[Content + 1] < currentTime) + if (Content + 1 < GetConfig>().TimePoints.Length && GetConfig>().TimePoints[Content + 1] < currentTime) Content++; - if (Content + 1 > CompiledEntries.Count) + if (Content + 1 > GetConfig>().TimePoints.Length) return; UpdateEntry(Content, GetPercentValue()); break; @@ -259,21 +229,22 @@ namespace Demo.Game public DataType Evaluate(float time) { - if (CompiledEntries.Count == 0) + if (GetConfig>().TimePoints.Length == 0) return default; - if (CompiledEntries.Count == 1) - return CompiledEntries.Positions[0]; - if (time < CompiledEntries.TimePoints[0]) - return CompiledEntries.Positions[0]; - for (int i = 1; i < CompiledEntries.Count; i++) + if (GetConfig>().TimePoints.Length == 1) + return GetConfig>().Positions[0]; + if (time < GetConfig>().TimePoints[0]) + return GetConfig>().Positions[0]; + for (int i = 1; i < GetConfig>().TimePoints.Length; i++) { - if (CompiledEntries.TimePoints[i - 1] <= time && CompiledEntries.TimePoints[i] > time) + if (GetConfig>().TimePoints[i - 1] <= time && GetConfig>().TimePoints[i] > time) { - return Lerp(CompiledEntries.Positions[i - 1], CompiledEntries.Positions[i], - (time - CompiledEntries.TimePoints[i - 1]) / (CompiledEntries.TimePoints[i] - CompiledEntries.TimePoints[i - 1])); + return Lerp(GetConfig>().Positions[i - 1], GetConfig>().Positions[i], + (time - GetConfig>().TimePoints[i - 1]) / + (GetConfig>().TimePoints[i] - GetConfig>().TimePoints[i - 1])); } } - return CompiledEntries.Positions[^1]; + return GetConfig>().Positions[^1]; } [Content] public GameObject UpdateTarget; @@ -293,15 +264,20 @@ namespace Demo.Game /// 实例在父类中控制 protected override void SetupTimelineItem(TimelineItem item) { - if (CompiledEntries.Count == 0) + if (GetConfig>().TimePoints.Length == 0) return; - item.SetupDuration(new(CompiledEntries.TimePoints[0], CompiledEntries.TimePoints[^1]), GetTimelineItemColor()); + item.SetupDuration(new(GetConfig>().TimePoints[0], GetConfig>().TimePoints[^1]), GetTimelineItemColor()); } private void OnDestroy() { - CompiledEntries.Dispose(); + if (GetConfig>().TimePoints.IsCreated) + GetConfig>().TimePoints.Dispose(); + if (GetConfig>().Positions.IsCreated) + GetConfig>().Positions.Dispose(); + if (GetConfig>().EaseCurveTypes.IsCreated) + GetConfig>().EaseCurveTypes.Dispose(); } } } diff --git a/Assets/Scripts/LookAtAnchor.cs b/Assets/Scripts/LookAtAnchor.cs index ae3539c..1f96e2f 100644 --- a/Assets/Scripts/LookAtAnchor.cs +++ b/Assets/Scripts/LookAtAnchor.cs @@ -1,7 +1,6 @@ using Convention; using Demo.Game.Attr; -using System.Collections; -using System.Collections.Generic; +using Demo.Game.ConfigType; using UnityEngine; namespace Demo.Game @@ -9,6 +8,10 @@ namespace Demo.Game [Scriptable] public class LookAtAnchor : Updatement { + protected override ScriptLoadableConfig MakeConfig() + { + return new UpdatementIntConfig(); + } public static LookAtAnchor Make() { return new GameObject().AddComponent(); diff --git a/Assets/Scripts/MaterialUpdatement.cs b/Assets/Scripts/MaterialUpdatement.cs index ecba5de..8a66994 100644 --- a/Assets/Scripts/MaterialUpdatement.cs +++ b/Assets/Scripts/MaterialUpdatement.cs @@ -1,10 +1,10 @@ using Convention; using Demo.Game.Attr; +using Demo.Game.ConfigType; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; -using UnityEngine.Rendering.LookDev; namespace Demo.Game { @@ -36,6 +36,10 @@ namespace Demo.Game [Scriptable] public class MaterialUpdatement : Updatement, IAssetBundleLoader { + protected override ScriptLoadableConfig MakeConfig() + { + return new MaterialUpdatementConfig(); + } public static MaterialUpdatement Make() { return new GameObject().AddComponent(); diff --git a/Assets/Scripts/MoreMaterialUpdatement/BaseOnMaterialUpdatement.cs b/Assets/Scripts/MoreMaterialUpdatement/BaseOnMaterialUpdatement.cs index 9e21cf8..a939cad 100644 --- a/Assets/Scripts/MoreMaterialUpdatement/BaseOnMaterialUpdatement.cs +++ b/Assets/Scripts/MoreMaterialUpdatement/BaseOnMaterialUpdatement.cs @@ -1,7 +1,8 @@ +using Convention; +using Demo.Game.ConfigType; using System.Collections; using System.Collections.Generic; using System.IO; -using Convention; using UnityEngine; namespace Demo.Game @@ -28,6 +29,10 @@ namespace Demo.Game public abstract class BaseOnMaterialUpdatement : Updatement { + protected override ConfigType.ScriptLoadableConfig MakeConfig() + { + return new BaseOnMaterialUpdatementConfig(); + } public abstract string TargetFieldName { get; } protected override float Lerp(float begin, float end, float t) diff --git a/Assets/Scripts/MoreSpline/PointBaseRenderer/BasicSplineRenderer.cs b/Assets/Scripts/MoreSpline/PointBaseRenderer/BasicSplineRenderer.cs index b00223a..10b7cc2 100644 --- a/Assets/Scripts/MoreSpline/PointBaseRenderer/BasicSplineRenderer.cs +++ b/Assets/Scripts/MoreSpline/PointBaseRenderer/BasicSplineRenderer.cs @@ -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 { 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 positions) + { + NativeArray 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 positions) + { + NativeArray 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, IAssetBundleLoader, IDependOnSplineCore { + protected override ConfigType.ScriptLoadableConfig MakeConfig() + { + return new BasicSplineRendererConfig(); + } /// /// 加载并绑定到新样条线 /// diff --git a/Assets/Scripts/MoreSpline/PointBaseRenderer/SplineTubeRenderer.cs b/Assets/Scripts/MoreSpline/PointBaseRenderer/SplineTubeRenderer.cs index c4b81ca..987df45 100644 --- a/Assets/Scripts/MoreSpline/PointBaseRenderer/SplineTubeRenderer.cs +++ b/Assets/Scripts/MoreSpline/PointBaseRenderer/SplineTubeRenderer.cs @@ -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 { + protected override ScriptLoadableConfig MakeConfig() + { + return new SplineTubeRendererConfig(); + } public static SplineTubeRenderer Make() { return new GameObject().AddComponent(); diff --git a/Assets/Scripts/MoreSpline/SplineCore.cs b/Assets/Scripts/MoreSpline/SplineCore.cs index 0eca3de..5a27f29 100644 --- a/Assets/Scripts/MoreSpline/SplineCore.cs +++ b/Assets/Scripts/MoreSpline/SplineCore.cs @@ -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(); - // return m_MySplineComputer; - // } - //} /// /// 需要在子都添加后再应用脚本才能使得节点生效 diff --git a/Assets/Scripts/MoreSpline/SplineNode.cs b/Assets/Scripts/MoreSpline/SplineNode.cs index ba993c1..c490dcb 100644 --- a/Assets/Scripts/MoreSpline/SplineNode.cs +++ b/Assets/Scripts/MoreSpline/SplineNode.cs @@ -75,6 +75,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetNodeSize(float size) { + SetLocalScaling(size, size, size); NodeSize = size; } diff --git a/Assets/Scripts/MoreSpline/Updatement/BasicSplineJustFollow.cs b/Assets/Scripts/MoreSpline/Updatement/BasicSplineJustFollow.cs index 99e4ccb..e1c54fd 100644 --- a/Assets/Scripts/MoreSpline/Updatement/BasicSplineJustFollow.cs +++ b/Assets/Scripts/MoreSpline/Updatement/BasicSplineJustFollow.cs @@ -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, IDependOnSplineCore { + protected override ConfigType.ScriptLoadableConfig MakeConfig() + { + return new BasicSplineJustFollowConfig(); + } /// /// 加载并绑定到新样条线 /// diff --git a/Assets/Scripts/MoreSpline/Updatement/SplineMovement.cs b/Assets/Scripts/MoreSpline/Updatement/SplineMovement.cs index 4650d93..817daa3 100644 --- a/Assets/Scripts/MoreSpline/Updatement/SplineMovement.cs +++ b/Assets/Scripts/MoreSpline/Updatement/SplineMovement.cs @@ -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 diff --git a/Assets/Scripts/MoreSpline/Updatement/SplinePointerObject.cs b/Assets/Scripts/MoreSpline/Updatement/SplinePointerObject.cs index 0988adc..beac89d 100644 --- a/Assets/Scripts/MoreSpline/Updatement/SplinePointerObject.cs +++ b/Assets/Scripts/MoreSpline/Updatement/SplinePointerObject.cs @@ -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 diff --git a/Assets/Scripts/MoreSpline/Updatement/SplineRotation.cs b/Assets/Scripts/MoreSpline/Updatement/SplineRotation.cs index b765a15..2cd1fad 100644 --- a/Assets/Scripts/MoreSpline/Updatement/SplineRotation.cs +++ b/Assets/Scripts/MoreSpline/Updatement/SplineRotation.cs @@ -1,7 +1,4 @@ -using Convention; using Demo.Game.Attr; -using System; -using System.Collections; using UnityEngine; namespace Demo.Game diff --git a/Assets/Scripts/TickMovement.cs b/Assets/Scripts/TickMovement.cs index 414c9bf..75b2482 100644 --- a/Assets/Scripts/TickMovement.cs +++ b/Assets/Scripts/TickMovement.cs @@ -1,9 +1,6 @@ using Convention; -using Convention.WindowsUI.Variant; using Demo.Game.Attr; -using System; -using System.Collections; -using System.Collections.Generic; +using Demo.Game.ConfigType; using UnityEngine; namespace Demo.Game @@ -11,6 +8,10 @@ namespace Demo.Game [Scriptable] public class TickMovement : Updatement { + protected override ScriptLoadableConfig MakeConfig() + { + return new UpdatementVec3Config(); + } public static TickMovement Make() { return new GameObject().AddComponent(); diff --git a/Assets/Scripts/TickRotation.cs b/Assets/Scripts/TickRotation.cs index 71caa28..4ab03b0 100644 --- a/Assets/Scripts/TickRotation.cs +++ b/Assets/Scripts/TickRotation.cs @@ -1,6 +1,6 @@ using Convention; using Demo.Game.Attr; -using System; +using Demo.Game.ConfigType; using UnityEngine; namespace Demo.Game @@ -8,6 +8,10 @@ namespace Demo.Game [Scriptable] public class TickRotation : Updatement { + protected override ScriptLoadableConfig MakeConfig() + { + return new UpdatementVec3Config(); + } public static TickRotation Make() { return new GameObject().AddComponent(); diff --git a/Assets/Scripts/TickScaling.cs b/Assets/Scripts/TickScaling.cs index 683b706..0c772ba 100644 --- a/Assets/Scripts/TickScaling.cs +++ b/Assets/Scripts/TickScaling.cs @@ -1,6 +1,6 @@ using Convention; using Demo.Game.Attr; -using System; +using Demo.Game.ConfigType; using UnityEngine; namespace Demo.Game @@ -8,6 +8,10 @@ namespace Demo.Game [Scriptable] public class TickScaling : Updatement { + protected override ScriptLoadableConfig MakeConfig() + { + return new UpdatementVec3Config(); + } public static TickScaling Make() { return new GameObject().AddComponent();