Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUI.BeginScrollView and GUI.DrawTexture

Discussion in 'Immediate Mode GUI (IMGUI)' started by ratamorph, Apr 17, 2008.

  1. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    I don't know if this is a known issue or a bug, but my calls to GUI.DrawTexture seem to ignore the viewable area of the ScrollView, scrolling works but I can see the whole texture even the parts that should be clipped by the ScrollView...

    If I use a Button or Box with the texture as image it works like it should, but I want to use DrawTexture since I seem to be unable to make the image on buttons or boxes larger than their original sizes.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    How about trying GUI.Label? That will stretch out an image to whatever size you specify.

    --Eric
     
  3. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    mmm I'll have to give that a shot, I guess I never looked into that since text is always the first thing in my mind when I think of a label.
     
  4. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    Still the same as with other GUI controlls, I guess what I'm missing is the stretching that GUI.DrawTexture does. If I do it with other controlls it does make them bigger but the image caps on the original size of the texture, say I have a 512x512 texture and my button is 1024x1024 the image on the button won't be larger than 512x512 because there is no stretching.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Oh yeah, I know what I did. This is what I have for a title screen that stretches to any arbitrary size:

    Code (csharp):
    1. GUI.Label(Rect(0,0,Screen.width,Screen.height), "", titleStyle);
    "titleStyle" is a public variable defined as "var titleStyle : GUIStyle" and in the Inspector for that variable I have the Background of the Normal element be the graphic for the title screen. So that's a bit convoluted. But it does work....

    --Eric
     
  6. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    Ohh I see, makes sence, I'll give that a shot.
     
  7. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    yeah that worked, makes a lot of sence actually. Thanks!

    I'll like to add that it works for all components aswell.
    I also created a private GUIStyle variable and made all changes on the script that way you don't have to expose the variable and make the changes in the inspector.
     
  8. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    GUI.DrawTexture has a bug that it does not get clipped to the enclosing BeginGroup or ScrollView. We'll fix that in next release