Is there a way to detect if a game is 2D or 3D in code?

I recently finished a pathing system that’s flawless on 3D but has some quirks on 2D, to be able to fix it though I need some way to detect if the game is 3D or 2D is there a way to do so in code?

Or even better: Is there a way to detect if a specific object is a 3D or 2D object? I know I could probably use GetComponent to do some checks but that doesn’t sound like the most performant way of going about that.

There’s fundamentally nothing different between a 2D and 3D game in Unity. You can even do 2D games with 3D elements or the reverse. You could make guesses, such as if Rigidbody2D is used instead of Rigidbody, by the settings on the camera, by the use of sprites instead of models, etc, but none of those are likely to be 100% reliable indicators.

I’d probably just put an option in the inspector to choose between 3D and 2D and leave it at that.

Yeah that’s probably best, thanks!