ParticleEffect出现无法加载完成的异常

This commit is contained in:
2025-11-30 17:33:26 +08:00
parent 0b80d0a775
commit 430209c948
5 changed files with 66 additions and 45 deletions

View File

@@ -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()

View File

@@ -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<ScriptableObject> Childs = new();
public readonly List<ScriptableObject> UpdateChilds = new();
[Content, SerializeField] private List<ScriptableObject> UpdateChilds = new();
/// <summary>
/// 获取根脚本对象
@@ -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<AssetBundle> callback)
{
Debug.Log($"{self.SharedInterfaceScriptObject.ScriptName}.{nameof(LoadAssetBundle)}({ab})", self.SharedInterfaceScriptObject);
yield return LoadAssetBundleAsync(ab, callback);
}

View File

@@ -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;
}
}

View File

@@ -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<ParticleEffect>();
}
private Dictionary<string,bool> AssetBundleLoaders = new();
private readonly List<string> AssetBundles = new();
private readonly List<GameObject> 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
/// <param name="ab"></param>
/// <param name="prefab"></param>
[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<GameObject>(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()

View File

@@ -116,9 +116,9 @@ namespace Demo.Game
/// </summary>
/// <param name="path"></param>
[Convention.RScript.Variable.Attr.Method]
public void Bind(string path)
public void Bind(IInteraction target)
{
MyInteractionModule = FindWithPath(path) as IInteraction;
MyInteractionModule = target;
}
/// <summary>