I want change my button image to my own custom image and I’ve read documentation but I have no idea how to go about this.
I think the way to do it is to create a GUISkin and I did that but I have no idea now how to reference this GUISkin (which is in my project) from the code.
All the examples just have something like:
var mySkin : GUISkin;
But I just don’t understand how this references their custom skin, doesn’t it need to be pointed to somewhere. I’m also using C# so directions would be very helpful.
For starters, make sure to use the most appropriate forum section when posting. For GUI related stuff use the UnityGUI section as you’re more likely to get solid help there (I’ll move this thread after I post).
You’re part way there, you’ve created a variable that will reference a skin but as you’ve surmised you now must also create that skin.
Go to Assets > Create > GUISkin and you can do that. Or alternatively, you can download the entire default Unity GUI Skin from here. Once you have a skin you can define your button as desired, then in code simply set the GUI skin to the one you created (GUI.skin = mySkin).
Now, with all that in mind this may not be the best option as it will make all buttons in your GUI use the custom image you set up. So if you want to have a globally used skin, then affect only certain buttons with this new image/behavior, then look at creating and applying a GUI style instead. You can create a GUI style entirely in code, or by adding it to an existing skin.
Either way will work and ultimately the choice will depend on exactly what you’re after. Make sense? If not then post up and following questions as we’re all here to help! 