Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug EditorGUI.DrawPreviewTexture in scrollview not working correctly

Discussion in 'Editor & General Support' started by arkano22, Nov 22, 2022.

  1. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,344
    EditorGUI.DrawPreviewTexture isn't correctly clipped by scrollviews (Unity 2021.3.3f1)



    All other UI elements in the EditorGUI and GUI namespaces are. Am I missing something? this looks like a bug to me...
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,344
    For anyone stumbling upon this, I found the culprit: passing a custom material to
    EditorGUI.DrawPreviewTexture breaks clipping, probably because Unity relies on the shader to perform it. Passing null as the material and allowing Unity to use the built-in blit material allows clipping to work.

    Will try to work out what needs to be done in a custom shader to get this working, but would be nice to mention this pitfall in the documentation.