@@ -36,7 +36,16 @@ namespace Ichni.Editor
|
||||
|
||||
private string BeatText;
|
||||
private string TimeText;
|
||||
private AudioMelSpectrogram _audioMelSpectrogram = new();
|
||||
|
||||
/// <summary>Mel 频谱图渲染目标 RawImage。请在 Inspector 中指定 Timeline 下的 RawImage 子对象。</summary>
|
||||
public RawImage spectrogramTarget;
|
||||
|
||||
/// <summary>可选的频谱图颜色渐变。为 null 时使用 AudioMelSpectrogram 内置默认渐变。</summary>
|
||||
public Gradient spectrogramGradient;
|
||||
|
||||
/// <summary>频谱图纹理分辨率缩放。0.5 = 半分辨率。</summary>
|
||||
[Range(0.1f, 1f)] public float spectrogramResolutionScale = 0.5f;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
@@ -50,6 +59,14 @@ namespace Ichni.Editor
|
||||
UpdateTime();
|
||||
});
|
||||
|
||||
// ── 初始化 Mel 频谱图 ──
|
||||
if (_audioMelSpectrogram != null)
|
||||
{
|
||||
_audioMelSpectrogram.targetImage = spectrogramTarget;
|
||||
_audioMelSpectrogram.resolutionScale = spectrogramResolutionScale;
|
||||
if (spectrogramGradient != null)
|
||||
_audioMelSpectrogram.colorGradient = spectrogramGradient;
|
||||
}
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
@@ -65,7 +82,16 @@ namespace Ichni.Editor
|
||||
DetectPointer();
|
||||
}
|
||||
|
||||
|
||||
// ── Mel 频谱图每帧刷新 ──
|
||||
if (_audioMelSpectrogram != null && musicPlayer != null && musicPlayer.audioSource != null && timePointerModule != null)
|
||||
{
|
||||
float visibleWidth = spectrogramTarget != null
|
||||
? spectrogramTarget.rectTransform.rect.width
|
||||
: GetComponent<RectTransform>().rect.width;
|
||||
float visTimeRange = Mathf.Max(1f, visibleWidth / timePointerModule.timePointerInterval * timePerBeat);
|
||||
_audioMelSpectrogram.UpdateView(musicPlayer.audioSource,
|
||||
songTime, songTime + visTimeRange);
|
||||
}
|
||||
}
|
||||
private void DetectSetRange()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user