customStyles

So, the documentation is really lacking on it’s information on how to implement customStyles.

Some background on what I’m doing : I made a new skin. Made some stuff in the skin, such as a custom button and label. But I need more than one type of button. So, I’m assuming customStyles allows you to do this. If not, please correct me – I’m clueless with some of Unity’s advanced GUI features.

In Custom Styles, I have defined a new type of button. How do I access that through scripting?

This is what I have right now :

GUI.skin.customStyles = new GUIStyle[1];
GUIStyle[1].attackbutton(menuButtonSize, "");

I’m completely guessing on what to do here – the documentation isn’t helping at all. Any insight would be great :smile:

I don’t think you want to do this. Just looking at it, it looks like it will wipe out whatever custom styles you have defined.

You want to define them as you already have, and can use the custom style through something like this:

var myStyle = GUI.skin.FindStyle( "StyleName" );
GUI.Button( position, content, myStyle );

You can use GUISkin.FindStyle() or GUISkin.GetStyle() depending on whether you want it to just fail silently if the named style isn’t defined.

As you can see in the following snapshot, I’ve defined a Custom Style named Attribute Down Button:

I reference that using GUI.skin.Find() as described above.

.

.

Thank you for such a detailed response! That was very helpful. :smile: