Search Unity

GUI clip issue

Discussion in 'Editor & General Support' started by tiancaiwrk, May 14, 2019.

  1. tiancaiwrk

    tiancaiwrk

    Joined:
    Nov 23, 2017
    Posts:
    35
    hi all
    I have a problem of draw line on EditorWindow
    you can see the pictures shows what the clip issue is, this is draw in an EditorWindow

    I draw a line use GUI.Box(new Rect(...), texture); the arrow is 3 lines combined...
    and rotate it by API : GUIUtility.RotateAroundPivot(angle, pivot);
    But I noticed it was cliped by the EditorWindow's Edge by origin(not rotated) area!!!

    Hope any one can understand what I mean. black line is the origin line, it was cliped by the window,
    and the rotated blue line is also be cliped thought it was rotated.

    is there any way can avoid this clip happen? thx for any replay
     
  2. tiancaiwrk

    tiancaiwrk

    Joined:
    Nov 23, 2017
    Posts:
    35
  3. wechat_os_Qy06wDCHIkyinNVZF11ZU9JYw

    wechat_os_Qy06wDCHIkyinNVZF11ZU9JYw

    Joined:
    Dec 8, 2019
    Posts:
    2
  4. warpfx

    warpfx

    Joined:
    Feb 10, 2020
    Posts:
    14
    I have the same problem under 2021.3.11f1.

    Looks like
    GUIUtility.RotateAroundPivot()
    also rotates clip rect and there's no way to disable/change clipping before drawing the label.

    upload_2022-10-15_0-43-11.png

    Code I've used (in
    void SceneGUI(SceneView obj)
    ):

    Code (CSharp):
    1. var matrix = GUI.matrix;
    2. GUIUtility.RotateAroundPivot(angle, SceneView.currentDrawingSceneView.camera.WorldToScreenPoint(To3D(world, coords)));
    3. Handles.Label(To3D(world, coords), text, new GUIStyle() { alignment = TextAnchor.MiddleCenter, normal = new GUIStyleState() { textColor = color }});
    4. GUI.matrix = matrix;
     
  5. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    @warpfx To prevent the parent scope's clipping rect to affect your drawing, you can call
    GUI.EndClip();
    to forcibly end it, then do your matrix and drawing stuff then call
    GUI.BeginClip(default);
    right after it to ensure the parent scopes'
    GUI.EndClip()
    doesn't send messages to the console. No idea how safe that is though but it works in my case.
     
    warpfx likes this.