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();
}