Forums › 💬 NodeCanvas › 🗨️ General Discussion › Get custom Property/Field › Reply To: Get custom Property/Field
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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
private List<BBVariable> allVariables{ get { var bbVarSet = new List<BBVariable>{ boolValue, floatValue, intValue, stringValue, vector2Value, vectorValue, quaternionValue, colorValue, curveValue, goValue, componentValue, unityObjectValue, enumValue }; AddExtraBBVariablesToSet(bbVarSet); return bbVarSet; } } |
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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
using UnityEngine; using System.Collections.Generic; namespace NodeCanvas.Variables{ partial class BBVariableSet { [SerializeField] private BBEcoNPC ecoNPC = new BBEcoNPC(); [SerializeField] private BBEcoNPCAbility ecoNPCAbility = new BBEcoNPCAbility(); [SerializeField] private BBEcoNPCAbilityList ecoNPCAbilityList = new BBEcoNPCAbilityList(); partial void AddExtraBBVariablesToSet(List<BBVariable> bbVarSet){ bbVarSet.Add(ecoNPC); bbVarSet.Add(ecoNPCAbility); bbVarSet.Add(ecoNPCAbilityList); } } } |
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!
