Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by immersiveGamer · Sep 14, 2013 at 10:26 PM · guierroreditoreditorwindowhandles

GUI error when using HandleUtility.PickGameObject()

So I have been building a map editor for a game that our class is making. So far the results and power of Unity Editor has been great. The editor is built as an EditorWindow and edits and gets information form the Scene via a delgate added to
SceneView.onSceneGUIDelegate. For selecting objects I was using a ray cast to detect objects within the scene however that means that every object needs to have a collider on it to work. Looking at the HandleUtility again I saw and tried to use PickGameObject() , this I assumed was the way the basic Unity Editor does it, and guess what? Works perfectly, even gets object information from a gizmo which is perfect for a spawn point or the likes that is only a empty game object. Only problem is that I get two errors when this function is being called. I have looked up the errors and use of the function, my searching has not helped. The errors don't crash the engine nor stop the function from working. Also a small black box appears at the tip of the cursor and lags behind when cursor is moved.

Errors

Error 1 - "GUI Window tries to begin rendering while something else has not finished rendering! Either you have a recursive OnGUI rendering, or previous OnGUI did not clean up properly."

Error 2 - "device.IsInsideFrame()"

Code

 //Function that is added to SceneView.onSceneGUIDelegate
 void SceneGUI()
     {
         //creates very accurate ray based on raw mouse position.
         ray = HandleUtility.GUIPointToWorldRay(mousePos);
 
         //only gets an object if there is an object to look for
         if(HandleUtility.RaySnap(ray) != null){
             //gets the gameobject the mouse is over in scene view
             hitObj = HandleUtility.PickGameObject(mousePos, true);
         }
     }


An idea about what the problem might be is that the SceneView class is already calling this function and since I am calling it in an added delegate in the SceneView it is causeing somekind of conflict. Of course no idea how to test that. This is a poorly documented feature of the HandleUtility so any help is greatly appreciated!

Comment
Add comment · Show 2
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 immersiveGamer · Nov 22, 2013 at 08:19 PM 0
Share

Since the time of posting this I have needed to do a different approach to my tool so I am not using this method any more. However it would be great to use else where, so if anyone has any ideas about how to get rid of the error or how to use it properly it would still be appreciated.

avatar image testure · Feb 20, 2014 at 02:49 AM 0
Share

Running into the exact situation you described. Unfortunately I actually need this to work without error, so solving the problem is going to be a requirement for me. If I figure out what the issue is I'll post the answer here.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by karl_ · Oct 06, 2014 at 12:32 AM

I also ran into trouble when I tried running PickGameObjects in the OnSceneGUI loop. Since it works as expected when nested under an if(eventType == EventType.MouseUp), I figured it was probably just an issue with it being called between Layout and Repaint. I was able to get it working by only checking for GameObjects on MouseMove type events, since that's really the only time it should change in the SceneView anyways.

 if( Event.current.type == EventType.MouseMove )
     go = HandleUtility.PickGameObject(Event.current.mousePosition, false);
Comment
Add comment · Show 1 · 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 immersiveGamer · Jan 16, 2015 at 09:24 PM 0
Share

That makes sense. While the project is on the back burner and past that issue I will still go back and try it with the SceneView delegate. However it does work with the instpector OnSceneGUI loop. Thanks.

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Draw Camera to Editor Window 1 Answer

EditorWindow: Window works, why does ModalWindow not? 1 Answer

Editor Window - GUI Error You are pushing more GUIClips than you are popping. 1 Answer

Editor windows showing weird noise 0 Answers

GUI Editior Script not working in ( Unity 2019.x ) 0 Answers


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