- Home /
I can't see my button in Game View!
So, I'm trying to make a button BE an image, a .png to be exact. I'm placing that on the Canvas Renderer that automatically shows up when you create a button, but the image is not showing up in game view. When I place that image on the button with a Sprite Renderer it shows up in game view but, I don't know that will still be clickable button when it comes to game time.
This button I'm creating is nested at the bottom of the screen and when clicked will spawn a unit on the battlefield. I'm a rookie at Unity so any help would be appreciated!
Thank you in advance.
Answer by NilZee · Jan 06, 2021 at 08:30 AM
It's too late for you. But it was the first result when I googled the issue. So I'm writing this for everyone that has the same issue. Select your canvas, go to the canvas component > Render Mode. Change it to "Screen space - camera" and add your main camera to the section below that. Now try to find your buttons somewhere on the screen (Select the button from the hierarchy and Press F) and even if it didn't work (it will!), go to the game view and play with the scale and position of your button until you can see it. There is also a possibility that the button is in the back layer. You can change the order of let's say your background, when you select it (Sprite renderer > Additional settings > Order in Layer) Hope it helps!
Answer by Larry-Dietz · Dec 06, 2017 at 06:02 AM
When you create the button component, it has an image already part of the button. Just put whatever PNG file you want into that, and the button should be displaying your image, with the text component overlaying it.
As long as that button is within the viewable range of the camera, I can't think of any reason it wouldn't show up in the game view.
-Larry
I assume, being new to this I don't really know but I haven't found to much online. I put the .png in the Canvas Renderer where the default image for a button is held and it switches the button to my .png but it still doesn't show up in game view.
Could it have to do with sorting layers? The only issue is that to my knowledge buttons don't have sorting layers. So, I can't do anything there. I've also changed the Z position as this is a 2D game and that didn't seem to do anything either.
Further speculation would be appreciated! Thank you.
Can you post a screenshot of your scene view, with the camera selected?
Here is a screenshot from a game I am working on, showing a button. If you look at the inspector window, you see an Image component set to Buttons_45
Buttons_45 is a PNG file in my project. You can see that it is visible in both the Scene and Game view.
The first image is the scene view and you see the the tiles with the character faces in them. Next is the game view and those images disappear! Thoughts?
I am sorry to say, that this one has me stumped. Looking at the screenshots, I cannot see any reason that the buttons are not visible in the game view.
I know this is a pain, but if you want to send me a repro project, just a single scene with the canvas and sprites, no code or anything, I would be happy to dig through it an figure out why this is happening.
Answer by CmdrZin · Jan 06, 2021 at 06:27 AM
Have you tried making the Buttons children of that brown tiled area at the bottom? They may be getting blocked by it during rendering.
Your answer
Follow this Question
Related Questions
Change camera fov on canvas button pressed 2 Answers
Canvas is hiding my 3D model, can I place the model in front of the canvas? 1 Answer
How to instantiate a prefab between Canvas and a Button? 0 Answers
Canvas: On hovering over Buttons: Wrong Buttons activated 2 Answers
The camera doesn't match with canvas 1 Answer