Skip to content

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

Merged
merged 3 commits into from
Jan 16, 2020
Merged

Use AddComponentMenu for MonoBehaviours #3231

merged 3 commits into from
Jan 16, 2020

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Jan 15, 2020

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:
Screen Shot 2020-01-15 at 1 18 11 PM

Add Component in the inspector
Screen Shot 2020-01-15 at 1 21 11 PM

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

@chriselion chriselion requested a review from surfnerd January 15, 2020 21:32
@@ -10,6 +10,7 @@ namespace MLAgents
/// Demonstration Recorder Component.
/// </summary>
[RequireComponent(typeof(Agent))]
[AddComponentMenu("ML Agents/Demonstration Recorder")]
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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")]
Copy link
Contributor Author

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.

Copy link
Contributor

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")]
Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[AddComponentMenu("ML Agents/Sensors/Camera Sensor")]
[AddComponentMenu("ML Agents/Camera Sensor", kSensorMenuGroup)]

Where kSensorMenuGroup is defined somewhere.

@chriselion chriselion changed the title Set AddComponentMenu for MonoBehaviours Use AddComponentMenu for MonoBehaviours Jan 15, 2020
@vincentpierre
Copy link
Contributor

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

For now 😈

Copy link
Contributor

@vincentpierre vincentpierre left a 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")]
Copy link
Contributor

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")]
Copy link
Contributor

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

Copy link
Contributor

@surfnerd surfnerd left a 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).

Copy link
Contributor

@surfnerd surfnerd left a 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. 👍

@chriselion
Copy link
Contributor Author

Without nesting and adding a menu group:
Screen Shot 2020-01-16 at 3 08 35 PM

@chriselion chriselion requested a review from surfnerd January 16, 2020 23:15
/// <summary>
/// Grouping for use in AddComponentMenu (instead of nesting the menus).
/// </summary>
public enum MenuGroup
Copy link
Contributor Author

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?

Copy link
Contributor

@surfnerd surfnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@chriselion chriselion merged commit 25f3697 into master Jan 16, 2020
@delete-merged-branch delete-merged-branch bot deleted the component-menu branch January 16, 2020 23:43
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants