- Home /
Way to find Default Behavior Mode of Physics through Script
I was wondering if anyone knew of a way to check by script what unity's default behavior mode is for physics.
The reason for asking I want to make a a* system that reads what the current behavior mode of physics is and create the grid on the respectful world axis.
Thank you to anyone that takes there time to answer this.
Uhm, i have no idea what you mean by "Behavior $$anonymous$$ode". Even if there is something like a "physics behaviour mode", what would that "mode" control and how would it affect a search algorithm?
Sorry, but this question is not clear at all and needs clarification. Please edit your question and be more precise what you mean.
Answer by Bunny83 · Mar 19, 2016 at 05:04 PM
That has nothing to do with physics at all. This is a project specific setting which changes how the editor works. That's why you find this setting in
Edit --> Project Settings --> Editor
and not
Edit --> Project Settings --> Physics / Physics2D
Whether you develop your game in the 2d editor mode or 3d has no influence on how the game actually works. It just simplifies the development a little bit. Also everything you create is automatically preconfigured for the "space" you have selected. You can develop a 3d game in 2d mode (which just gives some problems as the whole UI is designed for 2d but it's still possible) and you can develop a 2d game in 3d editor mode.
As for physics, both physics systems can be used at runtime. You don't need to switch something. Both can even run at the same time. They are independent from each other.
If you just want to determine the mode the Unity editor is currently in you can use
UnityEditor.EditorSettings.defaultBehaviorMode
in an editor script. It returns an enum value of EditorBehaviorMode. It seems they are still lacking proper documentation of this enum and the EditorSettings class in general (as it's completely missing in the docs)
This class can't be used at runtime since it belongs to the Unity editor namespace. This namespace is only available inside editor scripts since it provides things that belong to the editor application which of course isn't shipped with your built game.
Thank you that code line helps a lot. I know it doesn't have to do with physics behavior. I am sorry if my question was clear. The main reason I had this question is I wanted to have a script read your default behavior of the editor is and draw an a* path grid on based on the correct perspective. So if the behavior is 2D draw it on the axis used by 2d sprites and if it is 3d draw the grid on the perspective of the 3d world.