Search Unity

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

Can we Position a GUILayout

Discussion in 'Immediate Mode GUI (IMGUI)' started by sushanta1991, Jan 12, 2012.

  1. sushanta1991

    sushanta1991

    Joined:
    Apr 3, 2011
    Posts:
    305
    Hi guys I am learning GUI these days and stick to a problem, i cant change the position of GUILayout so is there any way to change there positions?
    I see unity Documentation but nothing is given to set there position, only given things are :
    GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Not sure,
    I am thinking perhaps the GUILayout by default is at 0, 0, but that the elements with in it, say button x, can be adjusted.

    :.?
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use GUILayout.BeginArea/EndArea.

    --Eric
     
  4. sushanta1991

    sushanta1991

    Joined:
    Apr 3, 2011
    Posts:
    305
    Ha Ha thanks for the reply guys And Mr Eric5h5 that's what i am looking for, and really really thanks for pointing that out. I found this on the Scripting Reference and this works.
    Code (csharp):
    1.  
    2. function OnGUI () {
    3. // Starts an area to draw elements
    4. GUILayout.BeginArea (Rect (10,10,100,100));
    5. GUILayout.Button ("Click me");
    6. GUILayout.Button ("Or me");
    7. GUILayout.EndArea ();
    8. }
    9.  
     
    Last edited: Jan 13, 2012
  5. raghadalem

    raghadalem

    Joined:
    Jan 9, 2023
    Posts:
    1
    What if I would let the user control the position of the GUILayout?! is that possible?!