Get custom Property/Field

NodeCanvas Forums General Discussion Get custom Property/Field

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9285

    I’ve created a custom BBVariable for my project and it works perfect. I’m able to create a var inside Blackboard etc. What I’m struggling with is GetField/GetProperty/ExecuteFunction that operates on this datatype. For some reason UI doesn’t let me select functions/properties/fields that return custom value. How do I fix that? I can of course write my own functions for retrieval, but there should be an easier way to do that.

    #9287
    Gavalakis
    Keymaster

    Hey,

    Yeah, having read your other post first, I really understand the reason you’d like this, since it will just save you from that task you posted which simply gets the EcoAbilities property(or field) from a component and saves it into your BBEcoAbilities.

    So the reason that these don’t show is because the UI filters a specific set of types to show which are defined into the BBVariableSet class which holds the different BBVariables to use depending on the type of the property/field or method parameters/return type.
    The reason for that is that if all types -even unsupported- were to show up and you select it, then it will be unusable thus no reason to show it.

    So, in other words you must add your custom BBVars into the BBVariableSet. The only way I can think of without modifying the source code is to use partial classes. So here is the way of doing this if you want to do this now:

    1. In BBVariables.cs line #422, mark the BBVariableSet class as partial:
    public partial class BBVariableSet{…

    2. Add a partial method within it:
    partial void AddExtraBBVariablesToSet(List bbVarSet);

    3. Change to first private property you see in there named ‘allVariables’ to look like this:

    4. That’s prety much it for the hard part :). Now you have to add your own types. Create a new file with a partial BBVariableSet like for example:

    Note that this have to be in the NodeCanvas.Variables namespace

    Your custom variable types will now show up in the UI and be usable like the rest in all ‘Script Control’ Tasks
    Let me know if this works for you, or if you possibly have an alternative solution.

    Cheers!

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

    #9286

    Great!!! Thank you for such a quick response!

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