Skip to content
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

Add a generic EditorPlugin callback for Node configuration warnings #922

Open
willnationsdev opened this issue May 27, 2020 · 0 comments
Open

Comments

@willnationsdev
Copy link
Contributor

willnationsdev commented May 27, 2020

Describe the project you are working on:
I have a plugin that expects nodes matching certain criteria to be configured in specific ways. The nodes do not necessarily all share a script or base type.

Describe the problem or limitation you are having in your project:
If I want to have a configuration warning appear to notify users that the node(s) are configured incorrectly for use with the plugin, I need to add a code change to every script (or even to nodes that may not have a script) to implement the _get_configuration_warning() method.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
EditorPlugin should have a generic callback that accepts a Node and returns a configuration warning string. The callback would get called on every node in the Scene dock and non-empty string values returned by it would generate warning icons just like the virtual method call per-script would.

Edit: As an added bonus, this helps clean up script code as editor-specific code is now moved out of a script and into plugin code (potentially allowing a tool script to stop being a tool in the first place).

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

  1. Implement an EditorPlugin get_configuration_warning(Node p_node) method. Check if the plugin's script implements the method, and if it does, get the string results and return it.
  2. Add a get_configuration_warning(Node p_node); public method to the EditorNode. Have it iterate through the list of EditorPlugins, and call their implementations of the same method. Concatenate the results with double newlines.
  3. Modify the Scene dock implementation to take into account not only a potential _get_configuration_warning() method on the script, but also the results from the EditorNode via concatenation (double newlines).

If a node's script and two plugins implement it, the resulting warning tooltip would look like...

node script message

plugin A message

plugin B message

If this enhancement will not be used often, can it be worked around with a few lines of script?:
The entire point is to avoid having to reproduce multiple lines of script, and no, existing EditorPlugin features do not allow for this.

Is there a reason why this should be core and not an add-on in the asset library?:
Requires editor changes inaccessible to the existing scripting API.

@Calinou Calinou changed the title Add a generic EditorPlugin callback for Node configuration warnings. Add a generic EditorPlugin callback for Node configuration warnings Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants