Hello, Hmm. The setMethod is checked for null for some time now. It may be that you are using an older version? :). Thanks!
Actually, you’re right, I was using an older version.
I just updated Node Canvas in my project (via Package Manager), and there were code updates, including the setMethod null check.
The odd thing is that, based on my project’s version control, I had updated Node Canvas to v3.2.5 circa July 2022.
But the latest version on the Asset Store (from August 29, 2022) is also numbered v3.2.5? That’s what made me confused earlier.
Anyway, thanks for giving me the hint to upgrade Node Canvas. 😀
Hello, Hmm. The setMethod is checked for null for some time now. It may be that you are using an older version? :). Thanks!
I don’t think that’s the case at all, both regarding setMethod being checked for null, and me using an older version of Node Canvas.
As mentioned in a few posts above, I’m using NodeCanvas v3.2.5, the latest version available on Asset Store.
Stepping through with the debugger, setMethod is null here (Variable.cs) line 280:
if ( prop.CanWrite ) {
try { setter = setMethod.RTCreateDelegate<Action<T>>(instance); } //JIT
catch { setter = (o) => { setMethod.Invoke(instance, ReflectionTools.SingleTempArgsArray(o)); }; } //AOT
if ( callSetter ) { setter(_value); }
} else {
setter = (o) => { Logger.LogError(string.Format(“You tried to Set a Property Bound Variable ‘{0}’, but the Bound Property ‘{1}’ is Read Only!”, name, _propertyPath), LogTag.VARIABLE, go); };
}
I’m having this exact issue reported by ccfoo242 (setMethod being null in line 280 from Variable.cs), in specific cases like the one from my post above (trying to set a property-bound variable that had “protected set”).
Actually, in my case, the setMethod null reference exception still helped me locate an error in my logic.
I was trying to set a property bound variable that had the following getter/setter:
1 |
get; protected set; |
In this case, I had to remove the “protected” keyword, for NodeCanvas to be able to set the variable correctly.
I still think a null check and extra LogError for that setMethod inside the catch {} block would be helpful, to hint to the user about potential cases like mine above.
Do you have any ETA on when this Variable.cs setMethod null check will be added?
I’m having null reference exceptions because of this same issue, on NodeCanvas v3.2.5.
Thank you for adding the SetObjectEnabled action task! It worked perfectly 😀
Sorry for the necro, but I wanted to ask, if it would be possible to add a SetEnabled action task (where you set a component reference and its desired .enabled value), in a future NodeCanvas version?
I think that would be more intuitive than the SetProperty method, simpler to use, just like the SetActive action task for GameObjects.
Thank you for updating the documentation!
I managed to implement my attribute drawer correctly now 😀
Okay, the OnErrorCheck override worked perfectly 🙂
Thanks for adding my feature request!