Пример #1
0
    private IEnumerator __Start()
    {
        if (!this.configs.aSource)
        {
            this.configs.aSource = this.GetComponent <AudioSource>();
        }
        if (!this.configs.aSource)
        {
            this.configs.aSource = this.GetComponentInChildren <AudioSource>();
        }
        if (!this.configs.aSource)
        {
            this.configs.aSource = GameObject.FindObjectOfType(typeof(AudioSource)) as AudioSource;
        }
        if (!this.configs.aSource)
        {
            Debug.LogError("No Audio Source in the scene found to use for Sound Previews");
            yield break;
        }

        if (this.configs.aSource.clip && this.enabled)
        {
            this.ResetClipView(this.configs.aSource.clip);
        }

        while (true)
        {
            yield return(new WaitForEndOfFrame());

            if (!enabled)
            {
                continue;
            }

            if (this.configs.aSource.isPlaying)
            {
                GLUtils.RenderLines(this.vertices, this.configs.samplesColor);
                GLUtils.RenderVertices(this.viewers, this.configs.markersColor);
                GLUtils.RenderRect(this.GetFFTRect(), this.configs.bgColor, this.configs.borderColor);
            }
            bool stereo = this.verticesRight != null;
            GLUtils.RenderLines(this.verticesLeft, this.configs.samplesColor);
            GLUtils.RenderRect(this.GetLeftRect(stereo), this.configs.bgColor, this.configs.borderColor);
            if (stereo)
            {
                GLUtils.RenderLines(this.verticesRight, this.configs.samplesColor);
                GLUtils.RenderRect(this.GetRightRect(), this.configs.bgColor, this.configs.borderColor);
            }
            GLUtils.RenderLines(this.playingBar, this.configs.markersColor);
        }
    }