How to Upload Image to Canvas Unity
In my last article, I promised that I would cover inserting a groundwork image. Start your game engines! Permit's go!
In the Consummate Unity Programmer course lecture "Adding 2d User Interface Text", our instructor, Ben Tristem, shows us how to add a background paradigm to the UI (User Interface). Let's acquire how to do this, step past footstep.
Create the Background Image Element
1). Click on the Game Object Carte du jour, which is located at the pinnacle of Unity'south interface.
2). Scroll over UI.
iii). Click on the Image option, in the side menu that slides out. (Please refer to moving-picture show below).
Linking Your Epitome to Source Image & Re-sizing the Image
A thumbnail (small picture of your image) will announced in the Assets department of the Project Tab, at the bottom of your Unity interface. A white bare box volition also announced in the canvass, which is in the middle of your screen. We want the paradigm to take the place of that white bare box, and for that to happen we must do the following steps:
i). Become to the Project Tab, which is located on the Bottom-Left. Make sure y'all have selected Assets, which is located on the Left-Hand side in the Project Tab'southward directory. Click on the thumbnail of your paradigm, in the Assets area, and drag information technology to the blank box next to the word Source Epitome, which is located on the Bottom-Right of your screen in the Inspector Tab. Please refer to picture below.
Some of these steps volition spoil an instructor challenge! Don't read on, unless you really want to.
2). We need to resize the prototype, so that information technology fits within of the borders of the Canvas. In club to do this, we need to see the edge of the Canvas. To make the edge visible, click on the Layers Drop-Down Box, which is located at the Top-Correct of the screen. Next, select the Everything option. This will highlight the Canvas and requite it a solid white border. Please see picture below.
iii). Select Image, which is located in the list in the Hierarchy Tab, on the Left. Delight see picture below.
4). Click on the Move Tool, which is located on the Top-Left. Delight run into picture show below.
5). Click on the center of the Prototype box, and drag it till it snaps to the heart of the Canvas. When information technology snaps y'all will see a thin white line appear in the center of the Sail.
6). You will see the Blueish Re-Sizing Handles, which are on the 4 corners of the Epitome box (Please come across film below). Click on them, ane at a time, and elevate them to resize the image.Yous need the discussion Prison to fill the upper third of the canvas. My image is a little too big, and so please don't employ information technology as an example.
7). Click the Play Button, at the Meridian-Middle of the screen, to see if the epitome displays properly. You want it to exist centered and at the peak one third of the screen, just like the example in the moving picture below.
In my next blog, I volition prove you how to add together a background image file to the Assets expanse of the Projection Tab. I accept enjoyed showing y'all how to add a background image to your game, resize it, and make sure information technology is displaying properly. There is so much more to acquire from theComplete Unity Developer! If yous want to learn more, this course is a must have!
Until adjacent time, happy programming to all! Have an crawly day!
A little nearly the author:
I take always been fascinated with blitheness and video games, and I plan to use these platforms to make clean, family unit oriented, entertainment. I as well programme to revolutionize teaching, and make it fun for everyone!
Source: https://blog.gamedev.tv/how-to-add-a-background-image-to-the-ui-canvas-of-your-unity-game/
0 Response to "How to Upload Image to Canvas Unity"
Post a Comment