Show / Hide Table of Contents

Class Level

This section contains all the level data. It can be found in 2 distinct forms, depending on Project current settings: - If "Separate level files" is disabled (default): full level data is embedded inside the main Project JSON file, - If "Separate level files" is enabled: level data is stored in separate standalone .ldtkl files (one per level). In this case, the main Project JSON file will still contain most level data, except heavy sections, like the layerInstances array (which will be null). The externalRelPath string points to the ldtkl file. A ldtkl file is just a JSON file containing exactly what is described below.

Properties

| Improve this Doc View Source

BgColor

Background color of the level (same as bgColor, except the default value is automatically used here if its value is null)

Type Description
System.String
| Improve this Doc View Source

BgPivotX

Background image X pivot (0-1)

Type Description
System.Single
| Improve this Doc View Source

BgPivotY

Background image Y pivot (0-1)

Type Description
System.Single
| Improve this Doc View Source

BgPos

Position informations of the background image, if there is one.

Type Description
LevelBackgroundPosition
| Improve this Doc View Source

BgRelPath

The optional relative path to the level background image.

Type Description
System.String
| Improve this Doc View Source

ExternalRelPath

This value is not null if the project option "Save levels separately" is enabled. In this case, this relative path points to the level Json file.

Type Description
System.String
| Improve this Doc View Source

FieldInstances

An array containing this level custom field values.

Type Description
FieldInstance[]
| Improve this Doc View Source

Identifier

User defined unique identifier

Type Description
System.String
| Improve this Doc View Source

Iid

Unique instance identifier

Type Description
System.String
| Improve this Doc View Source

LayerInstances

An array containing all Layer instances. IMPORTANT: if the project option "Save levels separately" is enabled, this field will be null.
This array is sorted in display order: the 1st layer is the top-most and the last is behind.

Type Description
LayerInstance[]
| Improve this Doc View Source

LevelBgColor

Background color of the level. If null, the project defaultLevelBgColor should be used.

Type Description
System.String
| Improve this Doc View Source

LevelBgPos

An enum defining the way the background image (if any) is positioned on the level. See __bgPos for resulting position info. Possible values: <null>, Unscaled, Contain, Cover, CoverDirty, Repeat

Type Description
System.Nullable<LDtkUnity.BgPos>
| Improve this Doc View Source

Neighbours

An array listing all other levels touching this one on the world map. Since 1.4.0, this includes levels that overlap in the same world layer, or in nearby world layers.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, this array is always empty.

Type Description
NeighbourLevel[]
| Improve this Doc View Source

PxHei

Height of the level in pixels

Type Description
System.Int32
| Improve this Doc View Source

PxWid

Width of the level in pixels

Type Description
System.Int32
| Improve this Doc View Source

SmartColor

The "guessed" color for this level in the editor, decided using either the background color or an existing custom field.

Type Description
System.String
| Improve this Doc View Source

Uid

Unique Int identifier

Type Description
System.Int32
| Improve this Doc View Source

UnityBgColor

Type Description
UnityEngine.Color

Background color of the level (same as bgColor, except the default value is automatically used here if its value is null)

| Improve this Doc View Source

UnityBgPivot

Type Description
UnityEngine.Vector2

Background image pivot (0-1)

| Improve this Doc View Source

UnityLevelBgColor

Type Description
UnityEngine.Color

Background color of the level. If null, the project defaultLevelBgColor should be used.

| Improve this Doc View Source

UnityPxSize

Type Description
UnityEngine.Vector2Int

Size of the level in pixels

| Improve this Doc View Source

UnitySmartColor

Type Description
UnityEngine.Color

The "guessed" color for this level in the editor, decided using either the background color or an existing custom field.

| Improve this Doc View Source

UnityWorldCoord

Type Description
UnityEngine.Vector2Int

World coordinate in pixels.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always (-1, -1) here.

| Improve this Doc View Source

UnityWorldRect

Type Description
UnityEngine.RectInt

Rect of the level in pixels

| Improve this Doc View Source

UseAutoIdentifier

If TRUE, the level identifier will always automatically use the naming pattern as defined in Project.levelNamePattern. Becomes FALSE if the identifier is manually modified by user.

Type Description
System.Boolean
| Improve this Doc View Source

WorldDepth

Index that represents the "depth" of the level in the world. Default is 0, greater means "above", lower means "below".
This value is mostly used for display only and is intended to make stacking of levels easier to manage.

Type Description
System.Int32
| Improve this Doc View Source

WorldX

World X coordinate in pixels.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here.

Type Description
System.Int32
| Improve this Doc View Source

WorldY

World Y coordinate in pixels.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here.

Type Description
System.Int32

Methods

| Improve this Doc View Source

FromJson(Byte[])

Used for deserializing ".ldtkl" files.

Parameters
Type Name Description
System.Byte[] json

The LDtk json string to deserialize.

Returns
Type Description
Level

The deserialized level.

| Improve this Doc View Source

UnityWorldSpaceBounds(WorldLayout, Int32, Int32)

A Rect of the level's bounds in Unity's world space.

Parameters
Type Name Description
LDtkUnity.WorldLayout layout

Layout of the world. This affects how the level would be naturally positioned.

System.Int32 pixelsPerUnit

Main pixels per unit.

System.Int32 vector

Vector of the level for when creating the position for the level's layout as LinearHorizontal or LinearVertical. Otherwise the value is 0.

Returns
Type Description
UnityEngine.Rect

World space bounds of this level.

| Improve this Doc View Source

UnityWorldSpaceCoord(WorldLayout, Int32, Int32)

A special Vector2 position that solves where the layer's position should be in Unity's world space based off of LDtk's top-left origin. If the world layout is not free style, then the positioning of the level will be automatically arranged like they do in LDtk.

Parameters
Type Name Description
LDtkUnity.WorldLayout layout

Layout of the world. This affects how the level would be naturally positioned.

System.Int32 pixelsPerUnit

Main pixels per unit.

System.Int32 vector

Vector of the level for when creating the position for the level's layout as LinearHorizontal or LinearVertical. Otherwise the value is 0.

Returns
Type Description
UnityEngine.Vector2

The bottom left corner of the level's position in world space.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX