Fill a Circular Progress Bar Based on Value

alt textHi,

Edit: I need to fill up a circle texture with another texture (apparently a material) based on a value. I have two Texture varaibles, 'rightCircle' and 'backgroundTexture'. I have a material texture 'mat' of which is a transparant/cutout/diffuse shader. alt text public Texture backgroundTexture, rightCircle; public Material mat;

void OnGUI()
{
    if (Event.current.type == EventType.Repaint)
    {
        mat.SetFloat("_Cutoff", Mathf.InverseLerp(0, 48, someScript.growVar);

        Graphics.DrawTexture(new Rect(987, 0, 58, 45), backgroundTexture, mat);
        Graphics.DrawTexture(new Rect(987, 0, 58, 45), rightCircle);
    }
}

EDIT -- The above draws a square (alpha) with the image of a circle in the middle of the square. [o] <-- kind of like that, but with the top and bottom width's drawn in. Each time that someScript.growVar increments, a little portion of the square dissapears...but instead of the square (alpha) being drawn, I need it to be a circle.. :-/

have you tried looking around? maybe this related question might help? http://answers.unity3d.com/questions/7449/creating-a-circular-progressbar-timer the alpha texture idea is i guess what you need too

create a material, set it's shader to transparent cutout and prolly diffuse, for the main texture use a texture use sg. like the one in the above link where white parts represent fully opaque, or as mine alt text

if you go with a textured object, a plane for example use sg. like the following code from Update() prolly

renderer.material.SetFloat("_Cutoff", alphaCutoff);

but I assume you wanna stick to GUI so you could do sg. like this:

void OnGUI () {
    if (Event.current.type == EventType.Repaint) {
        mat.SetFloat("_Cutoff", alphaCutoff);
        Graphics.DrawTexture(screenRect, texture, mat);
    }
}

check out the documentation for Graphics.DrawTexture() - the reason for the event fuss

in both cases the `alphaCutoff` is the float value you'll alter based on your (game)logic

(using the above pic for the alpha texture I have some bugs and artifacts(not the one that it's upside-down))