- Home /
[2D] Sprites invisible in game view after instantiating.
Hey all,
So I have a script that, when I click the left mouse button, instantiates a sprite at the position of the mouse. This is that line of code:
Instantiate(emptyAtomPrefab, mainCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f)), Quaternion.identity);
So the problem is that the sprites is completely invisible in the Game View, but not in the Scene View. This feels like a weird bug, because I can't think of a reason why it wouldn't appear.
A few things to note:
The Sprite is not an image or any kind of UI object.
The Sprite only contains the default components.
Anyone knows what's going on here? Thanks!
Check scale of instantiated object camera position needs to be -10 units check camera far .
Answer by rufopufo · Jan 23, 2020 at 07:39 AM
Hi there,
@kskjadav007 camera's answer may be the one. You can also check the "Order in layer" in your prefab's Sprite Renderer component. It has to be higher than the background's order in layer.
By default both of them would be 0, so it may be making that you can't see the instantiated object in the game view. Try to set it to 1.
Hope it helps.
Your answer
![](https://koobas.hobune.stream/wayback/20220612221930im_/https://answers.unity.com/themes/thub/images/avi.jpg)