Time for action – positioning and scaling the clock
The pie clock is pretty neat, but it's sadly stuck to the top-left corner of the screen. It would be great if we could make it any size we wanted, and if we could move it anywhere on the screen.
We're not far off from that goal. Follow these steps to get a dynamically positioned and scaled pie clock:
Create these variables at the top of the
OnGUI
function:var pieClockX:int = 100; var pieClockY:int = 50; var pieClockW:int = 64; // clock width var pieClockH:int = 64; // clock height var pieClockHalfW:int = pieClockW * 0.5; // half the clock width var pieClockHalfH:int = pieClockH * 0.5; // half the clock height
In this example,
100
and50
are the X and Y values where I'd like the pie clock to appear on the screen. The clock builds out from its top-left corner.64
and64
are the width and height values I'd like to make the clock—that's exactly half the size of the original clock.Note
Scaling the clock will result in some...