- Home /
Is it possible to set the scene view rotation pivot through code?
I know one can set it in the editor by selecting an object and pressing F. I would like however to do that through C# scripting ...
Answer by mouurusai · Sep 21, 2014 at 10:37 PM
You need use "SceneView" class from UnityEditor namespace.
Thanks, could you be more specific? I know how to change the scene view camera position, rotation, .... through the SceneView class, but not how to change the rotation pivot.
I'm sorry, I missed the word "pivot" when I read the question. $$anonymous$$aybe if you know a mouse delta , you can achieve the desired behavior by setting position and rotation.
Answer by ocimum · Oct 16, 2015 at 12:54 PM
If you want to change the sceneview position you have to set a new position to the pivot of the scene view
void UpdateSceneView ()
{
_scene = SceneView.lastActiveSceneView;
Vector3 newPos = _scene.pivot;
newPos.x = 0;
newPos.y = (_2dMode) ? 0 : 40;
newPos.z = (_2dMode) ? 40 : 0;
_scene.pivot = newPos;
_scene.Repaint ();
}
You could also just load a game object and just pass the gameobject.transform to the sceneview
_scene.AlignViewToObject (_camera.transform);