Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

About Guistyle

Discussion in 'Immediate Mode GUI (IMGUI)' started by philipzhang, Mar 9, 2010.

  1. philipzhang

    philipzhang

    Joined:
    Feb 20, 2010
    Posts:
    50
    Hi guys
    I found one argument in gui.box and gui.label or gui.something

    What does guistyle really mean and how can i create and define it?

    B.T.W:Is any default guistyle I can try? :)
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    A GUIStyle is a way to supply extra information to the GUI functions to specify how the control should be displayed. You can instantiate them directly in code and set their fields, but the easiest way to use GUIStyles is with a GUISkin. See this manual page for more information on how to use styles and skins.
     
  3. Cyclops

    Cyclops

    Joined:
    Jan 31, 2010
    Posts:
    111
    The GUI Customization Manual page says, "As stated earlier, GUISkins are a collection of GUIStyles. Styles define the appearance of a GUI Control. You do not have to use a Skin if you want to use a Style." And the picture shows a Custom GuiStyle object directly under a GUIScript.

    This, to me, implies that I can create a Style as a separate object, in the Editor. Is that true or not? I don't see the option in Assets->Create, or anywhere else. Or does that mean you can procedurally (only) create a Style?

    John C>
    "For all your days, prepare, and meet them ever alike;
    When you are the anvil, bear - when the hammer, strike."
     
  4. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    There isn't a GUIStyle asset type, so you do indeed need to declare it from a script. Typically, you would make it a public variable so you can set the fields from the inspector.
     
  5. Cyclops

    Cyclops

    Joined:
    Jan 31, 2010
    Posts:
    111
    Thanks, the Manual isn't at all clear on that.

    I understand the concept, but it does warp my mind a bit, using the Editor to change internally-created variables... Definitely blurring the line between programming and point-and-click... :)

    John C>
    "For all your days, prepare, and meet them ever alike;
    When you are the anvil, bear - when the hammer, strike."
     
  6. pienia

    pienia

    Joined:
    Aug 21, 2009
    Posts:
    8
    There isn't GUIStyle asset but there's GUISkin, so you can also add custom style to your custom skin (Custom Styles property in inspector). Then, you can use one style in many objects.