Blackboard Data Provider
BlackboardDataProvider
is an abstract class available in the Unity Plugin for Grail that helps insert data from a scene into a blackboard.
The excerpt below shows the public interface:
public abstract class BlackboardDataProvider : MonoBehaviour
{
[FormerlySerializedAs("provideOnAwake"), SerializeField] private bool provideToEntityOnAwake = true;
public abstract void ProvideBlackboardData(Blackboard blackboard);
//...the rest of the class body
}
Implement the ProvideBlackboardData
method to insert selected data into a blackboard.
For example:
public class MyCustomProvider : BlackboardDataProvider
{
public override void ProvideBlackboardData(Blackboard blackboard)
{
blackboard.SetValue(AIConsts.MyObjectKeyName, FindObjectOfType<MyObjectToStore>());
}
}
Attach this script to a game object in the scene or to a prefab. By default, the ProvideBlackboardData
function is executed when the object is awakened.
Remember that BlackboardDataProvider inherits from MonoBehaviour , allowing you to use its methods to control when data is provided. For instance, you can use its Update() method to determine when the data should be inserted into the blackboard.
|
Example Scene
You can explore a simple scene available at: Assets/Plugins/Grail/Examples/Scenes/ExampleScene.

In this scene, there are two custom actors ("Collectors"), each with an AIEntity component attached, and both have scripts that inherit from BlackboardDataProvider
. The CollectorProvider.cs
script, for example, is responsible for putting the Collector object onto the blackboard.
Notice the checkbox "Provide To Entity On Awake", which is set to true by default. If you set it to false, make sure to use MonoBehaviour methods to determine when data should be provided to the blackboard.