Draw a circle over time in Unity

Hi everyone.

I’m trying to create a funny sound visualizer in Unity in C#.

I have a question to ask, cause i have no idea how to do this.

I would like to create a circle that will be drawed over time.

basically like this : alt text

How can I do this (I’m very very bad at graphics so with more code and less graphics ^^)?

Thank you !!

EDIT : I didn’t explained very well this is my bad. I would like the item to be in 3D. This because i would like to have my camera move on the scene (which is in 3D) and so see this “donut” under different perspective.

Try this!!

Here are some answered questions about the same thing:

I did it myself to double check the solution and it’s pretty easy:

  • Create a canvas in your scene
  • Create UI Image
  • Change the image type to filled
  • Change fill method to Radial 360
  • Change fill origin to top
  • Set fill amount to 0
  • Uncheck clockwise

I then got the basics of the script from the documentation and made it fit what you needed so just drag this on your image and it should work fine.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class SongTimer : MonoBehaviour 
{
	
	public Image timer;
	public float songTime = 60.0f;
	private bool isSongPlaying = false;

	void Start()
	{
        timer = GetComponent<Image>();
		StartSong (60.0f);
	}

	void StartSong(float songTimeInSeconds)
	{
		songTime = songTimeInSeconds;
		isSongPlaying = true;
	}
	
	
	// Update is called once per frame
	void Update () 
	{
		if (isSongPlaying == true)
		{
			//Increase fill amount over songTime
			timer.fillAmount += 1.0f/songTime * Time.deltaTime;
		}
	}
}

If you want it to be in a 3D world you can change your canvas to be in World Space.