- Home /
Question by
TheDarkVoid · Jun 07, 2014 at 09:49 PM ·
rotationguirotatearoundpivotguiutility
Position jitter when using GUIUtility.RotateAroundPivot
I's trying to make a GUI like what I have shown below that uses text that is rotated by 90 degrees.
I'm having a strange problem that seems to only affect the rotated text, it's position jitters as the GUI moves across the screen. Below is the code:
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
pos.y = Screen.height-pos.y;
float hW = hudFrame.width*hudScale;
float hH = hudFrame.height*hudScale;
GUI.BeginGroup(new Rect(pos.x-hW+hudOffset.x, pos.y-(hH/2)+hudOffset.y, hW, hH));
GUI.DrawTexture(new Rect(0, 0, hW, hH), hudFrame);
float pHealth = (_pc.GetHealth()/_pc.maxHealth);
float hBarHeight = (healthBar.height*hudScale)*pHealth;
GUI.DrawTexture(new Rect(432*hudScale, (55*hudScale)+((healthBar.height*hudScale)-hBarHeight), healthBar.width*hudScale,hBarHeight), healthBar);
List<PowerUp> powers = _pc.GetPowers();
float sH = selector.height;
int curSel = _pc.GetSelectedPower();
GUI.DrawTexture(new Rect((95-16) * hudScale, (57 + (38*curSel) + (198 * curSel) - 16)*hudScale, selector.width * hudScale, sH * hudScale), selector);
for(int i = 0; i < powers.Count; i++)
{
GUI.Box(new Rect(95 * hudScale, (57 + (38*i) + (198 * i))*hudScale, 198 * hudScale, 198 * hudScale), powers[i].ToString());
}
GUI.EndGroup();
GUI.skin = skin;
GUI.BeginGroup(new Rect(pos.x+hudOffset.x, pos.y-(hH/2)+hudOffset.y, hH, hW));
GUIUtility.RotateAroundPivot(90, new Vector2(0,0));
GUI.Label(new Rect(67*hudScale, 230*hudScale, 250, 25), powers[curSel].ToString());
GUI.Label(new Rect(771*hudScale, 190*hudScale, 250, 25), (pHealth*100)+"%");
GUI.EndGroup();
Is there a way to correct this issue?
capture.png
(34.2 kB)
Comment