08 Unity Attributes

This example shows you how to use unity attributes in a blackboard.

These files can be found in the /Examples/[example] and /Blackboards/Examples folders.

UnityAttributeBlackboard.cs

using System;
using CrashKonijn.Blackboard.Contracts;
using UnityEngine;

namespace CrashKonijn.BlackboardPro.Blackboards.Examples
{
    public partial class UnityAttributeBlackboard : BlackboardBehaviour
    {
        // You can use unity attributes to show extra information in the editor
        [Header("Basic Info")]
        private string playerName;
        
        // The blackboard is rendered in the following order:
        // 1. Fields
        // 2. Lists
        // 3. Computed properties
        // This means that this header and field be lower in the blackboard
        [Header("Arrays/Lists")]
        private int[] someArray;
        
        [Space]
        private string spacedValue;

        [HideInInspector]
        private float hiddenValue;
        
        // These attributes won't work
        [Tooltip("The player's health points.")]
        [Range(0, 100)]
        private int health;
    }
}

Last updated