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 Knedlo · Sep 10, 2018 at 07:37 PM · editoreventonguicommand

ShowObjectPicker ObjectSelectorClosed command is never issued

Hi, I have troubles catching Event.current.commandName == "ObjectSelectorUpdated" after invoking ObjectPicker and selecting something in it.

First I invoke the ObjectPicker after recieving an event. myObject is just a null Brain.

 void OnPullingFromBrain(object obj, System.EventArgs e)
         {
             EditorGUIUtility.ShowObjectPicker<Brain>(myObject, true, "", 1);
         }

Then in OnGUI I'm checking

 if (Event.current.commandName == "ObjectSelectorClosed")
             {
                 Debug.Log(EditorGUIUtility.GetObjectPickerObject());
             }

However command is always empty string. Even debuging it every OnGUI call I get just bunch of empty strings regardless of ObjectPicker updating, closing or whatever.

Any idea what could cause this?

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
1
Best Answer

Answer by Knedlo · Sep 11, 2018 at 05:02 PM

Solved this myself. The ObjectPicker apparently has to be opened from OnGUI method itself, otherwise it won't broadcast events to it. I did it like this:

 int pickerFlag = 0;
     
     void OnPullingFromBrain(object obj, System.EventArgs e)
     {
           pickerFlag = 1; 
     }
     
     private void OnGUI()
     {
           if (pickerFlag > 0)
                 {
                     EditorGUIUtility.ShowObjectPicker<Brain>(myObject, true, "", pickerFlag);
                 }
                 if (canvasCache.nodeCanvas.canvasName == "Brain" && Event.current.commandName == "ObjectSelectorUpdated")
                 {
                     if (EditorGUIUtility.GetObjectPickerControlID() == 1)
                     {
                         Object brainGO = EditorGUIUtility.GetObjectPickerObject();
                         (canvasCache.nodeCanvas as BrainCanvasType).PullFromBrain(brainGO);
                         pickerFlag = 0;
                     }
             }
     }


Sorry for the messy formating.

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 lucbloom · Jul 05, 2021 at 02:56 PM 0
Share

Thank you from saving me from what otherwise would probably have been a full day of despair.

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

121 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 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 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 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 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 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 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 avatar image avatar image

Related Questions

Left Click Up Event in Editor 4 Answers

Adding Tab support to TextArea's TextEditor (almost done) 2 Answers

Event Mouse not working correctly 1 Answer

Is there an event being fired off when the Inspector is being resized? 1 Answer

How to be notified when material changes 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