diff --git a/Assets/Scripts/Framework/EditiorContent/EditorController.cs b/Assets/Scripts/Framework/EditiorContent/EditorController.cs index 15976da..1ac7d4e 100644 --- a/Assets/Scripts/Framework/EditiorContent/EditorController.cs +++ b/Assets/Scripts/Framework/EditiorContent/EditorController.cs @@ -402,6 +402,8 @@ namespace Demo.Editor Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater.GetTypename(typeof(SplineComputer.SampleMode))).Register(); new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(typeof(Spline.Type), null, null, Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater.GetTypename(typeof(Spline.Type))).Register(); + new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(typeof(IEffectHookObject.InteractiveEffectType), null, null, + Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater.GetTypename(typeof(IEffectHookObject.InteractiveEffectType))).Register(); } private void Start() diff --git a/Assets/Scripts/Framework/ScriptableObject.cs b/Assets/Scripts/Framework/ScriptableObject.cs index cc96a7b..3bbb336 100644 --- a/Assets/Scripts/Framework/ScriptableObject.cs +++ b/Assets/Scripts/Framework/ScriptableObject.cs @@ -1,14 +1,14 @@ -using Convention; -using Convention.RScript; -using Convention.WindowsUI.Variant; -using Demo.Game; -using Dreamteck.Splines; using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; +using Convention; +using Convention.RScript; +using Convention.WindowsUI.Variant; +using Demo.Game; +using Dreamteck.Splines; using Unity.VisualScripting; using UnityEngine; @@ -76,6 +76,15 @@ namespace Demo public Spline.Type CatmullRom => Spline.Type.CatmullRom; public Spline.Type Bezier => Spline.Type.Bezier; } + + public class IEffectHookObjectInstance + { + public static IEffectHookObjectInstance instance = new(); + public IEffectHookObject.InteractiveEffectType VisibleDuration => IEffectHookObject.InteractiveEffectType.VisibleDuration; + public IEffectHookObject.InteractiveEffectType InteractiveDuration => IEffectHookObject.InteractiveEffectType.InteractiveDuration; + public IEffectHookObject.InteractiveEffectType InteractableScoreInterval => IEffectHookObject.InteractiveEffectType.InteractableScoreInterval; + public IEffectHookObject.InteractiveEffectType InteractableIntervalThatCanScoreBest => IEffectHookObject.InteractiveEffectType.InteractableIntervalThatCanScoreBest; + } } public partial class ScriptableObject : IScriptableObject @@ -204,7 +213,7 @@ namespace Demo public ScriptableObject Parent; public readonly List Childs = new(); - public readonly List UpdateChilds = new(); + [Content, SerializeField] private List UpdateChilds = new(); /// /// 获取根脚本对象 @@ -490,6 +499,8 @@ namespace Demo new() { data = PrivateType.SplineComputerSampleModeInstance.instance, type = typeof(PrivateType.SplineComputerSampleModeInstance)} }, { $"Spline{nameof(Spline.Type)}", new() { data = PrivateType.SplineTypeInstance.instance, type = typeof(PrivateType.SplineTypeInstance)} }, + { nameof(IEffectHookObject.InteractiveEffectType), + new() { data = PrivateType.IEffectHookObjectInstance.instance, type = typeof(PrivateType.IEffectHookObjectInstance)} } }; foreach (var ir in engine.RunAsync(script, importClass, variables).Yield()) @@ -530,7 +541,7 @@ namespace Demo else { // UpdateTicks - if (UpdatePerFrame > 0) + if (this.IsSelfEnableUpdate && UpdatePerFrame > 0) { if (ScriptUpdateCounter % UpdatePerFrame == 0) UpdateTicks(currentTime, deltaTime, tickType); @@ -751,7 +762,6 @@ namespace Demo public static IEnumerator LoadAssetBundle(this IAssetBundleLoader self, string ab, Action callback) { - Debug.Log($"{self.SharedInterfaceScriptObject.ScriptName}.{nameof(LoadAssetBundle)}({ab})", self.SharedInterfaceScriptObject); yield return LoadAssetBundleAsync(ab, callback); } diff --git a/Assets/Scripts/Framework/Updatement.cs b/Assets/Scripts/Framework/Updatement.cs index 1474bc2..5923f79 100644 --- a/Assets/Scripts/Framework/Updatement.cs +++ b/Assets/Scripts/Framework/Updatement.cs @@ -69,41 +69,38 @@ namespace Demo.Game protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType) { - using (Profiler.BeginZone($"Updatement<{typeof(DataType).Name}>.UpdateTicks")) + base.UpdateTicks(currentTime, deltaTime, tickType); + + float GetPercentValue() { - base.UpdateTicks(currentTime, deltaTime, tickType); + return (currentTime - Entries[Content].TimePoint) / (Entries[Content + 1].TimePoint - Entries[Content].TimePoint); + } - float GetPercentValue() - { - return (currentTime - Entries[Content].TimePoint) / (Entries[Content + 1].TimePoint - Entries[Content].TimePoint); - } - - if (Entries.Count <= 1) - return; - switch (tickType) - { - case TickType.Reset: - case TickType.Start: - { - Content = 0; - while (Content + 1 < Entries.Count && Entries[Content + 1].TimePoint < currentTime) - Content++; - UpdateEntry(Content, GetPercentValue()); - } - break; - default: - if (Entries[0].TimePoint > currentTime) - return; - if (Content + 1 >= Entries.Count) - return; - if (Entries[Content + 1].TimePoint < currentTime) + if (Entries.Count <= 1) + return; + switch (tickType) + { + case TickType.Reset: + case TickType.Start: + { + Content = 0; + while (Content + 1 < Entries.Count && Entries[Content + 1].TimePoint < currentTime) Content++; - if (Content + 1 >= Entries.Count) - UpdateEntry(Content, 1); - else - UpdateEntry(Content, GetPercentValue()); - break; - } + UpdateEntry(Content, GetPercentValue()); + } + break; + default: + if (Entries[0].TimePoint > currentTime) + return; + if (Content + 1 >= Entries.Count) + return; + if (Entries[Content + 1].TimePoint < currentTime) + Content++; + if (Content + 1 >= Entries.Count) + UpdateEntry(Content, 1); + else + UpdateEntry(Content, GetPercentValue()); + break; } } diff --git a/Assets/Scripts/Interaction/Effect/ParticleEffect.cs b/Assets/Scripts/Interaction/Effect/ParticleEffect.cs index 584f9a7..219f711 100644 --- a/Assets/Scripts/Interaction/Effect/ParticleEffect.cs +++ b/Assets/Scripts/Interaction/Effect/ParticleEffect.cs @@ -1,5 +1,7 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; +using Convention; using UnityEngine; namespace Demo.Game @@ -11,9 +13,17 @@ namespace Demo.Game return new GameObject().AddComponent(); } + private Dictionary AssetBundleLoaders = new(); private readonly List AssetBundles = new(); private readonly List Prefabs = new(); + protected override IEnumerator DoSomethingDuringApplyScript() + { + yield return base.DoSomethingDuringApplyScript(); + while (AssetBundleLoaders.Any(x => x.Value == false)) + yield return null; + } + public override IEnumerator UnloadScript() { yield return base.UnloadScript(); @@ -29,9 +39,10 @@ namespace Demo.Game /// /// [Convention.RScript.Variable.Attr.Method] - public IEnumerator Load(string ab, string prefab) + public void Load(string ab, string prefab) { - yield return this.LoadAssetBundle(ab, x => + AssetBundleLoaders.TryAdd(ab, false); + ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x => { GameObject sub = Instantiate(x.LoadAsset(prefab)); sub.SetActive(false); @@ -39,7 +50,8 @@ namespace Demo.Game sub.transform.SetParent(transform); sub.transform.localPosition = Vector3.zero; AssetBundles.Add(ab); - }); + AssetBundleLoaders[ab] = true; + })); } public override void OnInit() diff --git a/Assets/Scripts/Interaction/IEffectHookObject.cs b/Assets/Scripts/Interaction/IEffectHookObject.cs index ca28345..39ced6e 100644 --- a/Assets/Scripts/Interaction/IEffectHookObject.cs +++ b/Assets/Scripts/Interaction/IEffectHookObject.cs @@ -116,9 +116,9 @@ namespace Demo.Game /// /// [Convention.RScript.Variable.Attr.Method] - public void Bind(string path) + public void Bind(IInteraction target) { - MyInteractionModule = FindWithPath(path) as IInteraction; + MyInteractionModule = target; } ///