Inheritance and binding

NodeCanvas Forums Support Inheritance and binding

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12352
    jschanhals
    Participant

    I am finding that binding of properties and methods is not doing what I would have thought when using inherited classes with virtual/overridden methods/properties. Given the classes below:

    When binding to TestChild1.myName and using a LogText (or even a LogVariable) action node, the value ‘TestBase1’ is logged rather than the expected ‘TestChild1’. Similar behavior when calling a method – the base’s method is called and not the overridden one.

    Is there something I need to do to get the overridden method/property called? Or is this a problem with NodeCanvas implementation?

    Attached is a sample scene that demonstrates this issue.

    Jeff

    Attachments:
    You must be logged in to view attached files.
    #12361
    Gavalakis
    Keymaster

    Hello and sorry for the late reply due to summer vacation.

    This is a unintended behavior that I wasn’t aware of. Thanks for reporting this problem.
    To fix this quickly, please open up ReflectionTools.cs file, fine and replace method RTCreateDelegate with the following code:

    The difference here is that if re-fetch the method type from the true type of the instance if any before creating the delegate and as such, the delegate will correctly call the child method/property from there-on.

    Please let me know if making this change also works for you.

    Thanks again for the error report.

    Join us on Discord: https://discord.gg/97q2Rjh

    #12364
    jschanhals
    Participant

    Thanks for the updated code. For the test scene that I had attached, this fixes the issue. I will validate it further in our main project.

    #12377
    Gavalakis
    Keymaster

    Thanks for the follow up.
    If you find any problems with this, please let me know.

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.