GUIStyle scripting

Hello,

I recently got really annoyed by my pc errors which mess up my Unity3d scenes.
It’s nothing serious, because all the scripts are ok, but the problem is that I have tons of GUIStyles and if re-add the script, then I’m gonna have to go through all this process off setting up the GUIStyle via inspector (adding textures, setting widths/ heights etc etc.) which is a real pain…

I decided that the best option to avoid this would be to define all those settings inside scripts so they would be default and I wouldn’t need to do anything in inspector after re-adding script, but how do i do that?

I tried doing something like this:

to define default fixedWidth for that gui style, but it didn’t work. No errors but just didn’t work.

How do you do it? How do you change stuff of guistyle inside script?

thank’s.

wow… anyone?

I use c# and I put all the Variables Initialization inside this 2 functions .
void Start()
{
}
void Awake()
{
}

Relax, you posted on a Sunday, it’s common for folks to take a day or two off over the weekend. :slight_smile:

As to your problem, you declared a variable that’s of type GUIStyle, but you didn’t actually initialize it.

var skinas : GUIStyle = new GUIStyle();
skinas.fixedWidth = 100;

If you did the above (please post all code when asking for help if you did) are you sure that you’ve applied your GUIStyle to your UI elements properly? Can you share a complete example script where you create and apply a style to a GUI element?