Merge branch 'main' of https://git.hoshino.fan/Soullies/ichni_Creator_Studio
Signed-off-by: TRADER_FOER <lhf190@outlook.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -32,6 +33,17 @@ namespace Ichni.RhythmGame
|
||||
substantialObject.FirstSetUpObject(isFirstGenerated);
|
||||
substantialObject.SetEditorSubmodules();
|
||||
if (isFirstGenerated) substantialObject.AfterInitialize();
|
||||
|
||||
// 在 NoteVisual 的 AfterInitialize + Recover 全部完成后,
|
||||
// 立即强制父 Note 执行 ManualUpdate,让效果状态机根据当前 songTime
|
||||
// 将 noteMain 驱动至正确的可见状态,而非等待下一帧 NoteManager.ManualTick。
|
||||
if (isFirstGenerated && substantialObject is NoteVisualBase noteVisual && noteVisual.note != null)
|
||||
{
|
||||
NoteBase note = noteVisual.note;
|
||||
note.gameObject.SetActive(true);
|
||||
note.ManualUpdate(EditorManager.instance.songInformation.songTime);
|
||||
}
|
||||
|
||||
return substantialObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,23 @@ namespace Ichni.RhythmGame
|
||||
#endregion
|
||||
|
||||
#region [特殊逻辑接口预留] Specific Manager Callbacks
|
||||
/// <summary>
|
||||
/// 当 NoteVisual 被动态挂载或替换后,重新缓存效果列表并刷新 NoteScheduler 注册。
|
||||
/// 解决手动添加 NoteVisual 后,父 Note 的 generateEffects 等缓存仍为 null 导致特效无法驱动的问题。
|
||||
/// </summary>
|
||||
public void RefreshNoteVisualCaches()
|
||||
{
|
||||
generateEffects = GetEffectListSafe("Generate");
|
||||
generalJudgeEffects = GetEffectListSafe("GeneralJudge");
|
||||
perfectEffects = GetEffectListSafe("Perfect");
|
||||
goodEffects = GetEffectListSafe("Good");
|
||||
badEffects = GetEffectListSafe("Bad");
|
||||
missEffects = GetEffectListSafe("Miss");
|
||||
afterJudgeEffects = GetEffectListSafe("AfterJudge");
|
||||
|
||||
AddinNoteManager(false);
|
||||
}
|
||||
|
||||
public void AddinNoteManager(bool isNewOne = true)
|
||||
{
|
||||
if (generateEffects != null)
|
||||
@@ -243,15 +260,24 @@ namespace Ichni.RhythmGame
|
||||
finishTime = Mathf.Max(finishTime, finishEffects[i].effectTime);
|
||||
}
|
||||
|
||||
float activationTime = exactJudgeTime - beyondTime - 0.1f;
|
||||
float endTime = (this is Hold hold ? hold.holdEndTime : exactJudgeTime) + finishTime + 0.1f;
|
||||
|
||||
if (exactJudgeTime - beyondTime - 0.5f > -EditorManager.instance.songInformation.delay)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
var noteScheduler = CoreServices.UpdateScheduler.NoteScheduler;
|
||||
if (isNewOne)
|
||||
noteScheduler.RegisterNote(this, exactJudgeTime - beyondTime - 0.1f, (this is Hold hold ? hold.holdEndTime : exactJudgeTime) + finishTime + 0.1f);
|
||||
noteScheduler.RegisterNote(this, activationTime, endTime);
|
||||
else
|
||||
noteScheduler.ChangeNoteInfo(this, exactJudgeTime - beyondTime - 0.1f, (this is Hold hold ? hold.holdEndTime : exactJudgeTime) + finishTime + 0.1f);
|
||||
noteScheduler.ChangeNoteInfo(this, activationTime, endTime);
|
||||
}
|
||||
else if (!isNewOne)
|
||||
{
|
||||
// 条件不满足(早期 Note)时仍须更新 NoteManager 的时间窗口,
|
||||
// 否则 beyondTime 变化后窗口不一致,ManualTick 会错误地隐藏 Note。
|
||||
var noteScheduler = CoreServices.UpdateScheduler.NoteScheduler;
|
||||
noteScheduler.ChangeNoteInfo(this, activationTime, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,20 @@ namespace Ichni.RhythmGame
|
||||
base.SetDefaultSubmodules();
|
||||
effectSubmodule = new EffectSubmodule(this, EffectSubmodule.EffectSubmodulePreset.Note);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NoteVisual 初始化完毕后,通知父 Note 重新缓存效果列表。
|
||||
/// 解决手动生成 NoteVisual 时,父 Note 的 generateEffects 等缓存为 null 导致特效不被驱动的问题。
|
||||
/// </summary>
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
base.AfterInitialize();
|
||||
|
||||
if (note != null)
|
||||
{
|
||||
note.RefreshNoteVisualCaches();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region [视觉行为] Visual Behaviors
|
||||
@@ -56,6 +70,18 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
base.OnDelete();
|
||||
|
||||
// 清除父 Note 对已删除 NoteVisual 的引用,防止悬空引用和 NullReferenceException
|
||||
if (note != null)
|
||||
{
|
||||
note.noteVisual = null;
|
||||
note.RefreshNoteVisualCaches();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,8 @@ namespace Ichni.RhythmGame
|
||||
this.trackDisplay = UnityEngine.Object.Instantiate(EditorManager.instance.basePrefabs.trackDisplay, track.transform).GetComponent<SplineRenderer>();
|
||||
this.trackDisplay.spline = path;
|
||||
this.trackDisplay.size = 0.1f;
|
||||
// 与 TrackRendererSubmodule 保持一致:LateUpdate 模式消除一帧延迟
|
||||
this.trackDisplay.updateMethod = SplineUser.UpdateMethod.LateUpdate;
|
||||
|
||||
this.SetDisplay(isShowingDisplay);
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ namespace Ichni.RhythmGame
|
||||
this.splineRenderer.doubleSided = true;
|
||||
this.splineRenderer.clipFrom = 0;
|
||||
this.splineRenderer.clipTo = 1;
|
||||
this.splineRenderer.updateMethod = SplineUser.UpdateMethod.Update;
|
||||
// LateUpdate 模式保证 MeshGenerator 在 SplineComputer.Update() 重采样之后才重建网格,
|
||||
// 消除 Update 模式下因 MonoBehaviour 执行顺序不确定导致的一帧延迟。
|
||||
this.splineRenderer.updateMethod = SplineUser.UpdateMethod.LateUpdate;
|
||||
this.meshRenderer.material = renderMaterial;
|
||||
this.splineRenderer.color = Color.white;
|
||||
this.uvRotation = 0f;
|
||||
|
||||
@@ -24,7 +24,9 @@ namespace Ichni.RhythmGame
|
||||
this.pathGenerator.doubleSided = true;
|
||||
this.pathGenerator.clipFrom = 0;
|
||||
this.pathGenerator.clipTo = 1;
|
||||
this.pathGenerator.updateMethod = SplineUser.UpdateMethod.Update;
|
||||
// LateUpdate 模式保证 MeshGenerator 在 SplineComputer.Update() 重采样之后才重建网格,
|
||||
// 消除 Update 模式下因 MonoBehaviour 执行顺序不确定导致的一帧延迟。
|
||||
this.pathGenerator.updateMethod = SplineUser.UpdateMethod.LateUpdate;
|
||||
this.meshRenderer.material = renderMaterial;
|
||||
this.pathGenerator.color = Color.white;
|
||||
this.uvRotation = 90f;
|
||||
|
||||
@@ -24,7 +24,9 @@ namespace Ichni.RhythmGame
|
||||
this.surface.doubleSided = true;
|
||||
this.surface.clipFrom = 0;
|
||||
this.surface.clipTo = 1;
|
||||
this.surface.updateMethod = SplineUser.UpdateMethod.Update;
|
||||
// LateUpdate 模式保证 MeshGenerator 在 SplineComputer.Update() 重采样之后才重建网格,
|
||||
// 消除 Update 模式下因 MonoBehaviour 执行顺序不确定导致的一帧延迟。
|
||||
this.surface.updateMethod = SplineUser.UpdateMethod.LateUpdate;
|
||||
this.meshRenderer.material = renderMaterial;
|
||||
this.surface.color = Color.white;
|
||||
this.surface.uvRotation = 90;
|
||||
|
||||
@@ -27,7 +27,9 @@ namespace Ichni.RhythmGame
|
||||
this.tubeGenerator.doubleSided = true;
|
||||
this.tubeGenerator.clipFrom = 0;
|
||||
this.tubeGenerator.clipTo = 1;
|
||||
this.tubeGenerator.updateMethod = SplineUser.UpdateMethod.Update;
|
||||
// LateUpdate 模式保证 MeshGenerator 在 SplineComputer.Update() 重采样之后才重建网格,
|
||||
// 消除 Update 模式下因 MonoBehaviour 执行顺序不确定导致的一帧延迟。
|
||||
this.tubeGenerator.updateMethod = SplineUser.UpdateMethod.LateUpdate;
|
||||
this.meshRenderer.material = renderMaterial;
|
||||
this.tubeGenerator.color = Color.white;
|
||||
this.tubeGenerator.uvRotation = 90;
|
||||
|
||||
Reference in New Issue
Block a user