[Solved] Adding a PNG image to a scene, but it's not visible in game view

Hello,

I decided to finish off the Number UI game by adding a few images. I ‘think’ I correctly followed the process that was used in the Text101 lesson.

Process followed

  1. Drag and drop Prison.png from file system to the Assets window (ensuring it was imported as sprite (2D and UI), sprite mode single.
  2. Drag Prison asset to the canvas
  3. Notice it’s extremely small compared to the canvas.
  4. Attempt to get image to a decent size using either of 2 methods (neither worked for me):
    • First attempt: In the inspector for the instance of the image Change Transform Scale to 100
    • Second attempt: Reset transform scale to 1, and instead set the Asset Pixels Per Unit to 1 in the inspector (It was at 100 by default)
  5. Show Game Window

Observed result
The textual elements are visible but not my image

Expected result
All elements should be visible

Any help greatly welcomed!
Phil

Screenshots follow

Will add more images in a followup post

Hi @fatphil,

Try the following;

In the hierarchy, move the prison word game object above the other game objects within the Canvas, place it directly under the Canvas - does this resolve the issue?

If not…

Change the z-index of the prison word game object to be closer to the camera (currently at -10) than the other game objects within the canvas, you can pop into 3D mode to get a view of where they are all sitting.

1 Like

Hi @Rob,

I played around with what you said but that wasn’t the issue. Then I had a d’oh moment :confounded: If I’d been paying attention to the video (Section 3, lecture 29, 13:25) I would have noticed that just dragging the sprite from the Assets to the canvas creates the wrong type of instance (Same as choosing GameObject>2D Object>Sprite). What you need to do to get it on the canvas is choose GameObject>UI>Image and drag the sprite from Assets to the Image’s SourceImage selection box.

I’d like to know why sprites added to the scene as sprites are not rendered visible. Is that a camera setting?

Cheers,
Phil

3 Likes

One possibility is that the size of the Canvas may be ENORMOUS compared to the area which the Main Camera is viewing. One may be looking at the huge Canvas area in Game View, while looking at the tiny Camera area in Scene View. So when one tries to position the Sprite in the Scene View, it would not show up in Game View because the camera area is microscopic relative to the Canvas. But if one were to use a UI Image as a child of the Canvas, it would then scale along with the size of the Canvas so that it becomes visible as normal in Game View.

on canvas, set “render mode” to world space. That worked for me

Privacy & Terms