SuperTiled2Unity icon indicating copy to clipboard operation
SuperTiled2Unity copied to clipboard

Calling custom TMX importer directly

Open ijacquez opened this issue 4 years ago • 4 comments

I create .tmx files within Unity, as well as the .png tilesheets. The problem is that because the tilesheets are marked as dependencies, the custom importer is fired for each tilesheet change. So if I have 10-35 tilesheets being created, the custom importer is unnecessarily fired 10-35 times. In reality, I only need it to be called once.

I call File.WriteAllBytes for every .png file, but I don't call AssetDatabase.SaveAssets and AssetDatabase.Refresh until the very end.

Is there functionality, or the ability to extend SuperTiled2Unity (locally, for now) to call a custom TMX importer of a specific type?

ijacquez avatar Apr 15 '20 20:04 ijacquez

I somewhat solved this issue by:

  1. Deleting the .tmx file via File.Delete, before I recreate it
  2. After creating, call AssetDatabase.ImportAsset on the .tmx file

This solves the issue, but it's an ugly solution. The other issue is that there's an object count of 2 for the .tmx file, which I don't understand. This has the custom importer executed twice. I'm not sure why. If I delete the .prefab I generate, then the importer is called just once.

ijacquez avatar Apr 15 '20 20:04 ijacquez

There was another issue in the past few days where Unity would lock up for 30-50 seconds at a time. There was 100% disk activity, and a ton of asset files were being read. This was killing my productivity (and patience).

I profiled the editor and found SuperAssetDependencyPostprocessor.cs and TiledAssetDependencies.cs to be culprit.

I force removed the files, and adjusted TmxAssetImporterEditor.cs to reflect the change.

I'm seeing that separating out the logic from SuperImporter would be a huge task, as it's directly coupled with Unity's importing pipeline.

I guess that's a project for another day.

ijacquez avatar Apr 30 '20 23:04 ijacquez

Hi there, @ijacquez. Are your tilesheets being automatically generated by some script?

Seanba avatar Feb 28 '22 03:02 Seanba

Yes, it's a script that generates these .tmx files.

I'm no longer working on the project, but the workaround that I mentioned did work.

ijacquez avatar Mar 02 '22 07:03 ijacquez