Example #1
0
        // Update is called once per frame
        void Update()
        {
            AudioListener.GetOutputData(waveData, 1);
            volume /= 2.0f;
            volume += waveData.Select(x => x * x).Sum() / waveData.Length * 0.5f;
            var y = Mathf.Sin(StateHolder.GetRhythm() / 10.0f * Mathf.PI * 2.0f) * 0.3f;

            for (int i = 0; i < childCount; i++)
            {
                this.transform.GetChild(i).transform.position   = childTransform[i].position + new Vector3(0.0f, y, 0.0f);
                this.transform.GetChild(i).transform.localScale = childTransform[i].scale * (1.0f + volume * 10.0f);
                this.transform.GetChild(i).transform.Rotate(Vector3.up * Time.deltaTime * 30.0f, Space.World);
            }
        }
Example #2
0
        // Update is called once per frame
        void Update()
        {
            AudioListener.GetOutputData(waveData, 1);
            float     delta  = ((float)waveData.Length) / ((float)childCount);
            float     volume = 0f;
            var       y      = Mathf.Sin(StateHolder.GetRhythm() / 10.0f * Mathf.PI * 2.0f) * 0.3f;
            Transform s;

            for (int i = 0; i < childCount; i++)
            {
                childTransform[i].localVolume *= 0.99f;
                childTransform[i].localVolume  = Mathf.Max(waveData[Mathf.FloorToInt(delta * i)], childTransform[i].localVolume);
                s            = this.transform.GetChild(i).transform;
                s.localScale = new Vector3(s.localScale.x, childTransform[i].scaleY * (0.1f + childTransform[i].localVolume), s.localScale.z);
            }
        }