So I was just working on something and I pulled the the layer’s documentation page.
And at the bottom I noticed something I never seen in the 7+ years I’ve been using Unity:
Wat?
OK… 1) Unity has 8 layers already reserved, only 5 of which are named, why not use one of the other 3 it reserved?
What is it referring to? What is the Editor Preview’s window mechanics? In what way could they clash?
See… layers in unity are multi-purpose. Not only are they used for physics, but for lighting, and for camera rendering.
As a result… I tend to use different ranges to organize out what the layer pertains to. As a result I might invert my order from 31 back for a sub group of layers.
Never realizing unity suggests not to use layer 31.
…
Now up until now, I haven’t really any known issues with this so called potential ‘clash’… but it leaves me scratching my head. Do clashes exist that I’m completely unaware of and I just assume them to be weird unity quarks, and why in god’s name is this only mentioned passingly in this single piece of documentation rather than well… as previously stated… the 8 other reserved layers???
…
Anyways… wondering if anyone else had noticed this before and their opinions on the matter. Or have answers to questions 1 and 2.
I use 31 all the time. I have no idea what raving nonsense this is. If Unity didn’t want us to use 31, it would be a huge fail letting us use it with impunity if it were harmful.
As it’s just note, I suspect some UI stuff renders using that layer so an editor preview window might draw random scene stuff, dunno. Guessing.
Have blindly continued to use it with no ill effects.
So I answered my own question of what they meant by Editor Preview’s window mechanics and in what way they clash.
I was just talking to my artist about it and how weird it is… and he’s like “wait, which layer is 31?”, “floor”, “floor? OMG! I saw this this morning!!!”
Turns out it was a quark that we just been looking over.
So what it is, is the ‘preview’ window/icons for stuff in your asset folder. I guess how Unity renders these is they draw the models on layer 31. So if anything is on that layer… it will show up when it gets drawn.
Note, the preview window in the lower right, and the preview icons in the assets folder. It’s supposed to be a gun, but there’s this weird grey nonsense in there too.
Well, it’s the pile of hats from in the scene!
That pile of hats is on layer 31 because my artist wanted to treat it as ‘floor’, and the collider and visuals are on the same GameObject.
As far as I understand, all things that you can preview - models, animations, etc., are previewed by instantiating a HideAndDontSave copy at the origin, on layer 31, with a HideAndDontSave camera looking at only layer 31. So you can use the layer for stuff, but it means that if you have something around the origin on that layer, it’ll show up in your animation previews and whatnot.
By the way, if anyone has figured out how to make custom stuff show in the preview window, I’d really love to know, because the only writeup I’ve found is from Unity 4 and in Japanese.
Just stumbled over this in Unity 2022.1.22f1. Tried using layer 31 on a test object, which promptly became invisible. It was marked as visible in the top-right layers visibility list, the camera, and the opaque and transparent layers in the URP asset. Switched to layer 30, and the object appeared. If Unity is going to reserve a layer for internal use, it shouldn’t be writable.
Never knew this, but I just had to try adding a directional light to Layer 31 just to see if it will finally make my preview icons less moribund and lackluster. No visible effect that I can see.
2022.2.17f1 Layer 31 if used causes Exceptions upon pulling up any Layer ComboBox like on the Camera component.
Already reported …but i have no response yet… since a few weeks.
Error appears on any element that uses a layer mask in the inspector, if you have layer 31 used.
Exists in: 2022.2.14 onwards
Does not exist in: 2022.1.24 or in 2023.1.0b15
Issue ID: 1289876