Search Unity

Zoom and pan textures without scrollbars

Discussion in 'Immediate Mode GUI (IMGUI)' started by mkolb, Feb 20, 2008.

  1. mkolb

    mkolb

    Joined:
    Dec 17, 2007
    Posts:
    48
    Hi all,


    is it possible to zoom and pan a texture without ever showing a scrollbar?
    I tried with GUI.BeginScrollView but there is always rendered a scrollbar if the viewArea is greater than the scrollArea.
    However, I want to scroll in script without showing the scrollbars.
    I also tried with a GUI.Box and the ScaleAndCrop ScaleMode. That way I get the zoom to work, but I can't scroll the texture then as I expected like in the shade r properties where you can scroll the texture through its placement structure).

    An example of what I want to achieve is http://www.dataphone.se/~ms/u-com/images/the-sims-aod13-binoc2.jpg

    I want the thing between and below the two eyes, which displays the current compass direction, according to the rotation of the binocular.

    Any ideas on how to achieve this?
    Regards
     
  2. nafonso

    nafonso

    Joined:
    Aug 10, 2006
    Posts:
    377
    Although I haven't tried anything like that, I believe you can achieve it with GUILayout.BeginArea() or GUI.BeginGroup().

    Then, to scroll the texture, use the GUI.matrix to offset the texture.

    Regards,
    Afonso
     
  3. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    @nafoso: GUI.Matrix and GUI.BeginGroup interact in a totally non-intuitive way, so you can't actually do that:

    @mkolb:
    I would try using a GUI.BeginScrollView, but passing in GUIStyle.none for the GUIStyles - then they should be invisible.