void Update() { TryRegister(); Value.Tick(Time.deltaTime); if (SimplePipe != null) { SimplePipe.Invoke(Value.GetValue()); } }
void Update() { var ms = MusicManager.MusicState; _rms.AddValue(ms.RMS); _peak.AddValue(ms.Peak); RMS.value = _rms.GetValue(); Peak.value = _peak.GetValue(); var p = LineRenderer.Points; var pLength = ms.Wavelength.Length / STEP; if (p == null || p.Length != pLength) { p = new Vector2[pLength]; } int pCounter = 0; for (var i = 0; i < ms.Wavelength.Length; i += STEP) { if (pCounter >= p.Length) { break; } var w = ms.Wavelength[i]; if (w < _wMin) { _wMin = w; } if (w > _wMax) { _wMax = w; } var x = i / (float)ms.Wavelength.Length; var y = (w - _wMin) / (_wMax - _wMin); p[pCounter] = new Vector2(x, y); pCounter++; } LineRenderer.Points = p; LineRenderer.SetAllDirty(); }
protected override void TickInternal(float strength) { Debug.Log(System.textureSheetAnimation); System.maxParticles = Rows * Columns; Vector2 realSize = SizeMultiplier * Size; float maxDist = Mathf.Sqrt(Rows * realSize.x * Columns * realSize.y); while (_buffer.Count > BufferSize) { _buffer.RemoveAt(0); } float alpha = Mathf.Clamp01(strength) * AlphaBoost; AlphaValue.AddValue(alpha); alpha = AlphaValue.GetValue(); if (Exponential) { strength *= strength; } strength *= ValueMultiplier; _buffer.Add(strength); if (_particles == null || _particles.Length != System.main.maxParticles) { _particles = new ParticleSystem.Particle[System.main.maxParticles]; } int numParticlesAlive = System.GetParticles(_particles); Vector2 min = transform.position.xz() - realSize / 2; Vector2 step = new Vector3(realSize.x / (Rows - 1), realSize.y / (Columns - 1)); int rowCounter = 0; int columnCounter = 0; for (int i = 0; i < numParticlesAlive; i++) { var newParticlePos = new Vector2(min.x, min.y) + new Vector2(step.x * rowCounter, step.y * columnCounter); float distance = Vector2.Distance(FocalPoint.transform.position.xz(), newParticlePos); distance = Mathf.Clamp01(distance / maxDist); int index = _buffer.Count - 1 - Mathf.FloorToInt(distance * _buffer.Count); index = Mathf.Clamp(index, 0, _buffer.Count - 1); if (index > _buffer.Count) { _particles[i].position = new Vector3(newParticlePos.x, 0, newParticlePos.y); } else { _particles[i].position = new Vector3(newParticlePos.x, _buffer[index], newParticlePos.y); } _particles[i].startColor = TemplateManager.GetTemplateAtTime(distance * ColorFrequency).Color0.WithAlpha(alpha); rowCounter++; if (rowCounter == Rows) { rowCounter = 0; columnCounter++; } } System.SetParticles(_particles, numParticlesAlive); }