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
2
Question by Ruffian0305 · Oct 03, 2018 at 05:41 PM · unityeditorobjectfield

Hide the Object Picker in Unity Editor in ObjectField

I'm just asking if there is any possibility to hide the "Object Picker" (The little knob/menu next to an ObjectField in a custom Inspector. I am putting a bunch of these object fields right next to each other, and the object picker is getting in the way.

alt text

120656-example.png (40.9 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by dbdenny · Dec 03, 2020 at 07:20 AM

I've got another solution: Ignore the pick result of this object picker, while I still don't know how to hide this button and the pickerwindow, here is the code:

     // Register another callback of this object field
     myObjectField.RegisterValueChangedCallback(DefaultObjectFieldCallback);
     
     // In this callback, is a trick
     private void DefaultAssetFieldCallback(ChangeEvent<UnityEngine.Object> evt) {
         // unregister the callback first
         myObjectField.UnregisterValueChangedCallback(DefaultAssetFieldCallback);
     
         // trick: set back to the old value
         m_ConfigAssetField.value = evt.previousValue;
     
         // register the callback again
         myObjectField.RegisterValueChangedCallback(DefaultObjectFieldCallback);
     }




Comment
Add comment · 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
0

Answer by Brodal · Jan 09 at 11:47 AM

Necroing old thread. But I needed to do something similar and found a way to do this by stepping through the ObjectField in the UIToolkit Debugger. The type of the little object selector button is hidden, so we cant really work with the class itself.

This solution is using UIToolkit.

 public override VisualElement CreatePropertyGUI(SerializedProperty property)
         {
             //  Create ObjectField
             var field = new ObjectField(property.displayName);
             field.objectType = typeof(MyType);
 
             //  Find the little circle button,
             //  The button is of type ObjectFieldSelector 
             //  which i think is internal which is why we cant simply do 
             //  button.Q<ObjectFieldSelector>
             var objectSelector = FindChild(field, "unity-object-field__selector");
 
             //  Make the button invisible
             objectSelector.visible = false;
             return field;
         }
 
 //  Helper method to find the button using a depth first search
 private VisualElement FindChild(VisualElement parent, string ussClass)
 {
     foreach(var child in parent.Children())
     {
         if (child.ClassListContains(ussClass))
             return child;
 
         var subChild = FindChild(child, ussClass);
         if (subChild != null)
             return subChild;
     }
     return null;
 }


Comment
Add comment · 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

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

93 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

Related Questions

EditorGUILayout for GUIStyle 0 Answers

Terrain glitch after editing it 0 Answers

Information box 0 Answers

No solution in Monodevelop 5 Answers

Unity freezing when any method is called? 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