Hardcoding GUISkin reference using C#

I’m trying to hardcode a reference to a GUI skin so that I don’t have to assign it via the inspector. I understand that I can use Resources.Load but what I don’t understand is how to convert or return the resource as a GUISkin type.

For instance…

Object uiSkinResource = Resources.Load("UI_Skin", typeof(GUISkin));
GUISkin uiSkin = uiSkinResource;

Obviously won’t work because the type returned by uiSkinResource is going to be a Unity.Object and I can’t change the ‘Object’ type at the beginning to GUISkin for the same reason.

So what’s the correct method for loading the resource as a GUISkin?

You just cast the return:

GUISkin uiSkinResource = Resources.Load("UI_Skin") as GUISkin;

or

GUISkin uiSkinResource = (GUISkin)Resources.Load("UI_Skin");