- Home /
This was a bug and has been reported to Unity. The tracking number is in the comments.
Why does the SceneView camera return jittery values?
I'm creating an editor extension that relies on converting screen space coordinates into world space coordinates using the SceneView editor camera.
However, doing a simple test of retrieving the camera size or converting coordinates, returns unreliable jittery values.
If you run the script below (place it in an Editor folder and then Window -> JitterTest) and simply click around on the Scene View you will see at least two different values output, even though the SceneView camera is not being moved around. Is this a bug?
*Using Unity 5.2.1f1 (Mac)
using UnityEngine;
using UnityEditor;
public class JitterTest : EditorWindow {
[MenuItem ( "Window/JitterTest" )]
static void OpenWindow() {
EditorWindow.GetWindow( typeof( JitterTest ) );
}
void OnEnable() {
SceneView.onSceneGUIDelegate += OnSceneGUI;
}
void OnSceneGUI( SceneView sceneView ) {
Debug.Log( "Random size:" + sceneView.camera.orthographicSize );
Vector3 testVec = new Vector3( 100f, 100f, 0f );
Debug.Log( "Random world point:" + sceneView.camera.ScreenToWorldPoint( testVec ) );
}
}
I've submitted this as a bug. If I get any confirmation that this is indeed a bug, I will update here.
I only get two different values if the scene view is in 2D mode. In 3D it's always the same output.
Confirmed as a bug. You can track it here: https://fogbugz.unity3d.com/default.asp?739443_m5seomjm53bji4mp