### Example LDtkPostprocessor Source: https://github.com/cammin/ldtktounity/blob/master/DocFX/documentation/Topics/topic_CustomImporting.md This example demonstrates how to create a custom LDtkPostprocessor to hook into the project import pipeline. It logs the project name and iterates through worlds, levels, layers, and entities to access tile and intGrid data. ```csharp using LDtkUnity; using LDtkUnity.Editor; using UnityEngine; public class ExamplePostprocessor : LDtkPostprocessor { protected override void OnPostprocessProject(GameObject root) { Debug.Log($"Post process LDtk project: {root.name}"); LDtkComponentProject project = root.GetComponent(); foreach (LDtkComponentWorld world in project.Worlds) { foreach (LDtkComponentLevel level in world.Levels) { foreach (LDtkComponentLayer layer in level.LayerInstances) { LDtkComponentLayerTilesetTiles tiles = layer.GridTiles; //access tile data! LDtkComponentLayerIntGridValues intGrid = layer.IntGrid; //access intGrid data! foreach (LDtkComponentEntity entity in layer.EntityInstances) { //access entities! } } } } } protected override void OnPostprocessLevel(GameObject root, LdtkJson projectJson) { Debug.Log($"Post process LDtk level: {root.name}"); LDtkComponentLevel level = root.GetComponent(); foreach (LDtkComponentLayer layer in level.LayerInstances) { //iterate upon layers } } } ``` -------------------------------- ### Example LDtkPostprocessor Implementation Source: https://github.com/cammin/ldtktounity/blob/master/docs/documentation/Topics/topic_CustomImporting.html This example demonstrates how to create a custom postprocessor by inheriting from LDtkPostprocessor and overriding OnPostprocessProject and OnPostprocessLevel. It shows how to access and iterate through project, world, level, layer, tile, intGrid, and entity data after import. ```csharp using LDtkUnity; using LDtkUnity.Editor; using UnityEngine; public class ExamplePostprocessor : LDtkPostprocessor { protected override void OnPostprocessProject(GameObject root) { Debug.Log($ ``` -------------------------------- ### LDtk Custom Data for Animation Start Time Source: https://github.com/cammin/ldtktounity/blob/master/docs/documentation/Topics/topic_AnimatedTiles.html Use the 'animationStartTime' keyword to define the initial animation time. A single value sets a fixed start time, while two values create a random range. ```text animationStartTime 0.5 ``` ```text animationStartTime 0, 2.5 ``` -------------------------------- ### Implement ILDtkImportedFields Interface Source: https://github.com/cammin/ldtktounity/blob/master/DocFX/documentation/Topics/topic_Fields.md Demonstrates how to implement the ILDtkImportedFields interface in a custom Unity script to retrieve field values during the LDtk import process. This example shows how to get an array of enums and an integer field. ```csharp public class Player : MonoBehaviour, ILDtkImportedFields { public Item[] items; public int health; public void OnLDtkImportFields(LDtkFields fields) { items = fields.GetEnumArray("inventory"); health = fields.GetInt("HP"); } } ``` -------------------------------- ### Example Custom Import Fields Component Source: https://github.com/cammin/ldtktounity/blob/master/DocFX/documentation/Topics/topic_CustomImporting.md This example demonstrates how to use the ILDtkImportedFields interface to set TextMesh properties based on LDtk entity fields during import. Ensure the LDtk entity has 'text' (string) and 'color' (color) fields. ```csharp using LDtkUnity; using UnityEngine; public class ExampleLabel : MonoBehaviour, ILDtkImportedFields { [SerializeField] private TextMesh _textMesh; //This class inherits from ILDtkImportedFields, which implements OnLDtkImportedFields. //This LDtk entity has a string field named "text" and a color field named "color". public void OnLDtkImportFields(LDtkFields fields) { _textMesh.text = fields.GetString("text"); _textMesh.color = fields.GetColor("color"); } } ``` -------------------------------- ### StartUp Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkIntGridTile.html This method is an inherited method from TileBase for StartUp. It is called when a tile is initialized and can be used for setup operations. ```APIDOC ## StartUp(Vector3Int, ITilemap, GameObject) ### Description This TileBase inherited method for StartUp. ### Method (Implicitly called by the Tilemap system) ### Parameters #### Path Parameters - **position** (UnityEngine.Vector3Int) - Description: Position on the tilemap. - **tilemap** (UnityEngine.Tilemaps.ITilemap) - Description: The tilemap. - **go** (UnityEngine.GameObject) - Description: The instantiated GameObject. ### Returns #### Success Response - **System.Boolean** - Always true. ``` -------------------------------- ### Add LDtkUnity Package via OpenUPM CLI Source: https://github.com/cammin/ldtktounity/blob/master/DocFX/documentation/Installation/topic_Install.md Use this command in your Unity project's root directory to install the LDtkUnity package using the OpenUPM CLI. ```bash openupm add com.cammin.ldtkunity ``` -------------------------------- ### LDtk Custom Data for Animation Start Frame Source: https://github.com/cammin/ldtktounity/blob/master/docs/documentation/Topics/topic_AnimatedTiles.html Use the 'animationStartFrame' keyword to set the initial animation frame. A single value provides a fixed frame, and two values define a random range. This setting overrides 'animationStartTime'. ```text animationStartFrame 2 ``` ```text animationStartFrame 0, 3 ``` -------------------------------- ### LDtkProjectFile.FromJson Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkProjectFile.html Gets the deserialized project root from the LDtk project file. This method allows access to the entire LDtk project's JSON data. ```APIDOC ## FromJson ### Description Gets the deserialized project root. ### Method N/A (Property Getter) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response - **LdtkJson** (LdtkJson) - The deserialized project root object. ``` -------------------------------- ### GetFloatArray(String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a float field's values. ```APIDOC ## GetFloatArray(String identifier) ### Description Gets a float field's values. ### Signature `System.Single[] GetFloatArray(System.String identifier)` ### Parameters - **identifier** (System.String) - The field instance's identifier. Case sensitive. ``` -------------------------------- ### GetFloat(String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a float field's value. ```APIDOC ## GetFloat(String identifier) ### Description Gets a float field's value. ### Signature `System.Single GetFloat(System.String identifier)` ### Parameters - **identifier** (System.String) - The field instance's identifier. Case sensitive. ### Returns **System.Single** - The field's value. If the field doesn't exist, then returns a default value type. ``` -------------------------------- ### LDtkTableOfContentsEntry Constructor Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkTableOfContentsEntry.html Initializes a new instance of the LDtkTableOfContentsEntry class with the specified LdtkTableOfContentEntry data. ```APIDOC ## LDtkTableOfContentsEntry(LdtkTableOfContentEntry) ### Description Initializes a new instance of the LDtkTableOfContentsEntry class. ### Parameters #### Path Parameters - **entry** (LdtkTableOfContentEntry) - Required - The LdtkTableOfContentEntry object to initialize with. ``` -------------------------------- ### LDtkArtifactAssets.Backgrounds Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkArtifactAssets.html Gets all the background sprite assets used by LDtkArtifactAssets. ```APIDOC ## Property: LDtkArtifactAssets.Backgrounds ### Description Gets all the background sprite assets used. ### Type System.Collections.Generic.List ``` -------------------------------- ### TryGetFloat(String, out Single) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a float field's value. ```APIDOC ## TryGetFloat(String, out Single) ### Description Gets a float field's value. ### Method Not specified (likely a method call) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **identifier** (System.String) - The field instance's identifier. Case sensitive. - **value** (System.Single) - The field's value. ### Returns #### Success Response - **System.Boolean** - If the field exists. ``` -------------------------------- ### GetFilePathArray(String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a file path field's values. ```APIDOC ## GetFilePathArray(String identifier) ### Description Gets a file path field's values. ### Signature `System.String[] GetFilePathArray(System.String identifier)` ### Parameters - **identifier** (System.String) - The field instance's identifier. Case sensitive. ### Returns **System.String[]** - The field's value. If the field doesn't exist, then returns a default value type. ``` -------------------------------- ### OnPreprocessProject Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.Editor.LDtkPreprocessor.html Called before the project hierarchy is created. This method is intended for operations on project files, not separate level files. ```APIDOC ## OnPreprocessProject(LdtkJson, String) ### Description Use to perform operations before the project hierarchy is created. This is only called for project files, not separate level files. ### Parameters #### Path Parameters - **projectJson** (LdtkJson) - Required - The project json. - **projectName** (String) - Required - Name of the project file. ``` -------------------------------- ### OnPreprocessLevel Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.Editor.LDtkPreprocessor.html Called before the level hierarchy is created. This method is intended for operations on separate level files, not project files. ```APIDOC ## OnPreprocessLevel(Level, LdtkJson, String) ### Description Use to perform operations before the level hierarchy is created. This is only called for separate level files, not project files. ### Parameters #### Path Parameters - **level** (Level) - Required - The level json. - **projectJson** (LdtkJson) - Required - The project data of this level. - **projectName** (String) - Required - Name of the project file. ``` -------------------------------- ### GetFilePath(String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a file path field's value. ```APIDOC ## GetFilePath(String identifier) ### Description Gets a file path field's value. ### Signature `System.String GetFilePath(System.String identifier)` ### Parameters - **identifier** (System.String) - The field instance's identifier. Case sensitive. ### Returns **System.String** - The field's value. If the field doesn't exist, then returns a default value type. ``` -------------------------------- ### TryGetFilePathArray(String, out String[]) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a file path field's values. ```APIDOC ## TryGetFilePathArray(String, out String[]) ### Description Gets a file path field's values. ### Method Not specified (likely a method call) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **identifier** (System.String) - The field instance's identifier. Case sensitive. - **values** (System.String[]) - The field's values. ### Returns #### Success Response - **System.Boolean** - If the field exists. ``` -------------------------------- ### LdtkTableOfContentEntry Methods Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LdtkTableOfContentEntry.html The LdtkTableOfContentEntry class has the following methods: UnityInstances. ```APIDOC ## Methods #### UnityInstances() ##### Returns Type: [LdtkTocInstanceData](LDtkUnity.LdtkTocInstanceData.html)[] Description: [Description for UnityInstances] ``` -------------------------------- ### TryGetFilePath(String, out String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a file path field's value. ```APIDOC ## TryGetFilePath(String, out String) ### Description Gets a file path field's value. ### Method Not specified (likely a method call) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **identifier** (System.String) - The field instance's identifier. Case sensitive. - **value** (System.String) - The field's value. ### Returns #### Success Response - **System.Boolean** - If the field exists. ``` -------------------------------- ### LayerInstance Properties and Methods Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LayerInstance.html Provides information about the properties and methods available on the LayerInstance class for querying layer details and types. ```APIDOC ## LayerInstance ### Description Represents an instance of a layer within an LDtk level. Provides properties to access layer definition, level information, and methods to determine the layer's type and content. ### Properties #### IsDeadWeight - **Type**: System.Boolean - **Description**: Returns true if this particular layer instance has no populated data. #### IsEntitiesLayer - **Type**: System.Boolean - **Description**: Returns true if this layer contains Entities. #### IsIntGridLayer - **Type**: System.Boolean - **Description**: Returns true if this layer contains IntGrid values. #### IsTilesLayer - **Type**: System.Boolean - **Description**: Returns true if this layer contains Grid tiles. #### LayerDefUid - **Type**: System.Int32 - **Description**: Reference the Layer definition UID. #### LevelId - **Type**: System.Int32 - **Description**: Reference to the UID of the level containing this layer instance. #### LevelReference - **Type**: [Level](LDtkUnity.Level.html) - **Description**: Reference to the level containing this layer instance. Make sure to call [LDtkUidBank](LDtkUnity.LDtkUidBank.html).[CacheUidData(LdtkJson)](LDtkUnity.LDtkUidBank.html#LDtkUnity_LDtkUidBank_CacheUidData_LDtkUnity_LdtkJson_) first! ### Methods (No explicit methods other than the boolean checks are documented in the provided text.) ### Example Usage ```csharp // Assuming 'layerInstance' is an instance of LayerInstance if (layerInstance.IsEntitiesLayer) { // This layer contains entities } if (layerInstance.IsIntGridLayer) { // This layer contains IntGrid values } if (layerInstance.IsTilesLayer) { // This layer contains tiles } if (layerInstance.IsDeadWeight) { // This layer has no populated data } int layerDefinitionId = layerInstance.LayerDefUid; int levelIdentifier = layerInstance.LevelId; // To get the Level reference, ensure data is cached first: // LDtkUidBank.CacheUidData(ldtkJson); // Level level = layerInstance.LevelReference; ``` ``` -------------------------------- ### GetEntry(String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkTableOfContents.html Gets all of the entity references in this table of contents of a specific entity type. ```APIDOC ## GetEntry(String) ### Description Gets all of the entity references in this table of contents of an entity type. ### Method N/A (This is a method signature, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response - **LDtkTableOfContentsEntry** - Description of the entry type returned. #### Response Example N/A ``` -------------------------------- ### LdtkCustomCommand Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LdtkCustomCommand.html This section details the properties available for LdtkCustomCommand, including the command itself and its execution timing. ```APIDOC ## Class LdtkCustomCommand ### Properties #### Command * **Type**: System.String * **Description**: The custom command to be executed. #### When * **Possible values**: `Manual`, `AfterLoad`, `BeforeSave`, `AfterSave` * **Type**: [When](LDtkUnity.When.html) * **Description**: Specifies when the custom command should be triggered during the LDtk to Unity process. ``` -------------------------------- ### LDtkPostprocessor.OnPostprocessProject Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.Editor.LDtkPostprocessor.html Use to perform operations after a project is created. This would primarily be used with a project that does not use separate level files. ```APIDOC ## OnPostprocessProject(GameObject) ### Description Use to perform operations after a project is created. This would primarily be used with a project that does **not** use separate level files. ### Parameters #### Path Parameters - **root** (UnityEngine.GameObject) - Required - The root GameObject of the imported LDtk project. This GameObject has a [LDtkComponentProject](LDtkUnity.LDtkComponentProject.html) component to get the project's json data with GetComponent. ``` -------------------------------- ### TryGetIntArray Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets an int field's values. Returns true if the field exists, false otherwise. ```APIDOC ## TryGetIntArray(String, out Int32[]) ### Description Gets an int field's values. Returns true if the field exists, false otherwise. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Parameters - **identifier** (System.String) - Required - The field instance's identifier. Case sensitive. - **values** (System.Int32[]) - Required - The field's values. ### Returns - **System.Boolean** - If the field exists. ``` -------------------------------- ### LayerInstance Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LayerInstance.html Provides information about various offset and visibility properties of a layer instance in LDtk. ```APIDOC ## LayerInstance Properties This section details the properties of the `LayerInstance` class. ### UnityCellSize * **Type**: `UnityEngine.Vector2Int` * **Description**: Grid-based size of the layer. ### UnityPxOffset * **Type**: `UnityEngine.Vector2Int` * **Description**: Offset in pixels to render this layer, usually (0,0). ### UnityPxTotalOffset * **Type**: `UnityEngine.Vector2Int` * **Description**: Total layer pixel offset, including both instance and definition offsets. ### UnityWorldOffset * **Type**: `UnityEngine.Vector2` * **Description**: Offset in world space to render this layer, usually (0,0). ### UnityWorldTotalOffset * **Type**: `UnityEngine.Vector2` * **Description**: Total layer world-space offset, including both instance and definition offsets. ### Visible * **Type**: `System.Boolean` * **Description**: Layer instance visibility. ``` -------------------------------- ### TryGetInt Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets an int field's value. Returns true if the field exists, false otherwise. ```APIDOC ## TryGetInt(String, out Int32) ### Description Gets an int field's value. Returns true if the field exists, false otherwise. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Parameters - **identifier** (System.String) - Required - The field instance's identifier. Case sensitive. - **value** (System.Int32) - Required - The field's value. ### Returns - **System.Boolean** - If the field exists. ``` -------------------------------- ### TryGetFloatArray Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a float field's values. Returns true if the field exists, false otherwise. ```APIDOC ## TryGetFloatArray(String, out Single[]) ### Description Gets a float field's values. Returns true if the field exists, false otherwise. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Parameters - **identifier** (System.String) - Required - The field instance's identifier. Case sensitive. - **values** (System.Single[]) - Required - The field's values. ### Returns - **System.Boolean** - If the field exists. ``` -------------------------------- ### Defs Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LdtkJson.html A structure that holds all the definitions for the current LDtk project. This includes definitions for layers, entities, tilesets, and other project-specific configurations. ```APIDOC ## Defs ### Description A structure containing all the definitions of this project. ### Type [Definitions](LDtkUnity.Definitions.html) ``` -------------------------------- ### EntityInstance Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.EntityInstance.html Provides details on the properties available for an EntityInstance, including their types and descriptions. ```APIDOC ## EntityInstance Properties ### Description This section details the properties of the `EntityInstance` class, which represents an instance of an entity within an LDtk level. ### Properties #### Iid * **Description**: Unique instance identifier. * **Type**: System.String #### Pivot * **Description**: Pivot coordinates (`[x,y]` format, values are from 0 to 1) of the Entity. * **Type**: System.Single[] #### Px * **Description**: Pixel coordinates (`[x,y]` format) in current level coordinate space. Don't forget optional layer offsets, if they exist! * **Type**: System.Int32[] #### SmartColor * **Description**: The entity "smart" color, guessed from either Entity definition, or one its field instances. * **Type**: System.String #### Tags * **Description**: Array of tags defined in this Entity definition. * **Type**: System.String[] #### Tile * **Description**: Optional TilesetRect used to display this entity (it could either be the default Entity tile, or some tile provided by a field value, like an Enum). * **Type**: LDtkUnity.TilesetRectangle #### UnityGrid * **Description**: Grid-based coordinates. * **Type**: UnityEngine.Vector2Int #### UnityPivot * **Description**: Pivot coordinates in Unity's coordinate system. * **Type**: UnityEngine.Vector2 ``` -------------------------------- ### LDtkComponentLevel Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkComponentLevel.html This component can be used to get certain LDtk information of a level. Accessible from level GameObjects. ```APIDOC ## LDtkComponentLevel Properties This component can be used to get certain LDtk information of a level. Accessible from level GameObjects. ### Properties #### BgColor Type Description `UnityEngine.Color` #### BgPivot Type Description `UnityEngine.Vector2` #### BgPos Type Description `LDtkUnity.LevelBackgroundPosition` #### BgRelPath Type Description `System.String` #### BorderBounds Type Description `UnityEngine.Bounds` The world-space bounds of this level. Useful for getting a level's bounds for a camera, for example. #### BorderRect Type Description `UnityEngine.Rect` The world-space rectangle of this level. Useful for getting a level's bounds for a camera, for example. #### ExternalRelPath Type Description `System.String` ``` -------------------------------- ### UnityPxSize Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.Level.html Represents the size of the level in pixels. ```APIDOC ## UnityPxSize ### Description Size of the level in pixels ### Type UnityEngine.Vector2Int ``` -------------------------------- ### LDtkComponentLayer Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkComponentLayer.html This component can be used to get certain LDtk information of a layer instance. Accessible from layer GameObjects. ```APIDOC ## Class LDtkComponentLayer This component can be used to get certain LDtk information of a layer instance. Accessible from layer GameObjects. ### Properties #### AutoLayerTiles Type: [LDtkComponentLayerTilesetTiles](LDtkUnity.LDtkComponentLayerTilesetTiles.html) Description: Information about auto-layer tiles. #### CSize Type: UnityEngine.Vector2Int Description: Layer dimensions in cells. #### EntityInstances Type: [LDtkComponentEntity](LDtkUnity.LDtkComponentEntity.html)[] Description: An array of entity instances within this layer. #### GridSize Type: System.Int32 Description: The size of a grid cell in pixels. #### GridTiles Type: [LDtkComponentLayerTilesetTiles](LDtkUnity.LDtkComponentLayerTilesetTiles.html) Description: Information about grid tiles. #### Identifier Type: System.String Description: The unique identifier of the layer. #### Iid Type: System.String Description: The globally unique identifier of the layer. ``` -------------------------------- ### TryGetEntityReferenceArray Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets an enum field's values from an LDtk project. Returns true if the field exists, false otherwise. ```APIDOC ## TryGetEntityReferenceArray(String, out LDtkReferenceToAnEntityInstance[]) ### Description Gets an enum field's values. ### Parameters #### Path Parameters - **identifier** (System.String) - Required - The field instance's identifier. Case sensitive. #### Request Body - **values** (LDtkUnity.LDtkReferenceToAnEntityInstance[]) - Required - The field's values. ### Returns #### Success Response (200) - **System.Boolean** - If the field exists. ``` -------------------------------- ### LDtkDefinitionObjectCommand Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkDefinitionObjectCommand.html Examines the properties available within the LDtkDefinitionObjectCommand class, including 'Command' and 'When'. ```APIDOC ## Class LDtkDefinitionObjectCommand ### Properties #### Command * **Type**: System.String * **Description**: Represents the command string associated with the definition object. #### When * **Type**: LDtkUnity.When * **Description**: Defines the conditions under which the command should be executed. ``` -------------------------------- ### TileInstance Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.TileInstance.html This section details the properties of the TileInstance class, which are used to represent a tile within an LDtk level. These properties include flip transformations, pixel coordinates in the layer and tileset, and the tile ID. ```APIDOC ## TileInstance Properties ### Description This section details the properties of the TileInstance class, which are used to represent a tile within an LDtk level. These properties include flip transformations, pixel coordinates in the layer and tileset, and the tile ID. ### Properties #### FlipX * **Type**: System.Boolean * **Description**: X mirror transformation of the tile. #### FlipY * **Type**: System.Boolean * **Description**: Y mirror transformation of the tile. #### Px * **Type**: System.Int32[] * **Description**: Pixel coordinates of the tile in the **layer** (`[x,y]` format). Don't forget optional layer offsets, if they exist! #### Src * **Type**: System.Int32[] * **Description**: Pixel coordinates of the tile in the **tileset** (`[x,y]` format) #### T * **Type**: System.Int32 * **Description**: The _Tile ID_ in the corresponding tileset. #### TileLayerCoordId * **Type**: System.Int32 * **Description**: The cell ID of this tile, much like the tile ID in a tileset. Ensure to get this value from a tile layer context! ``` -------------------------------- ### TryGetColorArray Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a color field's values from an LDtk project. Returns true if the field exists, false otherwise. ```APIDOC ## TryGetColorArray(String, out Color[]) ### Description Gets a color field's values. ### Parameters #### Path Parameters - **identifier** (System.String) - Required - The field instance's identifier. Case sensitive. #### Request Body - **values** (UnityEngine.Color[]) - Required - The field's values. ### Returns #### Success Response (200) - **System.Boolean** - If the field exists. ``` -------------------------------- ### UnityBgColor Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LdtkJson.html Represents the project's background color in Unity. This property is of type UnityEngine.Color. ```APIDOC ## UnityBgColor ### Description Project background color. ### Type `UnityEngine.Color` ``` -------------------------------- ### TryGetColor Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a color field's value from an LDtk project. Returns true if the field exists, false otherwise. ```APIDOC ## TryGetColor(String, out Color) ### Description Gets a color field's value. ### Parameters #### Path Parameters - **identifier** (System.String) - Required - The field instance's identifier. Case sensitive. #### Request Body - **value** (UnityEngine.Color) - Required - The field's value. ### Returns #### Success Response (200) - **System.Boolean** - If the field exists. ``` -------------------------------- ### TryGetBoolArray Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a boolean field's values from an LDtk project. Returns true if the field exists, false otherwise. ```APIDOC ## TryGetBoolArray(String, out Boolean[]) ### Description Gets a bool field's values. ### Parameters #### Path Parameters - **identifier** (System.String) - Required - The field instance's identifier. Case sensitive. #### Request Body - **values** (System.Boolean[]) - Required - The field's values. ### Returns #### Success Response (200) - **System.Boolean** - If the field exists. ``` -------------------------------- ### LDtkComponentProject Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkComponentProject.html The LDtkComponentProject class exposes several properties that allow access to various settings and data related to the LDtk project import. These properties can be used to retrieve information such as build IDs, backup settings, background colors, and custom commands. ```APIDOC ## Class LDtkComponentProject A component available in the import result's root GameObject. Reference this to access the json data. ### Properties #### AppBuildId * **Type**: System.Single * **Description**: Represents the application build ID. #### BackupLimit * **Type**: System.Int32 * **Description**: Specifies the limit for backups. #### BackupOnSave * **Type**: System.Boolean * **Description**: A flag indicating whether to perform backups on save. #### BackupRelPath * **Type**: System.String * **Description**: The relative path for backup files. #### BgColor * **Type**: UnityEngine.Color * **Description**: The background color of the project. #### CustomCommands * **Type**: LDtkDefinitionObjectCommand[] * **Description**: An array of custom commands defined for the project. #### DefaultEntitySize * **Type**: (Type not specified in source) * **Description**: (Description not specified in source) ``` -------------------------------- ### EntityInstance Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.EntityInstance.html This section details the properties available for the EntityInstance class, which represents an instance of an entity within LDtk. ```APIDOC ## Class EntityInstance ### Description Represents an instance of an entity within LDtk, holding its data and properties. ### Properties #### Definition - **Type**: [EntityDefinition](LDtkUnity.EntityDefinition.html) - **Description**: Reference of this instance's definition. Make sure to call [LDtkUidBank](LDtkUnity.LDtkUidBank.html).[CacheUidData(LdtkJson)](LDtkUnity.LDtkUidBank.html#LDtkUnity_LDtkUidBank_CacheUidData_LDtkUnity_LdtkJson_) first! #### DefUid - **Type**: System.Int32 - **Description**: Reference of the **Entity definition** UID #### FieldInstances - **Type**: [FieldInstance](LDtkUnity.FieldInstance.html)[] - **Description**: An array of all custom fields and their values. #### Grid - **Type**: System.Int32[] - **Description**: Grid-based coordinates (`[x,y]` format) #### Height - **Type**: System.Int32 - **Description**: Entity height in pixels. For non-resizable entities, it will be the same as Entity definition. #### Identifier - **Type**: System.String - **Description**: Entity definition identifier #### Iid - **Type**: System.String - **Description**: Unique instance identifier. ``` -------------------------------- ### LDtkComponentLayerTilesetTiles.Tilemap Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkComponentLayerTilesetTiles.html Gets the Tilemap associated with this component. This property provides access to the Unity Tilemap object that represents the LDtk layer. ```APIDOC ## LDtkComponentLayerTilesetTiles.Tilemap ### Description Gets the Tilemap associated with this component. This property provides access to the Unity Tilemap object that represents the LDtk layer. ### Type UnityEngine.Tilemaps.Tilemap ``` -------------------------------- ### LDtkPostprocessor.OnPostprocessLevel Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.Editor.LDtkPostprocessor.html Use to perform operations after a level is created. This is called when importing a separate level file, or called on every level gameobject in a project that doesn't use separate level files. ```APIDOC ## OnPostprocessLevel(GameObject, LdtkJson) ### Description Use to perform operations after a level is created. This is called when importing a separate level file, or called on every level gameobject in a project that doesn't use separate level files. ### Parameters #### Path Parameters - **root** (UnityEngine.GameObject) - Required - The root GameObject of the imported LDtk level. This GameObject has a [LDtkComponentLevel](LDtkUnity.LDtkComponentLevel.html) component to get the level's json data with GetComponent. - **projectJson** (LdtkJson) - Required - The Json data of the project this level is referenced by. ``` -------------------------------- ### Get Integer Field During Runtime Source: https://github.com/cammin/ldtktounity/blob/master/DocFX/documentation/Topics/topic_Fields.md Accesses an integer field named 'HP' from an LDtkFields component attached to a GameObject during runtime. ```csharp int hp = GetComponent().GetInt("HP"); ``` -------------------------------- ### TryGetEntityReference Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets an entity reference field's value from an LDtk project. Returns true if the field exists, false otherwise. ```APIDOC ## TryGetEntityReference(String, out LDtkReferenceToAnEntityInstance) ### Description Gets an entity reference field's value. ### Parameters #### Path Parameters - **identifier** (System.String) - Required - The field instance's identifier. Case sensitive. #### Request Body - **value** (LDtkUnity.LDtkReferenceToAnEntityInstance) - Required - The field's value. ### Returns #### Success Response (200) - **System.Boolean** - If the field exists. ``` -------------------------------- ### LDtkTilesetDefinitionWrapper.TilesetRect Methods Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkTilesetDefinitionWrapper.TilesetRect.html The LDtkTilesetDefinitionWrapper.TilesetRect struct provides methods to convert between Unity's RectInt and LDtk's TilesetRect, and to convert to a Unity Rect. ```APIDOC ## Struct LDtkTilesetDefinitionWrapper.TilesetRect ### Methods #### FromRectInt(RectInt rectInt) Converts a Unity RectInt to an LDtkTilesetDefinitionWrapper.TilesetRect. * **Parameters**: * rectInt (UnityEngine.RectInt) - The RectInt to convert. * **Returns**: * LDtkTilesetDefinitionWrapper.TilesetRect - The converted TilesetRect. ``` ```APIDOC #### ToRect() Converts the LDtkTilesetDefinitionWrapper.TilesetRect to a Unity Rect. * **Returns**: * UnityEngine.Rect - The converted Rect. ``` -------------------------------- ### LDtkComponentProject Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkComponentProject.html This section details the properties available on the LDtkComponentProject class, which are used to configure LDtk project settings within the Unity environment. ```APIDOC ## LDtkComponentProject Properties This class exposes several properties for configuring LDtk project import and export settings in Unity. ### DefaultEntitySize * **Type**: UnityEngine.Vector2Int * **Description**: The default size for entities in the LDtk project. ### DefaultGridSize * **Type**: System.Int32 * **Description**: The default grid size for levels in the LDtk project. ### DefaultLevelBgColor * **Type**: UnityEngine.Color * **Description**: The default background color for levels in the LDtk project. ### DefaultPivot * **Type**: UnityEngine.Vector2 * **Description**: The default pivot point for elements in the LDtk project. ### DummyWorldIid * **Type**: System.String * **Description**: A dummy World IID used internally. ### ExportLevelBg * **Type**: System.Boolean * **Description**: Determines whether level backgrounds should be exported. ### ExportTiled * **Type**: System.Boolean * **Description**: Determines whether tiled data should be exported. ### ExternalLevels * **Type**: System.Boolean * **Description**: Indicates whether levels are stored externally. ### Flags * **Type**: Unknown * **Description**: General flags for project settings. (Type not specified in source) ``` -------------------------------- ### GetColorArray(String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets a color field's values. Returns the field's value or a default value if the field does not exist. ```APIDOC ## GetColorArray(String) ### Description Gets a color field's values. Returns the field's value or a default value if the field does not exist. ### Method GET (Assumed based on typical SDK patterns for retrieval) ### Endpoint (Not applicable for SDK methods) ### Parameters #### Path Parameters (Not applicable for SDK methods) #### Query Parameters (Not applicable for SDK methods) #### Request Body (Not applicable for SDK methods) ### Request Example (Not applicable for SDK methods) ### Response #### Success Response - **colorArray** (UnityEngine.Color[]) - The field's value. If the field doesn't exist, then returns a default value type. #### Response Example (Not applicable for SDK methods) ``` -------------------------------- ### LayerInstance Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LayerInstance.html Provides access to various properties of a LayerInstance, including its opacity, optional rules, tileset overrides, and pixel offsets. ```APIDOC ## LayerInstance Properties ### Opacity Layer opacity as Float [0-1] **Type:** System.Single ### OptionalRules An Array containing the UIDs of optional rules that were enabled in this specific layer instance. **Type:** System.Int32[] ### OverrideTilesetDefinition This layer can use another tileset by overriding the tileset here. Make sure to call [LDtkUidBank](LDtkUnity.LDtkUidBank.html).[CacheUidData(LdtkJson)](LDtkUnity.LDtkUidBank.html#LDtkUnity_LDtkUidBank_CacheUidData_LDtkUnity_LdtkJson_) first! **Type:** [TilesetDefinition](LDtkUnity.TilesetDefinition.html) ### OverrideTilesetUid This layer can use another tileset by overriding the tileset UID here. **Type:** System.Nullable ### PxOffsetX X offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to the `LayerDef` optional offset, so you should probably prefer using `__pxTotalOffsetX` which contains the total offset value) **Type:** System.Int32 ### PxOffsetY Y offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to the `LayerDef` optional offset, so you should probably prefer using `__pxTotalOffsetX` which contains the total offset value) **Type:** System.Int32 ### PxTotalOffsetX **Type:** System.Int32 ``` -------------------------------- ### GetEntityReferenceArray(String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets an entity reference field's values. Returns the field's values or a default value if the field does not exist. ```APIDOC ## GetEntityReferenceArray(String) ### Description Gets an entity reference field's values. Returns the field's values or a default value if the field does not exist. ### Method GET (Assumed based on typical SDK patterns for retrieval) ### Endpoint (Not applicable for SDK methods) ### Parameters #### Path Parameters (Not applicable for SDK methods) #### Query Parameters (Not applicable for SDK methods) #### Request Body (Not applicable for SDK methods) ### Request Example (Not applicable for SDK methods) ### Response #### Success Response - **entityReferenceArray** ([LDtkReferenceToAnEntityInstance](LDtkUnity.LDtkReferenceToAnEntityInstance.html)[]) - The field's value. If the field doesn't exist, then returns a default value type. #### Response Example (Not applicable for SDK methods) ``` -------------------------------- ### TileInstance Properties Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.TileInstance.html The TileInstance structure contains properties that define a single tile, including its alpha, layer information, and rule definitions for auto-layers. ```APIDOC ## TileInstance Properties ### Description Represents a single tile from a given Tileset. ### Properties #### A - **Type**: System.Single - **Description**: Alpha/opacity of the tile (0-1, defaults to 1). #### AutoLayerCoordId - **Type**: System.Int32 - **Description**: The cell ID of this tile, much like the tile ID in a tileset. Ensure to get this value from an auto layer context! #### AutoLayerRuleDefinition - **Type**: [AutoLayerRuleDefinition](LDtkUnity.AutoLayerRuleDefinition.html) - **Description**: Reference of this tile's rule definition, only for AutoLayers! Make sure to call [LDtkUidBank](LDtkUnity.LDtkUidBank.html).[CacheUidData(LdtkJson)](LDtkUnity.LDtkUidBank.html#LDtkUnity_LDtkUidBank_CacheUidData_LDtkUnity_LdtkJson_) first! #### AutoLayerRuleId - **Type**: System.Int32 - **Description**: Rule definition uid. Ensure to get this value from an auto layer context! #### D - **Type**: System.Int32[] - **Description**: Internal data used by the editor. For auto-layer tiles: `[ruleId, coordId]`. For tile-layer tiles: `[coordId]`. ``` -------------------------------- ### GetEntityReference(String) Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkFields.html Gets an entity reference field's value. Returns the field's value or a default value if the field does not exist. ```APIDOC ## GetEntityReference(String) ### Description Gets an entity reference field's value. Returns the field's value or a default value if the field does not exist. ### Method GET (Assumed based on typical SDK patterns for retrieval) ### Endpoint (Not applicable for SDK methods) ### Parameters #### Path Parameters (Not applicable for SDK methods) #### Query Parameters (Not applicable for SDK methods) #### Request Body (Not applicable for SDK methods) ### Request Example (Not applicable for SDK methods) ### Response #### Success Response - **entityReference** ([LDtkReferenceToAnEntityInstance](LDtkUnity.LDtkReferenceToAnEntityInstance.html)) - The field's value. If the field doesn't exist, then returns a default value type. #### Response Example (Not applicable for SDK methods) ``` -------------------------------- ### GetEntity() Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.LDtkReferenceToAnEntityInstance.html Gets a iid GameObject. This method retrieves the iid component that matches the provided iid. It requires the component to be active and accessed after its OnEnable. ```APIDOC ## GetEntity() ### Description Gets a iid GameObject. This method retrieves the iid component that matches the iid. The objects are only available after their OnEnable. If the component exists but this returned null, ensure the referenced component is active and accessed after its OnEnable. ### Returns - **LDtkIid** - The iid component that matches the iid. ``` -------------------------------- ### UnityLevelBgColor Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.Level.html Represents the background color of the level. If this property is null, the project's default level background color should be used. ```APIDOC ## UnityLevelBgColor ### Description Background color of the level. If `null`, the project `defaultLevelBgColor` should be used. ### Type UnityEngine.Color ``` -------------------------------- ### TilesetRectangle Methods Source: https://github.com/cammin/ldtktounity/blob/master/docs/api/LDtkUnity.TilesetRectangle.html Provides methods for comparing TilesetRectangle objects and converting them to strings. ```APIDOC #### Equals(TilesetRectangle) ##### Parameters - **other** (TilesetRectangle) - Description: The TilesetRectangle to compare with. ##### Returns - Type: System.Boolean - Description: True if the other TilesetRectangle is equal to the current one; otherwise, false. #### ToString() ##### Returns - Type: System.String - Description: A string that represents the current TilesetRectangle object. ```