Getter and Setter extension

NodeCanvas Forums General Discussion Getter and Setter extension

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12433
    kinerius
    Participant

    Hi, i have been using node canvas for some time and im having a very good time with it.
    Right now i need to reduce the ammount of nodes to increase the speed of productivity for my team and i need to do some stuff like automatic casting for some custom class types to Vector3 or Transform but the only way to do this right now is by extending the GetGetConverter/GetSetConverter methods from Variable class.
    I dont want to modify node canvas classes because the changes will dissapear when updating to the next version (and there are chances that i wont be the one that will be updating it).

    So my questions are:
    – Is there any other way of doing this?
    – Can we get this feature on the future?
    – Can i help implement it?

    Greetings!

    #12441
    Gavalakis
    Keymaster

    Hello.

    Sorry for the late reply due to summer vacation and thank you. I am glad you enjoy NodeCanvas.
    Unfortunately right now there is no easy way to implement custom “auto conversions”. One solution to make this more modular that I am thinking, is to make the Variable class a partial class along with a partial method which one can implement to provide further conversions.

    Let me know what you think.
    Thanks!

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

    #12450
    kinerius
    Participant

    Hey, thanks for the reply!

    Making Variable a partial class sounds like a good idea for something that specific, sadly partial methods must return a void so some additional work will be needed.

    #12458
    Gavalakis
    Keymaster

    Hey,
    You are welcome 🙂
    That is true. I have just added this in the roadmap and will see how it can best be implemented. Making the class partial is one possible solution, but I might come up with something better 🙂

    Thanks again for the suggestion!

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

    #12481
    kinerius
    Participant

    Good, im looking forward to it. Thanks for the support 🙂

    #13809
    psykaw
    Participant

    HeyGavalakis,

    I need getter/setter for my custom types so I implement a simple way to add it.
    Add this lines at the beginning of TypeConverter.cs:

    And in public static Func<object, object> Get(Type fromType, Type toType) method:

    Now, in your custom classes you can add this to auto convert your custom types:

    Sounds good to you ?

    #13815
    Gavalakis
    Keymaster

    Hey Psykaw,
    This is definetely a good solution 🙂
    I’ve just added this in for the next version.
    Thanks!

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

    #13817
    timv
    Participant

    Hi kinerius, are you using revision control like Git? If so, you could make a separate branch of your code that has the unaltered NodeCanvas. Every time an official update is released, you update this branch and then merge it to your master branch. This way your changes and the official changes can be merged. Sometimes it’s a bit hard to get everything right though if many files get moved around between versions, but in general I’m quite happy with this approach.

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