Skip to content

Add Tiled custom types JSON support#314

Open
Hinen wants to merge 1 commit into
Seanba:masterfrom
Hinen:support-custom-types-json
Open

Add Tiled custom types JSON support#314
Hinen wants to merge 1 commit into
Seanba:masterfrom
Hinen:support-custom-types-json

Conversation

@Hinen

@Hinen Hinen commented Jun 16, 2026

Copy link
Copy Markdown

Overview

This PR adds support for importing custom class and enum definitions exported from Tiled's Custom Types Editor.

SuperTiled2Unity already imports custom properties serialized directly in .tmx, .tsx, and template files. With Tiled custom classes, default member properties can live in the custom type definition instead of being duplicated into every asset that uses the class. Unless a value is overridden, or the asset is exported with Tiled's "Resolve object types and properties" option, ST2U may not see those class defaults during import.

This change lets users assign Tiled's exported propertytypes.json file in SuperTiled2Unity Project Settings. During import, ST2U can then load the same custom class defaults and enum metadata that Tiled uses in the editor.

What Changed

  • Added a Custom Types JSON field to SuperTiled2Unity Project Settings.
  • Added parsing support for Tiled Custom Types JSON exports.
  • Supports both exported raw arrays and project-style propertyTypes wrappers.
  • Imports custom classes as ST2U custom object types, including class colors and member defaults.
  • Imports custom enum definitions, including storageType, values, and valuesAsFlags.
  • Preserves propertyType on imported custom properties.
  • Resolves enum-backed properties to the enum's configured storage type, such as string or int.
  • Applies loaded class defaults through the existing custom property import path.
  • Registers the selected JSON file as an import dependency.
  • Updates the Custom Properties Viewer to show loaded classes, enum definitions, and enum-backed member metadata.
  • Keeps existing Object Types XML support intact.

Example

The screenshots below use a small sample custom type setup to demonstrate the import path.

In Tiled, the sample defines one class, TestClass, with a red class color and three default members: one integer member, one flag enum member, and one regular enum member. The two enum definitions are string-backed, with TestEnum1 using flags and TestEnum2 using a single selected value.

Tiled Custom Types Editor with sample class and enum definitions

The exported propertytypes.json file is assigned in the new Custom Types JSON field in SuperTiled2Unity Project Settings.

SuperTiled2Unity settings with Custom Types JSON assigned

After refreshing, the Custom Properties Viewer shows the loaded class defaults, the class color, the enum-backed member propertyType values, and the enum definitions loaded from the JSON file.

SuperTiled2Unity Custom Properties Viewer showing imported sample custom types

Compatibility

  • Existing Object Types XML support remains available.
  • Existing serialized custom properties in .tmx, .tsx, and template files continue to work.
  • Serialized instance-level properties still take precedence over class defaults.
  • Projects that do not assign a Custom Types JSON file behave as before.
  • This does not add Unity-side enum dropdown editing, enum value validation, or C# enum generation.

Testing

Manually tested with a Tiled Custom Types JSON export containing:

  • one custom class with default members
  • class color
  • a string-backed flag enum
  • a string-backed non-flag enum
  • class members referencing those enum property types

Verified in Unity that:

  • the exported propertytypes.json can be assigned in the new setting
  • the existing Object Types XML setting remains available
  • class defaults and class color appear in the Custom Properties Viewer
  • enum-backed members preserve their propertyType
  • enum-backed members resolve to the enum storage type
  • loaded enum definitions show storage type, flag setting, and values

Also checked:

  • git diff --check HEAD~1 HEAD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant