- Home /
GUI.BeginGroup() and GUI.matrix problem
I'm trying to use GUI.BeginGroup() to clip an area of the GUI where the inner elements can be rotated or scaled. For doing that I change the GUI.matrix. But when I do that the clipping doesn't work.
Anyone knows a way to avoid this problem without removing the use of GUI.matrix?
The code that make the problems:
public void OnGUI()
{
UnityEngine.GUI.BeginGroup(new UnityEngine.Rect(100, 100, 100, 20));
GUI.matrix = Matrix4x4.identity;
for (int i = 0; i < 20; i++)
{
GUI.matrix = Matrix4x4.identity * Matrix4x4.TRS(new Vector3(45 * i, 0, 0), Quaternion.identity, Vector3.one);
UnityEngine.GUI.DrawTexture(new Rect(0, 0, 42, 42), (Texture2D)Resources.Load("some_texture_here"));
}
UnityEngine.GUI.EndGroup();
}
Answer by Bunny83 · Jul 13, 2011 at 01:38 PM
No, it isn't possible since the matrix transformations are applied after the clipping. GUI.matrix isn't really useful in most cases. I'm not sure if you can replace the default shader that renders the GUI layer but if it's possible that would be a way to implement your own clipping.
Your answer
Follow this Question
Related Questions
GUI.Matrix Problems 0 Answers
Problem with resolution independent game interface 1 Answer
Rotate GUI Button 1 Answer
Editor Scrollview clipping Issue 0 Answers