public void GenerateWaveformImage(AudioClip clip) { Texture2D texture = mm.PaintWaveformSpectrum(clip, sat, width, height, waveformColor, bgColor); img = gameObject.GetComponent <Image>(); img.overrideSprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0.5f, 0.5f)); }