Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to scale the content of ScrollView without affecting the clipping?

Discussion in 'Immediate Mode GUI (IMGUI)' started by Seto, Jun 29, 2017.

  1. Seto

    Seto

    Joined:
    Oct 10, 2010
    Posts:
    243
    https://issuetracker.unity3d.com/is...than-the-view-area-when-using-beginscrollview

    I report this bug. But it says it's by design. Then how can I achieve this? And it actually breaks my editor plugin.
    Previously, I can use the code below to achieve that. But I can't since 2017.1.0b7.

    Code (CSharp):
    1. GUIUtility.ScaleAroundPivot(Vector2.one * scale, Vector2.zero);
    2. position.size /= scale.
    3. GUI.BeginScrollView(position, m_ScrollPosition, viewRect, GUIStyle.None, GUIStyle.None);
     
    Last edited: Jul 3, 2017
  2. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    998
    Hi,

    There was a change in the GUI clipping behavior that made your code work in 2017.1.0b2, but this change was reverted in 2017.1.0b7 because of other regressions that was caused by it.

    This is a limitation of the EditorWindow, which does a BeginGroup() to clip the content of the dock area. There is a workaround though, you can first do a EndGroup() before drawing your scaled content. This will bring you in "unclipped space". After drawing drawing your content, you reset the initial clipping with a BeginGroup().

    You can find a blog post about the technique here:
    http://www.arsentuf.me/2015/01/27/unity-3d-editor-gui-and-scaling-matricies/

    Hope this helps!
     
    mete-berk-2001 likes this.