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

Use Mono script metadata also for class->script mapping #27218

Closed
wants to merge 1 commit into from
Closed

Use Mono script metadata also for class->script mapping #27218

wants to merge 1 commit into from

Conversation

shartte
Copy link
Contributor

@shartte shartte commented Mar 19, 2019

This fixes #27095 by enabling the appropriate CSharpScript's to be reused when the mono module attempts to get a CSharpScript for a given Mono class.
This primarily occurs when one does:

in "MyNodeSubclass.cs":
class MyNodeSubclass : Node { ... }

When new MyNodeSubclass() is used, Godot will now correctly assign the script "res://MyNodeSubclass.cs" to the newly created Node, instead of assigning a script with an empty path (which will not be saved to the Scene).

The script metadata is now kept in-memory in two Map's to enable bi-directional lookup.

The only caveat is that during _update_exports, we need to pre-allocate the native Node before we call the user's constructor. Otherwise the default constructor would call back into C++ to create the native Node, which would trigger a call to ResourceLoader::load for the script that is in the process of being created. This would simply fail. If the managed object is already associated with a native object before the constructor is called, this doesn't happen.

@shartte shartte requested a review from neikeq as a code owner March 19, 2019 01:49
@Chaosus Chaosus added this to the 3.2 milestone Mar 19, 2019
@akien-mga
Copy link
Member

CC @neikeq

@akien-mga
Copy link
Member

What's the status on this PR?

@akien-mga
Copy link
Member

Ping.

@neikeq neikeq self-assigned this Aug 23, 2019
@shartte shartte closed this Aug 23, 2019
@shartte shartte deleted the fix-mono-class-mapping branch August 23, 2019 20:49
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.

Creating and Saving Mono Nodes Fails
4 participants