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 canis · Aug 12, 2017 at 05:18 PM · editorbug-perhapseditorguieditor scripting

Inspector issue about draw Button(s) on top of EditorGUI fields, and "CLICK" on it.

here is the story,
I tried to create the auto complete popup for my Editor tools kit.
as the images shown, when the "popup" that I make show on top of another EditorGUI.

alt text

I assume it's some kind of bug for inspector, but I'm not sure if I use it correctly.
what's the point that allow developer to draw button on top of something,
but not allow to click on it ?
Problem:
I can't really click on the "Top" button,
What happen ?
single mouse click will focus the EditorGUI.TextField behind it.
What should happen
Click on the button ! and run the script within the session.

in this case:

  • if any textfield are lay behind the button, mouse click will focus on the textfield "Behind" it, instead of the button on "Top" of it.

  • Cursor (Mouse), it also display as a Cursor.Text instead of Cursor.Hand

  • The popup working fine, if there is nothing allow to interact behind.

some article are saying the GUI.Depth are used to solve the issue, however it didn't work on my cases. in editor I mean. here is how I implement it.

 // Draw recommend keyward(s)
 if (m_CacheCheckList.Count > 0)
 {
     int cnt = m_CacheCheckList.Count;
     float height = cnt * EditorGUIUtility.singleLineHeight;
     Rect area = position;
     area = new Rect(area.x, area.y - height, area.width, height);
     GUI.depth-=10;
     // GUI.BeginGroup(area);
     // area.position = Vector2.zero;
     GUI.BeginClip(area);
     Rect line = new Rect(0, 0, area.width, EditorGUIUtility.singleLineHeight);
  
     for (int i = 0; i < cnt; i++)
     {
         if (GUI.Button(line, m_CacheCheckList[i]))//, EditorStyles.toolbarDropDown))
         {
             rst = m_CacheCheckList[i];
             GUI.changed = true;
             GUI.FocusControl(""); // force update
         }
         line.y += line.height;
     }
     GUI.EndClip();
     //GUI.EndGroup();
     GUI.depth+=10;
 }

so any idea how to workaround the problem ?

for anyone who interested to review the full source code, there is the link in my blog. http://www.clonefactor.com/wordpress/public/1769/

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 canis · Aug 14, 2017 at 07:29 PM

Since I can't find any other solution, using Event.current and did the math, seems it's the only way that I can do.

my solution was using Event.current.mousePosition to calculate which option are hover by mouse. and cache the reference, until that field detected focus lost (blur) script will looking into the cache to find out which one should be selected & replace if needed.

however, the click event still directly land on the TextField behind of it (that's the issue I can't fixed) and still waiting for the correct answer appear.

alt text

the upgraded source code is here. http://www.clonefactor.com/wordpress/program/c/1809/


editorautocompletev2.gif (390.2 kB)
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

88 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

Related Questions

Hint at Inspector variables that have tooltips 0 Answers

Initialising List array for use in a custom Editor 1 Answer

Reflection: "Field items defined on type Inventory is not a field on the target object which is of type PartyManager" 1 Answer

SceneView.onSceneGUIDelegate GUI sorting problem 1 Answer

EditorGUI.PrefixLabel got truncated 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