Click or drag to resize

Basic Object handling

When you export your data from articy:draft to your Unity project, the articy importer plugin will populate a database with your data and create C# classes and properties for everything. This article will cover how to access that data.

This topic contains the following sections:

Simple Object Access

The most basic way to access an articy object is to query it directly from the database:

C#
ArticyObject manfred1 = ArticyDatabase.GetObject("Chr_Manfred"); // get the object by its technical name
We use the ArticyDatabase and ask it for an object with the Technical name "Chr_Manfred" using one of the many GetObject methods. The returned object is an ArticyObject which is the base type of all objects in the database.

You can either cast the ArticyObject manually, or ask the GetObject method to return a specific type:

C#
Player_Character manfred2 = ArticyDatabase.GetObject<Player_Character>("Chr_Manfred"); // get the object by its technical name and with its proper type
In this example we supplied the template name Player_Character which will automatically cast the returned object to this type. The variable manfred2 now contains a reference to our entity with the type Player_Character and we can access all its properties
C#
Debug.Log( manfred2.Text ); // we can access all exported properties
manfred2.DisplayName = "Advanced Manfred 2.0"; // and ofc we can set properties

The Technical Name is not the only way to query the database for an object. Another one is to use the unique object id every articy object has:

C#
var manfred3 = ArticyDatabase.GetObject(0x1000001000010C6);    // this is the same as below but in hexadecimal notation
var manfred4 = ArticyDatabase.GetObject(72057598332899526);    // this is basically the same as above just in decimal notation
Note how you can write hexadecimal (as displayed in articy:draft) or in decimal, shown when you would print the id to the log or store it in an int.
Note Note

The plugin contains methods to convert the id of an object into its hexadecimal string notation and vice versa. See ToHex(Int64)

Articy doesn’t require Technical Names to be unique. In fact, it can be useful to assign the same name to multiple objects and use it to get all objects with the same Technical Name.

C#
List<ArticyObject> allManfreds = ArticyDatabase.GetObjects("Chr_Manfred");

To get a specific object in that case use GetObject(id) with the unique id instead.

Note Note

Due to the high potential for errors it is not recommended to deliberately assign the same Technical Name to multiple objects inside articy:draft. To group certain objects together, rather use custom templates and query the objects by their type. See Basic Object handling on how to query objects by type.

Advanced Object Access

Sometimes you want all objects of a specified type. The ArticyDatabase contains the function GetAllOfTypeTObject for this. you can specify any of the standard articy object types, or your own templates when calling it:

C#
var allmyItems = ArticyDatabase.GetAllOfType<Item>();

To further filter the list of returned items you can also use LINQ to specify additional conditions. Please see the LINQ documentation by Microsoft on how to write LINQ statements. The example below selects all objects of type item that have by only selecting ones with a gold cost greater than 100.

C#
var allExpensiveItems = ArticyDatabase.GetAllOfType<Item>().Where( aItem => aItem.Template.Item.GoldCost > 100).ToList();

See Also