I want to assign my own GUISkin to the GUI.skin in javascript. Till now I have written this code (shown bellow) but I don't know how to assign myGUISkin = the GUI skin I created in the inspector.
So, the whole context is like this: the GUISkin I created is called "EsGUIskin.guiskin" and I have it in my project folder.
And in a script I have written:
var myGUISkin : GUISkin;
***BUT HOW do I SAY THAT myGUISkin=EsGUIskin.guiskin?????***
function OnGUI () {
GUI.skin=myGUISkin;
//whatever here
}
It wasn't clear that you knew about drag-and-drop. You can use Resources.Load, but I'd recommend using drag-and-drop unless you have good reason not to.
Thanks anyway Eric5h5, for helping me and others. I am improving quite fast in Unity scripting thanks to your and others help. And yes, I do have reasons for using javascript as much as possible ;)
Hi, try this…(the name of my skin is ‘My Skin’ in the ‘Assets/SKIN’ folder).
var myCustomSkin : GUISkin;
function Start () {
myCustomSkin = Resources.LoadAssetAtPath("Assets/SKIN/MySkin.GUISkin", GUISkin);
}
function OnGUI () {
GUI.skin = myCustomSkin;
}
In documentation there is: "Returns a resource at an asset path (Editor Only).", so after building standalone version it can couse problems. It's better to use 'Resources.Load' instead.
Please, I want to do it in my SCRIPT (javascript). I already know the drag-and-drop solution... If it is not possible just say to me please.
– anon19470065It wasn't clear that you knew about drag-and-drop. You can use Resources.Load, but I'd recommend using drag-and-drop unless you have good reason not to.
– Eric5h5Thanks anyway Eric5h5, for helping me and others. I am improving quite fast in Unity scripting thanks to your and others help. And yes, I do have reasons for using javascript as much as possible ;)
– anon19470065