UnityEditor.AudioClipInspector.CombineWaveForms C# (CSharp) Method

CombineWaveForms() private static method

private static CombineWaveForms ( Texture2D waveForms ) : Texture2D
waveForms UnityEngine.Texture2D
return UnityEngine.Texture2D
        private static Texture2D CombineWaveForms(Texture2D[] waveForms)
        {
            if (waveForms.Length == 1)
            {
                return waveForms[0];
            }
            int width = waveForms[0].width;
            int height = 0;
            foreach (Texture2D textured in waveForms)
            {
                height += textured.height;
            }
            Texture2D textured2 = new Texture2D(width, height, TextureFormat.ARGB32, false);
            int num4 = 0;
            foreach (Texture2D textured3 in waveForms)
            {
                num4 += textured3.height;
                textured2.SetPixels(0, height - num4, width, textured3.height, textured3.GetPixels());
                UnityEngine.Object.DestroyImmediate(textured3);
            }
            textured2.Apply();
            return textured2;
        }

Usage Example

        public override Texture2D RenderStaticPreview(string assetPath, UnityEngine.Object[] subAssets, int width, int height)
        {
            AssetImporter atPath = AssetImporter.GetAtPath(assetPath);
            AudioImporter exists = atPath as AudioImporter;

            if (!exists)
            {
                return(null);
            }
            AudioClip audioClip = this.target as AudioClip;

            Texture2D[] array = new Texture2D[audioClip.channels];
            for (int i = 0; i < audioClip.channels; i++)
            {
                array[i] = AudioUtil.GetWaveForm(audioClip, atPath, i, (float)width, (float)(height / audioClip.channels));
            }
            return(AudioClipInspector.CombineWaveForms(array));
        }