-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Use AddComponentMenu for MonoBehaviours #3231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -10,6 +10,7 @@ namespace MLAgents | |||
/// Demonstration Recorder Component. | |||
/// </summary> | |||
[RequireComponent(typeof(Agent))] | |||
[AddComponentMenu("ML Agents/Demonstration Recorder")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we list this? I'd be willing to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to have it or remove it?
@@ -8,6 +8,7 @@ namespace MLAgents | |||
/// Monitor is used to display information about the Agent within the Unity | |||
/// scene. Use the log function to add information to your monitor. | |||
/// </summary> | |||
[AddComponentMenu("ML Agents/Monitor")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK removing this one too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should, this is supposed to be hidden from the user and automagic
@@ -3,6 +3,7 @@ | |||
|
|||
namespace MLAgents.Sensor | |||
{ | |||
[AddComponentMenu("ML Agents/Sensors/Camera Sensor")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally left "Component" off the sensor menu items; I think it's a bit wordy otherwise but willing to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Unity UI guidelines recommend against nesting menus. We should just group the alike menu items using the componentOrder
constructor variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[AddComponentMenu("ML Agents/Sensors/Camera Sensor")] | |
[AddComponentMenu("ML Agents/Camera Sensor", kSensorMenuGroup)] |
Where kSensorMenuGroup
is defined somewhere.
For now 😈 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we should do this now. We do not know yet how components will evolve and I would like to avoid maintaining new user entry points and associated documentation.
@@ -8,6 +8,7 @@ namespace MLAgents | |||
/// Monitor is used to display information about the Agent within the Unity | |||
/// scene. Use the log function to add information to your monitor. | |||
/// </summary> | |||
[AddComponentMenu("ML Agents/Monitor")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should, this is supposed to be hidden from the user and automagic
@@ -10,6 +10,7 @@ namespace MLAgents | |||
/// Demonstration Recorder Component. | |||
/// </summary> | |||
[RequireComponent(typeof(Agent))] | |||
[AddComponentMenu("ML Agents/Demonstration Recorder")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we should do this now. We do not know yet how components will evolve and I would like to avoid maintaining new user entry points and associated documentation.
@vincentpierre I believe this is something we should be doing and keep up to date as components are changing. This way users have multiple ways to find out what they need. This is a common workflow for unity users. It's a small, yet impactful, step towards improving the discoverability of components (even if they are changing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for the nesting, which from talking to you will be changed. 👍
/// <summary> | ||
/// Grouping for use in AddComponentMenu (instead of nesting the menus). | ||
/// </summary> | ||
public enum MenuGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better way to do this / better place to put it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There have been a few issues about missing menu items.
#2870
#3227
These were probably from following a now-outdated tutorial, but I think adding menu items for the MonoBehaviours that we have probably makes things a bit more discoverable:
Menu bar:

Add Component in the inspector

Unfortunately,
Agent
doesn't qualify for this because it's abstract.