I can't see my button in Game View!

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.

6 Answers

6

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.

Scale

  1. 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.

  2. Now try to find your buttons somewhere on the screen (Select the button from the hierarchy and Press F)

  3. 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.

Draw order

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 RendererAdditional SettingsOrder in Layer)


Hope it helps!

This is a bad idea, it should be overlay. Using camera mode means if the camera changes, so will the UI

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. ![alt text][1] [1]: http://www.citrussensations.com/button_ScreenShot.png

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? [106905-screen-shot-2017-12-06-at-125052-am.jpg|106905] [106906-screen-shot-2017-12-06-at-125117-am.jpg|106906]

Have you tried making the Buttons children of that brown tiled area at the bottom? They may be getting blocked by it during rendering.

I can't find anything online. I have no idea what it could be

Still nothing?

Make sure that the parent and the button itself have a scale of 1. Having the scale at 0 was my problem.

Hi, me too… I built my game and couldn’t see the buttons when running it, tried to change the canvas to world space or camera or the default one… nothing !! then as I went to build it for the 5th time, I look over the scenes to include, and I realized the Sample Scene was checked, sure I did some scenery and some script and gameplay content before saving Scene1, but there were no buttons in the sample scene, that’s why they wouldn’t show…felt like a blooper scene myself…
easy fix as you can imagine. just unchecked that the sample scene was to be built too.

I just had a similar issue, but with a peculiar cause that may escape some people.

Let’s say you’ve a complex game and you need to load more than one scene simultaneously, but you want the secondary screen you load to use a canvas set to World Space or Screen Space (Camera) mode. If you put a camera in your secondary scene, Unity will complain when you try and load it because there are two cameras. So you delete or disable the camera from your secondary scene, now what? Suddenly a lot of the stuff on the Canvas doesn’t appear.

That’s because Canvas won’t automatically inherit the main camera from your main scene. It’s got no camera, so a lot of stuff simply won’t render! A simple solution is to put this into any object appearing in that scene:

void Awake() {
    var allCanvases = GameObject.FindObjectsByType<Canvas>(FindObjectsInactive.Include, FindObjectsSortMode.None);
    foreach (var canvas in allCanvases) {
        canvas.worldCamera = Camera.main;
    }
}

What that does is it finds all Canvases in the newly-loaded scene and sets their camera to the main one. Using this method you can even make two Canvases work simultaneously, although I’d recommend putting them on different sorting layers so that you can tightly control which is rendered ‘in front’.