Time for action – commencing operation pie clock
Let's lay down some code to make those half-circle pieces rotate.
Set up a conditional statement so that we can draw different things before and after the halfway point:
GUI.DrawTexture(clockRect, back, ScaleMode.StretchToFill, true, 0); if(isPastHalfway) { } else { }
If we're not past halfway, rotate the GUI around the
centerPoint
. Draw the right side half-circle piece on top of the rotated GUI. Then, rotate the GUI back to its start position:if(isPastHalfway) { } else { GUIUtility.RotateAroundPivot(-rot, centerPoint); GUI.DrawTexture(clockRect, rightSide, ScaleMode.StretchToFill, true, 0); GUI.matrix = startMatrix; }
Save the script and test your game. You should see the right side half-circle piece rotating around the clock. But, we know it's not really rotating—the entire GUI is rotating, and we're stamping the image on the screen before resetting the rotation:
Draw the left half-circle once the GUI is back into position...