Search Unity

selectionGrid in a scrollView Bug?

Discussion in 'Immediate Mode GUI (IMGUI)' started by Decoder46, Jul 17, 2016.

  1. Decoder46

    Decoder46

    Joined:
    Jun 12, 2015
    Posts:
    20
    Hi all, I am trying to put a selectiongrid in a scroll view.
    here is what I got:
    Code (CSharp):
    1. Vector2 v = Vector2.zero;
    2. void OnGUI()
    3. {
    4. Rect rec = new Rect(Screen.width - 200, 0, 200, Screen.height / 2);
    5. v = GUI.BeginScrollView(rec, v, new Rect(rec.x, rec.y, rec.width - 20, rec.height * towersImage.Length / 2));
    6. currentTowerSelected = GUI.SelectionGrid(new Rect(rec.x, rec.y, rec.width - 20, rec.height  * towersImage.Length / 2), currentTowerSelected, towersImage, 1);
    7. GUI.EndScrollView();
    8. if (GUI.tooltip != "")
    9.  {
    10.     GUI.Box(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 100, 60), GUI.tooltip);
    11.  }
    12. }
    Now, it's working just fine, but I can see the tooltip outside the scroll view, it's like the selectionGrid is
    long. I cant click it but I can make it an "Hover button" and i see the tooltip. An image is attached:
    GUI BUG.png
     
  2. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    Sorry I can't help. But looking to your screenshot I'm thinking, is better if you jump to the new Unity UI.
    Probably you know this : Is simpler and nicer.
     
  3. Decoder46

    Decoder46

    Joined:
    Jun 12, 2015
    Posts:
    20
    You mean GUILayout? Can I choose on which side on the screen to put the grid? Sorry, I am not near my computer.

    Thanks for your help.
     
  4. Decoder46

    Decoder46

    Joined:
    Jun 12, 2015
    Posts:
    20
    Tried to use the GUILayout, which is nice. I got this:
    Code (CSharp):
    1.  Rect rec = new Rect(Screen.width - 125, 0, 125, Screen.height/2);
    2.         GUILayout.BeginArea(rec);
    3.         v = GUILayout.BeginScrollView(v);
    4.         currentTowerSelected = GUILayout.SelectionGrid(currentTowerSelected, towersImage, 1, GUILayout.MaxWidth(100));
    5.         GUILayout.EndScrollView();
    6.         GUILayout.EndArea();
    I can still see the tooltip outside the area. Is it a bug?
     
  5. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    I'm not able at the moment to help you with the old GUI layout
    In Unity there are different user interfaces.
    The UI system is the latest, is simple, powerful and more advance.
    First follow all this tutorials so that you can have an idea.
    http://unity3d.com/learn/tutorials/topics/user-interface-ui

    The GUI layout system is more difficult than the new UI system.
     
    Decoder46 likes this.
  6. Decoder46

    Decoder46

    Joined:
    Jun 12, 2015
    Posts:
    20
    So using the UI with grid can be very frustrating, there is no tooltip, the rect transfrom is very hard to control, you cant just tell him to be in an specific x and y. It's like he has it's own life lol. But i did got around it eventually and i will use it. Thanks for your help.