Hi,
I wrote an Editor funtion and everything worked fine in Unity 2022.3. I get this Error message in Unity 6:
Screen position out of view frustum (screen pos 1524.999146, 808.000366, 0.088590) (Camera rect 0 0 1769 794)
UnityEngine.Camera:ScreenToWorldPoint (UnityEngine.Vector3)
CodeRedCat._2DGameObjectTileBrush.Editor.Brushes.GameObjectTileBrush:<OnScene>g__MouseToWorld|60_0 (UnityEngine.Vector3,UnityEngine.Camera) (at Assets/CodeRedCat/2DGameObjectTileBrush/Editor/Brushes/GameObjectTileBrush.cs:214)
CodeRedCat._2DGameObjectTileBrush.Editor.Brushes.GameObjectTileBrush:OnScene (UnityEditor.SceneView) (at Assets/CodeRedCat/2DGameObjectTileBrush/Editor/Brushes/GameObjectTileBrush.cs:175)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Here is the shortened code for it:
private void OnScene(SceneView scene)
{
Vector2 mousePosRef = Event.current.mousePosition;
mousePosRef.y = scene.camera.pixelHeight - mousePosRef.y;
Vector3 mouseWorldPos = camera.ScreenToWorldPoint(new Vector3(mousePosRef.x, mousePosRef.y, camera.nearClipPlane));
}
The Error only thrown in very specific conditions:
Reproduce:
- Set the camera to 2D
- Write OnScene Method in a Scriptable Object
- Compile code
It won’t thrown Errors if the camera is 3D and the function works fine after compiling and gives the correct mouse Position. Only when compiling I get about 100 Error messages each time, which is of course not practial.