I’ve been looking for hours for an example that explains how to do something I thought would be simply, adding a image file to be used as a button.
The examples I’ve found talk about using Resources.Load(“wheat.png”) which I put inside a resources folder which I’ve put everywhere just in case I didn’t have in located in the right folder inside my project. e.g. like:
private Texture wheatButton; void Start() { wheatButton = (Texture)Resources.Load("wheat.png"); } void OnGui(){ if (GUI.Button(new Rect(button.x, button.y, 100, 20), wheatButton)); }
Nothing gets displayed and there is no examples of C# code to show how one goes about loading a image apart from saying, use inspector. But I can’t see what object or thing you can create to then access in the inspector to link a image, or any examples showing how to do it. I’m sure someone out there has needed to load an image as a texture to use in scripting code before and shouldn’t be that complex, any help would be appreciated.