How would i go about making a custom button to the effect of this:
Just wondering what the best method would be for achieving this result.
How would i go about making a custom button to the effect of this:
Just wondering what the best method would be for achieving this result.
Not sure what you’re asking there, but I’ll try to help you.
• First, you will need to have a sprite image like this one in Unity :
![]()
• Then you set as a UI Sprite.
• In the Sprite Editor (you got to press the button in the Inspector after selecting the image file in the Project tab), you place the padding so that the corner and edge doesn’t get stretched once it’s used.
Like this :
![]()
• Then you add a UI Canvas in the scene.
(If you wish to understand how the UI works, there are hundreds of tutorial on the web. Just search for “Unity UI 4.6 tutorial” and get ready to be launch into space by the massive amount of videos around.)
• Add a UI button as a child of the Canvas (or whatever panel or content you add into the Canvas)
(You can change the button text by changing the text object that is the child of the created button. Also, make sure to place the sprite image in the Source Image to get a preview)
• You set the UI Button to the size you wish for via the Rect Transform component in the inspector.
• If you wish for a animation or a Sprite Swap based buttons, you will have to make sure you got the animation or multiple image files set. For the Sprite swap, there are 4 possibles buttons states : Highlighted, Pressed, Disabled and Normal.
The normal state image is not in the Sprite Swap component, but in the Image (Script) component and is labeled as “Source Image”.
Also, the disabled only appears if the canvas group (need to be added manually) is set to ****.interactable = false. It’s possible to do it either from a script or directly from the OnClick event within the inspector (though you have to redo it every time so I suggest doing it through a common script used by every button if it’s needed).
I highly suggest this tutorial for a good understanding of the UI system :