How to create custom errors when [RequiredField] is not enough?

Deadcow

New member
I made a custom type with an ObjectDrawer to serialize references in the scene and want to add the error sign if the referenced object is not accessible anymore.
I found a way to toggle it via task.NodeData.NodeDesigner.HasError, but it does not much sense when accessible from ObjectDrawer's OnGUI, I need the error check to happen without Action selection.

I found no way to error check in custom Action either. And no suitable callbacks for the error-check phase also.
Maybe there is a way that I wasn't able to find? 🤔
 
Last edited:
There aren't any error check callbacks. Could you check it within the task constructor? This won't require the editor.
 
In my SetTarget action, I tried to access NodeDesigner, but it was null during construction and after a short delay.
I tried to do it like this:
Code:
#if UNITY_EDITOR
public SetTarget()
{
   UnityEditor.EditorApplication.delayCall += () 
     => ((BehaviorDesigner.Editor.NodeDesigner)NodeData.NodeDesigner).HasError = true;
}
#endif

How could I create or initialize the NodeDesigner properly?
 
The NodeDesigner object is only initialized when the behavior tree is loaded in the editor. The error checker is editor only, if it doesn't exist you could output a LogError message.
 
I figured out, that NodeDesigner is initialized 2 frames after the Task constructor (if it is created when Behavior Designer is displaying it, of course).
That's why it is still not set after the first "delayedCall". With a continuous check, I was able to achieve dynamic error-checking
In case anyone would look for a solution, here it is.

Currently trying to find the way to reliably add error data in ErrorDetails of BehaviorDesignerWindow
 
Back
Top