2019-07-06 22:17:26 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2019-09-28 18:17:39 +00:00
|
|
|
|
namespace cylvester
|
2019-07-06 22:17:26 +00:00
|
|
|
|
{
|
2019-07-07 11:26:16 +00:00
|
|
|
|
public class WaveformVisualizerBehaviour : MonoBehaviour
|
2019-07-06 22:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
#pragma warning disable 649
|
|
|
|
|
[SerializeField] private string pdArrayName;
|
|
|
|
|
[SerializeField] private int pdArraySize;
|
|
|
|
|
[SerializeField] private LineRenderer lineRenderer;
|
|
|
|
|
[SerializeField, Range(0f, 10f)] private float scale = 1f;
|
|
|
|
|
#pragma warning restore 649
|
|
|
|
|
|
2019-09-28 18:17:39 +00:00
|
|
|
|
private PdArray pdArray_;
|
2019-07-06 22:17:26 +00:00
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2019-09-28 18:17:39 +00:00
|
|
|
|
pdArray_ = new PdArray(pdArrayName, pdArraySize);
|
2019-07-06 22:17:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
pdArray_.Update();
|
|
|
|
|
for(var i = 0; i < pdArray_.Data.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var posX = (i / 20f) - 0.5f;
|
|
|
|
|
lineRenderer.SetPosition(i, new Vector3(posX, pdArray_.Data[i] * scale, 0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|