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:
ArticyObject manfred1 = ArticyDatabase.GetObject("Chr_Manfred"); // get the object by its technical nameYou can either cast the ArticyObject manually, or ask the GetObject method to return a specific type:
Player_Character manfred2 = ArticyDatabase.GetObject<Player_Character>("Chr_Manfred"); // get the object by its technical name and with its proper typeDebug.Log( manfred2.Text ); // we can access all exported properties
manfred2.DisplayName = "Advanced Manfred 2.0"; // and ofc we can set propertiesThe 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:
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 notationArticy 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.
List<ArticyObject> allManfreds = ArticyDatabase.GetObjects("Chr_Manfred");To get a specific object in that case use GetObject(id) with the unique id instead.
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:
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.
var allExpensiveItems = ArticyDatabase.GetAllOfType<Item>().Where( aItem => aItem.Template.Item.GoldCost > 100).ToList();