All objects have moved out on coordinate Z

Hello! As always, I’m working in Unity and suddenly I notice that some objects that I manually added the Sprite Renderer are not displayed. I look at the Z-coordinate and see: all objects on all scenes moved off-axis Z and are at different coordinates (some -60, some 1, some 70)
What could this be due to? I honestly did not pay much attention to the Z-coordinate before. I use Cinemachine cameras, if it’s important.

Note: apparently this is something to do with the camera, for scenes without it all is normal. But I missed the moment when it happened. Tell me if this is normal and will not cause problems in the game?
I tried adding a camera where it was missing and nothing moved.

Some candidate causes:

  • you dragged it there in the first place when you put it in scene

  • you inadvertently clicked on the blue plate when sliding around with the move widget

  • some other editor script moved it

Whatever it is, I would suggest keeping things at z == 0 if you are doing 2D, just to reduce confusion. Also keep this in mind:

Three (3) ways that Unity draws / stacks / sorts / layers / overlays stuff:

In short,

  1. The default 3D Renderers draw stuff according to Z depth - distance from camera.

  2. SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties

  3. UI Canvas Renderers draw in linear transform sequence, like a stack of papers

If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:

  • identify what you are using
  • search online for the combination of things you are doing and how to to achieve what you want.

There may be more than one solution to try.

Additional reading in the official docs:

If I understand you correctly, I can just put all the objects on the Z coordinate to 0. Thank you! The main thing is not to break anything :slight_smile: I will familiarize myself with the documentation.

If you’re not breaking anything, you’re probably not working efficiently. :slight_smile:

The key is to constantly break and fix stuff to gain more knowledge about how it all works.

Can I ask offtopic questions?

  1. I copy the same Cinemachine camera and Main Camera for every scene from start scene (its fast). But on some scenes I can’t change their Z-coordinate (its like freeze), but on others I can. What does this have to do with, I googled everything and couldn’t find
  2. I have UI buttons. And when I click on them, they start responding to pressing the Submit key (I have a spacebar). Is there any way to disable them from interacting with the space bar, so that the buttons are only pressed with the mouse? Thank you!

Can’t change Z of what, the camera? Or something else? A script could be doing it.

That’s an interesting question. Perhaps by adding an EventTrigger class to the button you can control more precisely what you respond to?? I haven’t tested it but that’s the first thing that comes to mind.

As for copying stuff around, that’s always a bad way to work.

Additive scene loading is one possible solution:

A multi-scene loader thingy:

My typical Scene Loader:

Other notes on additive scene loading:

Timing of scene loading:

Also, if something exists only in one scene, DO NOT MAKE A PREFAB out of it. It’s a waste of time and needlessly splits your work between two files, the prefab and the scene, leading to many possible errors and edge cases.

Two similar examples of checking if everything is ready to go:

No, I figured it out on my own.
Put “None” in the “Navigation” field. It fixed problem with triggering UI button on use “Submit” button.
You must have misunderstood me about additive loading. I just copy objects in the editor, nothing is copied in the game. Why do I need additive loading? Or are you on the wrong topic?

I was thinking you meant you had a very specific camera setup and you were copying it from scene to scene.

My suggestion re additive scene was, “Have a camera scene that you load with every level scene.”