-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
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
Mono: SetScript leaves initial node references in weird invalid state #39561
Comments
Is this explained by #31994 (comment) ?
(I happened to see your issue and the old one together in a random issue search I was doing, and figured I should try to help connect the dots if I can. 🙂 Sorry if this isn't helpful.) |
I assumed that it worked like that, yes. The problem (what both issues are similar in) is that this goes agains conventions and expectations. In unity, testing myObj == null (they override ==) would atleast return true if something happened to the unmanaged side and one could work with this, but godot doesn't have this and just 'lies' about the object not being null, or having magically changed type - the second is what my issue is about which is something that's not even possible in c#/.net by default. Only by accessing the object then it actually throws an exception. |
I have this problem now .. and feels like this could be solved by "proxy object" pattern. reference "proxy", that calls real object, if object is disposed (replaced by new one). The proxy will try to call new one or look for the same object with same Id. |
The managed objects are, in a way, already proxies. Afaik they mainly rely on an object handle to call into the native side. But the problem is that with a new script the type of the object changes (and with that its members etc.), so proxying with that pattern won't work (and actually changing the type of an object to an unrelated one is not possible in c#/.net as far as i know). But it could make sense to have a |
Well assigning script to node is doing the same thing. So returning new object wont work with [Export]. |
Godot version:
3.2.1.stable.mono.official
Issue description:
Using SetScript on a node, earlier references to that node still have the old type, but newly retrieved referenes to the same node are of the new type. When trying to access node members from the initial ref that are not of the custom type (engine internal) an exception is thrown, but members from the initial custom type on the same ref can still be accessed.
Steps to reproduce:
Run the attached project and examine the output log and
NodeTester.cs
Minimal reproduction project:
TypeWeirdness.zip
The text was updated successfully, but these errors were encountered: