Databrain Documentation
databrain.ccDiscord
  • Welcome
  • Installation / Update
  • Interface
  • DataObject Property Drawer
    • No GUI Implemented - FIX
  • Getting started
  • Guides
    • Add data objects
    • Add data objects at runtime
    • Get initial data
    • Get/Set runtime data
    • Serialize DataObjects
    • Runtime Save & Load
    • Use custom serializer
    • Import
    • Search
    • Custom GUI
    • Custom GUI with Odin Inspector
    • Hierarchy Template
  • Separate DataObjects
  • Using Version Control
  • Attributes
    • DataObject attributes
    • Field attributes
  • API
    • DataLibrary
    • DataObject
  • FAQ
    • Databrain - FAQ
  • Add-ons
    • Events
    • Blackboard
    • Logic
      • Interface
      • Create Graph
      • Execute graph
      • Control flow execution in groups
      • Custom Nodes
        • Asynchronous execution
        • Node Attributes
      • Scene Components
      • Graph Events
      • Finite State Machine
        • Create custom Actions
        • Examples
        • State Machine Nodes
    • Stats
      • Achievements
      • Modifiers
      • Values
      • Progressions
      • Components
      • Nodes
    • Progress
      • Progress Settings
      • Progress Graph
      • Progress Resources
      • Runtime UI Setup
      • API
        • ProgressController
    • Techtree (LEGACY)
      • Techtree Manager
      • Techtree
      • TechtreeResource
      • Techtree UIBuilder
        • Custom Techtree Node Button
        • Tooltip
      • API
    • Localization
      • Localization Manager
      • Localization
      • Examples
      • Components
      • Import
      • API
    • Inventory
      • Getting started
      • Demo
      • Data setup
        • Inventories
        • Slot IDs
        • Items
          • Blueprints
          • Item rarities
        • Money
        • Loot tables
        • Events
      • Runtime UI
        • Setup
    • Dialogue
      • Getting Started
        • Demo
      • Dialogue runtime setup
      • Actors
        • Emotions
      • Localization
      • Audio
      • Animation
      • Variables
      • Custom theme
      • Import
      • Nodes
      • API
        • DialogueController
        • IDialogueUIControl
  • Changelog
    • Databrain - Changelog
      • 1.4.0
      • 1.3.2
      • 1.3.1
      • 1.3.0
      • 1.2.0
      • 1.1.0
      • 1.0.10
      • 1.0.9
      • 1.0.8
      • 1.0.7
      • <= 1.0.6
Powered by GitBook
On this page
  • Add Types
  • Value
  • On Value Changed
  1. Add-ons

Blackboard

The blackboard add-on is included by default in the Databrain package

The blackboard add-on supports the following types by default:

  • Boolean

  • Float

  • Float List

  • Integer

  • Integer List

  • String

  • Vector2

  • Vector3

  • Prefab (GameObject)

Add Types

You can easily add additional types by inheriting from BlackboardGenericVariable<T>

public class BooleanVariable : BlackboardGenericVariable<bool> {}

Custom enum:

public class EnumVariable : BlackboardGenericVariable<MyEnum>
{
    public enum MyEnum
    {
        A = 0,
        B = 1,
        C = 2
    }
}

Value

When getting the value of a blackboard variable you will automatically receive the runtime value. You don't have to call GetRuntimeDataObject() on the blackboard variable object.

Example code:

public class BlackboardExample : MonoBehaviour
{
    public DataLibrary data;

    [DataObjectDropdown("data")]
    public FloatVariable floatValue;
    
    public void Start()
    {
        data.RegisterInitializationCallback(Ready);
    }
    
    void Ready()
    {
        // Modify data directly (changes the runtime value)
        floatValue.Value += Time.deltaTime;
        
        // Get initial value
        var _initialData = floatValue.GetInitialDataObject();
        
    }
}

On Value Changed

You can assign a blackboard event to a blackboard variable which gets called when the value has been changed. See the following example:

public class BlackboardExample : MonoBehaviour
{
    public DataLibrary data;

    [DataObjectDropdown("data")]
    public FloatVariable floatValue;
    
    public void Start()
    {
        data.RegisterInitializationCallback(Ready);
    }
    
    void Ready()
    {
        floatValue.onValueChanged.RegisterListener(FloatChanged);
    }
    
    void FloatChanged(BlackboardVariable _variable)
    {
        // Float value has been changed
        var _value = (_variable as FloatVariable).Value;
        Debug.Log("New value: " + _value);
    }
}
PreviousEventsNextLogic

Last updated 1 year ago