UI换了很多,spine主视觉停用
This commit is contained in:
@@ -124,10 +124,14 @@ public class BgmSpectrumVisualizer : MonoBehaviour
|
||||
|
||||
source.GetSpectrumData(spectrum, 0, fftWindow);
|
||||
|
||||
for (int i = 0; i < bars; i++)
|
||||
int barCount = bars;
|
||||
int barDenominator = Mathf.Max(1, barCount - 1);
|
||||
int spectrumDenominator = Mathf.Max(1, spectrumSize - 1);
|
||||
|
||||
for (int i = 0; i < barCount; i++)
|
||||
{
|
||||
float t = (float)i / (bars - 1);
|
||||
int idx = Mathf.Clamp(Mathf.RoundToInt(Mathf.Lerp(1, spectrumSize - 1, t * t)), 1, spectrumSize - 1);
|
||||
float t = (float)i / barDenominator;
|
||||
int idx = Mathf.Clamp(Mathf.RoundToInt(Mathf.Lerp(1, spectrumDenominator, t * t)), 1, spectrumDenominator);
|
||||
|
||||
float v = Mathf.Max(0f, spectrum[idx] - noiseFloor) * amplitude;
|
||||
float baseHeight = Mathf.Clamp01(v) * maxHeight;
|
||||
@@ -179,12 +183,13 @@ public class BgmSpectrumVisualizer : MonoBehaviour
|
||||
DestroyImmediate(child.gameObject);
|
||||
}
|
||||
|
||||
int barCount = bars;
|
||||
spectrum = new float[Mathf.Max(64, spectrumSize)];
|
||||
barRects = new RectTransform[bars];
|
||||
barHeights = new float[bars];
|
||||
barBasePos = new Vector2[bars];
|
||||
barRects = new RectTransform[barCount];
|
||||
barHeights = new float[barCount];
|
||||
barBasePos = new Vector2[barCount];
|
||||
|
||||
for (int i = 0; i < bars; i++)
|
||||
for (int i = 0; i < barCount; i++)
|
||||
{
|
||||
var bar = Instantiate(barPrefab, transform);
|
||||
bar.gameObject.SetActive(true);
|
||||
|
||||
Reference in New Issue
Block a user