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

Expose Script reflection methods to scripting API. #31021

Merged
merged 1 commit into from
Sep 3, 2019

Conversation

willnationsdev
Copy link
Contributor

When a user wishes to...

  1. write tool scripts for the editor to provide or take advantage of class information associated with a script...
  2. design their own customized editor that takes advantage of Godot's Script interface, say, via NativeScript or PluginScript...

...they cannot expose information about the resources' class data without first creating an instance of the underlying class. Not only is this wasteful in terms of memory and speed, but it is also a needless complexity since the functionality to access this information already exists within the engine. It simply isn't exposed.

This PR simply adds some utility methods to Script to convert things to Array/Dictionary format. It then binds those methods to the scripting API.

@akien-mga akien-mga added this to the 3.2 milestone Aug 2, 2019
@Zylann
Copy link
Contributor

Zylann commented Aug 3, 2019

Note: this won't list properties generated from get_property_list(), because that definitely requires an instance. In fact, (sadly), some ways to expose properties actually require to use get_property_list() :p Example: https://github.com/Zylann/godot_heightmap_plugin/blob/master/addons/zylann.hterrain/hterrain.gd#L135
Just wanted to precise this in case you expected those kinds of properties to be in results or just the "pre-declared" ones.

@willnationsdev
Copy link
Contributor Author

No, I was specifically referring to only the properties defined by the script, not associated with the underlying class (which would require the instance). Theoretically though, if I only want information about what the script provides, and I have the resource loaded, then I shouldn't need anything else to get that information.

@akien-mga akien-mga merged commit a00a9e8 into godotengine:master Sep 3, 2019
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants