• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Hijackedbrain · Feb 08, 2015 at 01:16 PM · c#cameraeditorfrustrum

"Screen position out of view frustum" error on startup

Hello,

I started a new project in unity recently. For now, it only has a camera, a script (attached to the camera), and two cubes. Yet I already have the infamous "Screen position out of view frustum" error EVERY time I start unity. To be more precise, here's the exact error message


Screen position out of view frustum (screen pos 0.000000, 0.000000, 100.000000) (Camera rect 0 0 0 0) UnityEngine.Camera:ScreenToWorldPoint(Vector3) cameraGizmo:OnDrawGizmos() (at Assets/RMAssets/Scripts/Misc/cameraGizmo.cs:17) UnityEditor.DockArea:OnGUI()


I've been searching all around for explanation. But all I could found was "meh it's an editor bug, just don't mind it. They've never been able to reproduce it".

So my questions are: Does this bug has been tracked down yet? If not, should I / How do I give a copy of my project to unity devs?

By the way, here's the script file attached to the camera, I only use it to print the camera field of view (not the full frustrum because I'm working on a 2D game):

 using UnityEngine;
 using System.Collections;
  
 public class cameraGizmo : MonoBehaviour
 {
     Camera cam;
  
     void Start()
     {
         Gizmos.color = Color.white;
     }
  
     void OnDrawGizmos()
     {
         Camera cam = this.camera;
  
         Vector3 blPoint = cam.ScreenToWorldPoint(new Vector3(0, 0, cam.farClipPlane));
         Vector3 brPoint = cam.ScreenToWorldPoint(new Vector3(cam.pixelWidth, 0, cam.farClipPlane));
         Vector3 tlPoint = cam.ScreenToWorldPoint(new Vector3(0, cam.pixelHeight, cam.farClipPlane));
         Vector3 trPoint = cam.ScreenToWorldPoint(new Vector3(cam.pixelWidth, cam.pixelHeight, cam.farClipPlane));
  
         Gizmos.DrawLine(tlPoint, trPoint);
         Gizmos.DrawLine(trPoint, brPoint);
         Gizmos.DrawLine(brPoint, blPoint);
         Gizmos.DrawLine(blPoint, tlPoint);
     }
  
     void OnDrawGizmosSelected()
     {
         Gizmos.color = Color.red;
         OnDrawGizmos();
     }
 }

Thanks for reading. Any help would be appreciated.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by PrincipleDev · Nov 13, 2015 at 03:37 PM

@Hijackedbrain No, this is not the same as the editor bug.

Change the following lines in your OnDrawGizmos call:

Vector3 blPoint = cam.ScreenToWorldPoint(new Vector3(0, 0, cam.farClipPlane - 0.01f)); Vector3 brPoint = cam.ScreenToWorldPoint(new Vector3(cam.pixelWidth - 0.01f, 0, cam.farClipPlane - 0.01f)); Vector3 tlPoint = cam.ScreenToWorldPoint(new Vector3(0, cam.pixelHeight - 0.01f, cam.farClipPlane - 0.01f)); Vector3 trPoint = cam.ScreenToWorldPoint(new Vector3(cam.pixelWidth - 0.01f, cam.pixelHeight - 0.01f, cam.farClipPlane - 0.01f));

The issue here is that you are attemting to find the out edge of the view frustrum using ScreenToWorldPoint, however the values held by cam.farClipPlane, cam.pixelWidth, and cam.pixelHeight are literally just outside the edge of that frustrum. By subtracing a small value like 0.01f, you are bringing those values back within the view frustrum so ScreenToWorldPoint can actually get a value for their location.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Burkard · Sep 14, 2015 at 12:52 PM

I had this error too.

It seems to happen when I create a project in a 14' laptop, and then copy the entire project folder for a laptop with a bigger monitor (in the case, a 15' one).

The solution was to recreate the project, and copy all the files (not the folders) necessary for it (.unity, .cs, etc). Maybe it has something to do with the .meta files or the cache (which are copied when you copy the entire folder)...

I didn't know someone reported this as a bug, maybe they could try to reproduce it this way.

Good luck!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Render distance editor. 1 Answer

'Locking' a scene cam in editor? 0 Answers

Best way to manage multiple camera angles? 3 Answers

How to reduce cam speed in the editor? 6 Answers

Editor Camera Perspective 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges