Unity运行时仅显示Skybox,Game视图与相机预览正常求助
Hey Ryan! Let's work through this annoying issue—since everything looks good in edit mode but vanishes when you hit play, it's almost always a runtime-specific setting or a hidden activation problem. Here are the most common fixes to check first:
Double-Check Your Main Camera's Position & Culling Mask
You mentioned the main camera is behind the background—this is probably the root cause! In 2D, we typically keep the camera at a Z-position of-10(the default) so it can render objects placed at Z=0. If your camera's Z is set to a positive number (like10), it's sitting behind all your game objects, so it can only see the skybox.
Also, pop into the Camera component's Culling Mask and make sure every layer your game objects (background, sprites, UI, etc.) are on is checked. It's super easy to accidentally uncheck a layer when tweaking settings, and that'll make everything on that layer disappear in play mode.Verify Object Activation (and Scripts That Might Disable Them)
Sometimes objects look active in edit mode but get turned off when the game starts.- Select your background and other game objects, then check the checkbox at the top-left of the Inspector (next to the object's name). If it's grayed out, it's inactive—but since you can see them in edit mode, this is more likely a script issue.
- Dig into any scripts attached to your objects and look for lines like
gameObject.SetActive(false)inStart()orAwake(). It's easy to add that line for testing and forget to remove it!
Sorting Layers & Render Order Checks
In 2D, sorting layers control what renders on top of what. If your objects are on a sorting layer that's set to render behind the skybox (unlikely, but possible) or their Order in Layer is misconfigured:- Select your sprite objects, open the Sprite Renderer component, and confirm the Sorting Layer is set to something like "Default" or a custom layer you created. Also, check the Order in Layer value—higher numbers mean the object renders on top. If your objects have a super low value, they might be hidden, but since you only see skybox, this is less likely than the camera issues.
Camera Projection & Clipping Planes
Make sure your camera is set up for 2D:- Ensure Projection is set to Orthographic (Perspective is for 3D and can mess up 2D rendering if the camera is positioned wrong).
- Check the Clipping Planes—Near should be around
0.1and Far around100. If your objects are outside this range (e.g., your camera's Z is-10but Far is set to5), they'll be outside the camera's view and won't render.
Quick Skybox Sanity Check
This is a long shot, but worth a quick look: Open Window > Rendering > Lighting Settings and check the Skybox material. If it's set to a solid color or a material that's forcing full coverage, but since edit mode works, this probably isn't the issue—but it never hurts to confirm!
I've dealt with this exact problem a handful of times when teaching myself 2D Unity dev—nine times out of ten, it's just a misplaced camera Z-position or an accidentally unchecked culling mask. Start with those two first, and you'll probably have it fixed in minutes!
内容的提问来源于stack exchange,提问作者Ryan W.

