Search Unity

How can i position GUILayout?

Discussion in 'Immediate Mode GUI (IMGUI)' started by mattcscz, Mar 26, 2011.

  1. mattcscz

    mattcscz

    Joined:
    Mar 7, 2010
    Posts:
    411
    hi guys, Im trying to re-position a texture using the code snippet below, but im not sure how to do this. I know you can edit it in the actual GUI skin offset menu, but is it possible doing inside of code? i havn't really learnt how to fully use GUIskin :/ Any ideas would be appreciated, thanks in adv

    Code (csharp):
    1. function OnGUI () {
    2.     GUI.skin.box = Skin;
    3.     GUI.skin.button = Skin;
    4.     if(GUILayout.Button(HelpT)) {
    5.     print("hi");
    6.     }
    7.     //GUI.Box(Rect(200,200,50,50),
    8. }
    I've tried something along the lines of:

    Code (csharp):
    1.     if(GUILayout.Button(Rect(100,100,50,50),(HelpT))) {
    2.     print("hi");
    3.     }
     
    Last edited: Mar 26, 2011
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    use windows or areas to define an "area" or "offset"

    guilayout is per definition not positioned cause it auto calculates that, if you want to explicitely use positions use GUI.Button not GUILayout.Button
     
  3. mattcscz

    mattcscz

    Joined:
    Mar 7, 2010
    Posts:
    411
    Ok thanks a lot for the help, i see if i use GUI.skin.button = Skin; it'll globally change it in unity :D
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Correct if you use that it will change globally

    What you want to do normally is use

    GUI.skin = newSkin;

    at the start and then just use "theNewStyleName" for the style (Button has multiple versions, one allows you to specify the style or its name explicitely, which is then used just for this button)