• 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.

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

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

Handles.color not working for Handles.PositionHandle 0 Answers

Editor GUI Foldout header style customization 0 Answers

MissingMethodException: Cannot find the requested method -2 Answers

OnInspectorGUI() Getting Control 2's position in a group with only 2 controls when doing repaint 1 Answer

Custom Curve Editor? 0 Answers

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