- Home /
GUI clipping with 3D matrix
(Same problem as this question I believe, but that question received no response)
I'm trying to draw a label at a 3D skew. Searching around I found this question where the answers state:
GUI.matrix lets you translate the 2D planes that is GUI in three dimensions.
and
While it cannot be positioned in 3d space, it can be rotated in all 3 dimensions using the GUI.Matrix.
So I figured GUI.matrix
is the solution I need...
However, when I attempt this I get strange clipping issues on the label. I've attempted to change the text clipping on the GUI style but that makes no difference.
This is my code:
#pragma strict
var guiStyle : GUIStyle;
function OnGUI () {
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, 0), Vector3.one);
if (guiStyle)
GUI.Label(Rect (200,200,500,500), "I am a label", guiStyle);
}
Using Quaternion.Euler(0, 0, 0)
as above, produces this correct output:
Using Quaternion.Euler(6, 5, 0)
(for example), produces:
Most other values don't show up at all, or show up with varying degrees of clipping.
What am I doing wrong?
Answer by thtgy2048 · Apr 01, 2013 at 05:49 PM
I have some answer, but not a solution after some experimentation. Basically I wanted the same effect that used in the GUI for Crysis 3, where it rotates on the Y axis based on the mouse position. So rotating on the Y and X Axis in Unity creates clipping effects very quickly. After playing around with the translation also, it appears that Unity clips the Z plane for values less than 1 and greater than 100. Unity is counting pixels as units in the z plane, so if you have a GUI element that is 400 pixels wide, its starts to clip very quickly as it is rotated. Does anyone have a way of changing the clipping of the GUI in the z plane, or performing the rotation, then scaling the result?
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Setting Scroll View Width GUILayout 1 Answer
Advanced Orbit Camera Around Target 1 Answer
Deduct health on collision 2 Answers
GUI Text Enter Name 3 Answers