Author Topic: Assigning string to GUIStyle  (Read 3194 times)

Vesuvian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
Assigning string to GUIStyle
« on: August 20, 2014, 10:32:46 AM »
Hey guys

I was reading through some NGUI code when I hit a bunch of lines that look like:

  1. if (mBlueDot == null) mBlueDot = "sv_label_1";

Where mBlueDot is a GUIStyle.

This is absolutely fascinating to me on a bunch of levels, because I didn't know you could assign strings to GUIStyles, and I don't know what the operation here is actually intending to do.

Can someone please explain this to me?

Thanks,
Ves

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Assigning string to GUIStyle
« Reply #1 on: August 20, 2014, 05:48:41 PM »
Unity has a bunch of built-in GUI styles you can reference by name. That's what I'm doing there. I know there is a style called "sv_label_1", so I'm just choosing to use it.

Here, place this script in the Editor folder then use Window -> ShowEditorStyles.

Vesuvian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
Re: Assigning string to GUIStyle
« Reply #2 on: August 21, 2014, 06:55:37 AM »
Very cool! I can see this window being invaluable.