Reply To: Get custom Property/Field

Forums 💬 NodeCanvas 🗨️ General Discussion Get custom Property/Field Reply To: Get custom Property/Field

#15002
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!