- Home /
How to Edit a Copy of the Default Skin
For cases where I want to use most of the settings from Unity's default skin, but just tweak a thing or two and only for one element at a time (say, a button), I'm attempting to create a copy of a style from the default skin and then just edit that copy. Since the docs say that the constructor for GUIStyle can take as an argument another style which it will construct a new copy of, I tried using that:
var myStyle:GUIStyle=GUIStyle(GUI.skin.button);
However, myStyle
does not seem to have been filled out; it's all blank as if I hadn't called the constructor. I've further tried assigning it directly:
var myStyle:GUIStyle=GUI.skin.button;
This now seems to make myStyle
into a pointer of sorts, so that any changes I make to myStyle are actually applied directly to GUI.skin.button and affect all other buttons in the game. (Not only that, it seems to leave the default skin this way permanently, so that I can't seem to retrieve the factory-settings even by calling "GUI.skin=null;
".
So how might one make a small tweak to the default GUI.skin, for only one particular GUIContent?
Answer by syclamoth · Oct 16, 2011 at 03:10 AM
Try downloading this- it gives you all the assets in the default skin, which allows you to swap and change the ones you need with ease! Then, just use that skin for everything instead of the default one.
Also, it's funny that using the GUIStyle constructor in the way you mentioned there didn't work, since the documentation claims it should work the way you think it should. Can someone confirm how the usage of the 'new' keyword in javascript relates to this kind of thing? I'm a C# person normally, so I'm not too familiar with the ins and outs of javascript programming.
I've actually downloaded that before. The "BuiltinSkin.unitypackage" file seems to contain only 2 files, the first being a font ("Arial Rounded Bold.ttf") which yields the error:
The font Assets/Builtin skin/Sources/Arial Rounded Bold.ttf could not be imported because the file is empty. If the file comes from $$anonymous$$ac OS X, it might be that all data is in 'resource fork'. Change the file there to have data in the file.
The other file is the script "ShowSkin.cs", which merely displays for you the various styles of your current skin. It doesn't seem to reset GUI.skin for you, or contain any actual style information.
um, that's weird. That's not what I remember being in the package! Are you sure you are talking about the same thing? The package I'm talking about has all the assets of the default skin in it!
Since this post I've re-downloaded it twice to double-check. It's nothing but those 2 files, and the zip file underneath it on that page contains a .psd file with the GUI textures all placed together, but still no actual GUISkin data.
It's really a secondary issue, though, as the page says itself you don't need the files since the information is buit-in. Even if it had the assets, I'm still disturbed by the original two problems:
-
The GUIStyle constructor not working as per the docs, leaving me wondering how to copy a style (or skin). Unity permanently keeping my modifications to the default skin in the project, leaving me unable to retrieve the factory settings even with
GUI.skin=null;
Can someone confirm the above facts by testing it themselves?
I'm just having the same issue, though only with custom skins. If I use a custom GUISkin and create a new style for, like, a button, all the buttons in any component using UnityGUI are changed. This is terrible...
Uh, found the reason (that was quick :P). Actually, the first time I created the new GUIStyle I erroneously used
GUIStyle buttonStyle = GUI.skin.button;
I immediately realized my mistake, and I corrected it with
GUIStyle buttonStyle = new GUIStyle( GUI.skin.button );
but I had already run the player once with that wrong setting, and I just discovered that it changes the actual GUISkin settings in your project! Wow! Bad! I had to reset them manually and now everything's working.