Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by N1nja · Aug 24, 2010 at 06:43 PM · guimenudisabledisplaycustom

GUIUtility.DisplayCustomMenu().. how can I disable one of these menu items..

For some reason I cannot find any documentation on this function, I am just curious how I can disable one of the menu items. I've seen only one example, where I guess in earlier Unity versions GUIContent had an "enabled" feature, which was used then to disable a menu item, however now GUI controls are enabled/disabled using GUI.enable, so what am I suppose to do here?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
-1
Best Answer

Answer by Daniel-Brauer · Aug 24, 2010 at 08:19 PM

Displaying custom menu items is most easily done with the MenuItem attribute:

http://unity3d.com/support/documentation/ScriptReference/MenuItem.html

As the examples show, you can use a second function to define when the item is enabled or not.

Comment
Add comment · Show 3 · 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 N1nja · Aug 24, 2010 at 09:23 PM 0
Share

um, no.. I'm fully aware on how to use the $$anonymous$$enuItem attribute, this is not for $$anonymous$$enuItems, or the CONTEXT context menus.. this is for the GUIUtility.DisplayCustom$$anonymous$$enu() method, which you may locate if you tried calling that in your code, as you may or may not see, it creates menu items through a GUIContent array, not through attributes.. thanks though!

avatar image Daniel-Brauer · Aug 26, 2010 at 07:02 PM 0
Share

I actually misread your question, because I've never heard of GUIUtility.DisplayCustom$$anonymous$$enu() and thought you made it up. Where did you find it? I don't see it in the documentation or in the UnityEngine.dll for Unity 2.6 or 3.0

avatar image N1nja · Sep 04, 2010 at 06:27 PM 0
Share

it doesn't exist in the documentation, not sure why.. I found a lot of things arnt, such as the Handles class..

avatar image
0

Answer by Daniel-Brauer · Aug 26, 2010 at 08:09 PM

Ok, I found it. It's not part of GUIUtility, but EditorUtility. There are three versions of the function:

internal static void DisplayCustomMenu(Rect position, string[] selected, SelectMenuItemFunction callback, object userData)
public static void DisplayCustomMenu(Rect position, GUIContent[] options, int selected, SelectMenuItemFunction callback, object userData)
internal static void DisplayCustomMenu(Rect position, string[] options, bool[] enabled, int[] selected, SelectMenuItemFunction callback, object userData)

As you can see, the only version with an enabled array is the third one, and it's marked internal.

The second function calls the first, which explicitly sets all the items to enabled.

I'm guessing that all three of these functions are supposed to be internal (or perhaps all public). You should file a bug report.

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 MattRix · May 01, 2016 at 03:42 AM

I know this question is super old, but it still comes up in searches so I might as well answer it.

I don't know why EditorUtility.DisplayCustomMenu isn't documented, but the better way to do what you want is by using GenericMenu. With GenericMenu it's easy to create menus that have dividers, disabled items, arbitrary hierarchies, etc.

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

1 Person is following this question.

avatar image

Related Questions

turn .cs file on and off with keypress???? 1 Answer

Displaying Z Rotation through script 1 Answer

Displaying percentage on GUI 1 Answer

Saving selections across multiple menus? 1 Answer

Custom Material 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