I have modified your code to work as I expect you want it to:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
usingNodeCanvas.Framework;
usingParadoxNotion.Design;
usingUnityEngine;
namespaceGame.Tasks.Conditions
{
[Name("On Variable Changed")]
[Category("✫ Blackboard")]
publicclassBBVariableChanged:ConditionTask
{
[BlackboardOnly]
publicBBParameter<object>BBVar;
protectedoverridestringinfo{
get{returnBBVar+" Changed.";}
}
protectedoverridestringOnInit(){
if(BBVar.isNone){
return"Blackboard Variable not set.";
}
returnnull;
}
protectedoverridevoidOnEnable(){
BBVar.varRef.onValueChanged+=OnValueChanged;
}
protectedoverridevoidOnDisable(){
BBVar.varRef.onValueChanged-=OnValueChanged;
}
protectedoverrideboolOnCheck(){
returnfalse;
}
privatevoidOnValueChanged(stringarg1,objectarg2){
YieldReturn(true);
}
}
}
Some notes:
– Use OnInit only for initialization similar to Unity’s Awake.
– Use OnEnable and OnDisable to subscribe and unsubscribe.
– You don’t have to call base implementation of methods.
– A BBParameter will never be null. Use .isNone to determine if the front-end user has selected a variable or not.
Let me know if that works for you.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.