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
  • DataObjectDropdown Attribute
  • General
  1. FAQ

Databrain - FAQ

DataObjectDropdown Attribute

Can I add a DataObjectDropdown attribute inside a DataObject class to reference other DataObjects inside of the Databrain editor?

Yes absolutely. Simply add the [DataObjectDropdown] attribute without any additional parameter. The library will be found automatically.

Can I use a return method instead of a name as the DataLibrary parameter in the DataObjectDropdown attribute?

Yes, you can! This is a great way when you have a singleton class which holds the DataLibrary in your scene. Here's an example code:

// Simply add the name of the DataLibrary returning method
[DataObjectDropdown(nameof(GetLibrary))]
public MyDataObject myDataObject;

public DataLibrary GetLibrary()
{
    return DataManager.Instance.data;
}

This would require a singleton of type DataManager which looks like this: Please note that you should also add the OnValidate method so that the DataLibrary will be found in the editor (not only at runtime).

// SINGLETON Example
// Please make sure to add the OnValidate method like in this example
// to your singleton class.
public class DataManager : MonoBehaviour
{
    public static DataManager Instance { get; private set; }

    public DataLibrary data;
    
    
    private void OnValidate()
    {
        Instance = this;
    }

    public void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(this);
            return;
        }

        Instance = this;
    }
}
Does the DataObjectDropdown support sub-types?

Yes, simply set the includeSubtypes parameter to true:

[DataObjectDropdown(includeSubtypes: true)]
public MyDataObject dataObject;
My DataObjectDropdown doesn't show up. All I see is a No GUI Implemented label.

This mostly happens because of another third-party asset installed. Please check out following page for a possible fix.

No GUI Implemented - FIX

General

My properties (get; set;) won't show up in the DatabrainEditor

The reason for this is that when you declare a property like public int Speed {get; set;} a hidden backing field is generated by the compiler which is where the value is actually stored, this field is private and so will not be serialized automatically by Unity's serializer. C# 7.3 added Auto-implemented property field-targeted attributes, allowing you to do this:

[field:SerializeField] public int Speed {get; set;}

This will apply the SerializeField attribute to the hidden generated field and Unity should serialize it normally.

How can I enable Odin Inspector attribute support inside of the Databrain editor?

Simply use the [UseOdinInspector] attribute to your DataObject class.

PreviousDataObjectNextEvents

Last updated 10 months ago