werainsider.blogg.se

How to create your own game background
How to create your own game background









how to create your own game background

So something smaller like this and then position that to the center so we're capturing this image within the frame. This allows me to resize the element while preserving the aspect ratio. Now I'm going to undo that because what I want to do is hold down the shift key on the keyboard and move to one of the corners.

how to create your own game background

This allows me to click and drag to manipulate the different corner elements. I'm going to scale this down a little bit by selecting the rect tool up here. Now to ensure this is set to the correct aspect ratio for this image, I'm going to hit the button here that says Set Native Size and there we have it. Now inside the source image field in the inspector, that is where we drag and drop the element that is to be part of the background. Right click with my mouse, choose UI and then select image to add an image as the background. Instead, I want to select the canvas object. So I'm going to select the object that it created automatically and I'm going to right click to delete that. So by default usually gets it wrong if we just drag and drop from the project panel to the scene. These are the kinds of elements that move around a world inside a 2D game, like a player character or an enemy character, but they're not part of the UI. Now a sprite is not part of the user interface system. You can see from the inspector, it creates a sprite. In creating this and by dragging and dropping the background, unity creates a sprite object. Now, you might think that the best way to do that is by dragging and dropping the background into the scene but it really isn't. So the first thing that I want to add is the background element to this world. The scene that gets saved is the sample scene, which is inside the Scenes folder down here in the project panel. So I'm going to save it by pressing Control + S on the keyboard, Command + S on a Mac or choose File Save. Before doing that I'm going to do something that we should have done a long time ago and that is save the scene in front of us here because we don't want to create work and then lose it. Now let's move forwards with the creation of our UI and to do that, I'm going to be creating the background of our scene.











How to create your own game background