• 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 crotchfruit · Apr 06, 2011 at 06:15 PM · mouseonsceneguideselect

How do I prevent Unity from deselecting the current object when I click in the SceneView?

I'm trying to do drawing in the SceneView window, but Unity keeps deselecting the object with my drawing script when I click.

From the docs, it looked like calling Event.Current.Use in OnSceneGUI was the way to go, but it doesn't seem to be working.

Any ideas?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
5

Answer by hardwire · Jun 14, 2011 at 12:05 PM

If you add your own control Unity won't use the "selector" control by default and thus clicking in the scene won't deselect your object. To do so call

 HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));

in OnSceneGUI()

Comment
Add comment · Show 2 · 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 damianf · Apr 13, 2012 at 05:21 AM 0
Share

Thanks! I had this problem and this was a perfect solution.

avatar image razveck · Jul 16, 2020 at 01:15 AM 0
Share

Works perfectly! Thank you

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

2 People are following this question.

avatar image avatar image

Related Questions

Right mouse button in webplayer 3 Answers

Mouse driven circular movement 1 Answer

Aiming With my mouse 1 Answer

How do i get the cursor to stay in the center of screen for fps!? 1 Answer

Attach an object to the mouse cursor? 0 Answers

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