Add Tiled custom types JSON support#314
Open
Hinen wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonfile 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
Custom Types JSONfield to SuperTiled2Unity Project Settings.propertyTypeswrappers.storageType,values, andvaluesAsFlags.propertyTypeon imported custom properties.stringorint.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, withTestEnum1using flags andTestEnum2using a single selected value.The exported
propertytypes.jsonfile is assigned in the newCustom Types JSONfield in SuperTiled2Unity Project Settings.After refreshing, the Custom Properties Viewer shows the loaded class defaults, the class color, the enum-backed member
propertyTypevalues, and the enum definitions loaded from the JSON file.Compatibility
.tmx,.tsx, and template files continue to work.Testing
Manually tested with a Tiled Custom Types JSON export containing:
Verified in Unity that:
propertytypes.jsoncan be assigned in the new settingObject Types XMLsetting remains availablepropertyTypeAlso checked:
git diff --check HEAD~1 HEAD