- Home /
I get a weird error when i try to use GUISkin on a timer
Ok well i googled the error and there was only one solution and it was c# so fooey. Well heres my script
var skin = GUISkin;
function OnGUI(){
GUI.skin = skin;
GUI.Box(new Rect(10, 10, 50, 25), "" + Ending.timer.ToString("0"));
}
and heres my error
Assets/Scripts/endScore.js(6,20): BCE0022: Cannot convert 'System.Type' to 'UnityEngine.GUISkin'.
I don't understand, sorry for the burden of such a silly question like this.
Answer by supernat · Mar 25, 2014 at 02:12 AM
GUISkin is a class. When you say "var skin = GUISkin". You are assigning the variable skin to a class type, not a class instance, which makes "skin" a System.Type. That is why it says "Cannot convert 'System.Type' to 'UnityEngine.GUISkin'".
You need to assign an instance of a GUISkin instead. Or don't use a skin at all.
Change to var skin : GUISkin; (thanks @Lo0NuhtiK for adding that)
Sorry i don't exactly know what the difference between a class and an instance. I understand what you are saying though, but how would i customize the look of it without using a skin at all? Use a guistyle?