- Home /
Question by
RewindGameStudio · Jun 27, 2014 at 10:52 PM ·
2deditoreditor-scripting
Detecting if the 2D Mode button was pressed
Is there any way ( through editor scripts or otherwise ) to detect if the 2D mode button was toggled. And what it's initially set to.
We'd like our assets to respond to this and switch some settings.
Comment
Best Answer
Answer by Omberone · Jun 27, 2014 at 11:36 PM
UnityEditor.EditorSettings.defaultBehaviorMode == UnityEditor.EditorBehaviorMode.Mode2D
Answer by Mikkel Gjoel · Jul 02, 2015 at 04:16 PM
If you want to know if a particular camera is a sceneview, and in 2D-mode:
bool isSceneView2D( Camera cam )
{
for ( int i=0,n=UnityEditor.SceneView.sceneViews.Count; i<n; ++i )
{
UnityEditor.SceneView sv = UnityEditor.SceneView.sceneViews[i] as UnityEditor.SceneView;
if ( sv.camera == cam )
{
return sv.in2DMode;
}
}
return false;
}