Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
1
Question by dhakim · Jul 29, 2011 at 05:13 PM · editorwindowthreadinglevel-editor

Camera.Render assertion in EditorWindow's OnGUI

I am trying to make an EditorWindow that displays the current scene with a camera, preferably without the use of RenderTextures, as that is a pro only feature, (and because if I were using raw OpenGL, that isn't the way I would do it as it would seem to be a waste of texture memory if there is an already existing frame buffer that I want to be drawing into anyway)

So I created an EditorWindow subclass called LevelEditor, from which I just took the small relevant snippet.

 public class LevelEditor : EditorWindow
 {
     public Camera cam;
 
     void OnGUI()
     {
         cam.pixelRect = new Rect(0, 0, position.width, position.height);
         cam.Render();
         
         GUILayout.Label("Hello World", skin.label);
     }
 }

I set cam in the inspector to be a camera separate from the main camera, and this EditorWindow will now draw the scene from the point of view of that camera.

However, while most of the time this works perfectly, (and quite quickly), sometimes it starts spraying out assertions inside the cam.Render(). Sometimes it sprays out 100 assertions in a frame, causing several seconds of lag between frames.

The assertion I get is screenviewcoord[1] < 0 || screenviewcoord[3] < 0 UnityEngine.Camera:Render() LevelEditor:OnGUI() (at Assets/Editor/LevelEditor.cs:32) UnityEditor.DockArea:OnGUI()

I believe this assertion is stating that the viewport I have set for the window does not actually fit inside the window I am drawing to, and based on the fact it only happens sometimes (and more and more often the larger the size of the EditorWindow), I expect that it is occurring as a race condition in which either the viewport I am sending or the window I am drawing to is changing during the Render() call.

Is there any function I can call to prevent Unity from trying to draw another window while I am rendering?

Is there any function I can call to set the window to draw to as my EditorWindow from inside my EditorWindow's Update() call, so that I can move my cam.Render there, where I may be less likely to run into threading issues?

Has anyone successfully done this before?

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

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Am I over-engineering my editorscript? 0 Answers

How do I get the properties of a model's (or Camera's) Transform in the Editor Preview control? 0 Answers

Adjust the width/height of List property elements in the Inspector 1 Answer

I am making a level editor and need ideas on how to save the level file. 1 Answer

How do you stop multithreading in editor? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges