Search Unity

scroll bar and text

Discussion in 'Immediate Mode GUI (IMGUI)' started by lesfundi, Feb 18, 2011.

  1. lesfundi

    lesfundi

    Joined:
    Jan 10, 2009
    Posts:
    628
    is there an easy way or example out there to create a scroll bar and text next to it?

    l.
     
  2. lesfundi

    lesfundi

    Joined:
    Jan 10, 2009
    Posts:
    628
    Code (csharp):
    1. // The position on of the scrolling viewport
    2. var scrollPosition : Vector2 = Vector2.zero;
    3. var stringToEdit : String = "Hello World\nI've got 2 lines...";
    4.  
    5. function OnGUI () {
    6.     // An absolute-positioned example: We make a scrollview that has a really large client
    7.     // rect and put it in a small rect on the screen.
    8.     scrollPosition = GUI.BeginScrollView (Rect (10,300,100,100),
    9.         scrollPosition, Rect (0, 0, 220, 200));
    10.    
    11.     // Make four buttons - one in each corner. The coordinate system is defined
    12.     // by the last parameter to BeginScrollView.
    13.     GUI.Button (Rect (0,0,100,20), "Top-left");
    14.     GUI.Button (Rect (120,0,100,20), "Top-right");
    15.     GUI.Button (Rect (0,180,100,20), "Bottom-left");
    16.     GUI.Button (Rect (120,180,100,20), "Bottom-right");
    17.      stringToEdit = GUI.TextArea (Rect (0, 25, 100, 100), stringToEdit, 200);
    18.    
    19.     // End the scroll view that we began above.
    20.     GUI.EndScrollView ();
    21. }
    22.  
    23.  
    24.