1

I'm trying to code a custom importer for the SuperTiled2Unity plugin in Unity. This task is explained in the pugin documentation: here. My problem is that Unity don't seem to be aware that the plugin is installed which is weird because it works perfectly while the plugin import a tiled map. The problem occurs when a call the plugin in a script:

using SuperTiled2Unity;
using SuperTiled2Unity.Editor;
using UnityEngine;


/*
* Tells SuperTiled2Unity to used this importer by default
* */
[AutoCustomTmxImporter()]
public class MapImporter : CustomTmxImporter
{

    public override void TmxAssetImported(TmxAssetImportedArgs args)
    {
        // Note: args.ImportedSuperMap is the root of the imported prefab
        // You can modify the gameobjects and components any way you wish here
        // Howerver, the results must be deterministic (i.e. the same prefab is created each time)
        SuperMap map = args.ImportedSuperMap;
        //Debug.LogFormat("Map '{0}' has been imported.", map.name);
        // Find all tracks in our maps. These are edge colliders under the "Track" layer
        EdgeCollider2D[] edgeCollider2Ds = map.GetComponentsInChildren<EdgeCollider2D>();
        foreach (EdgeCollider2D collider in edgeCollider2Ds)
        {
            if (collider.gameObject.layer == LayerMask.NameToLayer("Block_Bullet"))
            {
                Rigidbody2D rb = collider.gameObject.AddComponent<Rigidbody2D>();
                rb.isKinematic = true;
            }
        }

    }

}

Then Unity gives me these compilation errors: Unity error console

What is strange is that VisualStudio seems to know that SuperTiled2Unity exists and thus, doesn't throw any compilation error.

At this time, I already tried to:

  1. Re-import the SuperTiled2Unity plugin
  2. Put my class in a namespace

I am aware that this issue seems like this one but I don't know how to use this solution. If this is relevant, please explain me how to apply it.

I use the 1.9.3 version of SuperTiled2Unity whit Unity 2020.1.3f1.

EDIT: I run the examples provided with the SuperTiled2Unity plugin on Github and the only difference I'm spotting is the assembly informations: Assembly information of my script Assembly information the example script

Could it be the cause of my problem ? If so, how to solve it ?

  • Try to move your script outside the `Editor` folder ... editor folders have a special meaning in Unity. Maybe the [compilation order](https://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html) is a problem and Unity doesn't "know" these types yet – derHugo Sep 22 '20 at 13:10
  • @derHugo Unfortunately, it changes nothing. – De Wolf Maxime Sep 22 '20 at 13:31
  • Maybe go to the according plug-in folder and check if it is supported for your target platform – derHugo Sep 22 '20 at 13:53

2 Answers2

1

The plugin is in it's own assembly definition. It's likely set up only be referenced by specific other assemblies that need it. Try putting your scripts that use SuperTiled2Unity in the same folder as SuperTiled2Unity's scripts. This will make it part of the same assembly. If that works then you either need to keep it there or set the SuperTiled2Unity assemblies to be referenced by your extension's assembly definition.

Thomas Finch
  • 482
  • 2
  • 6
1

It looks like you've got your own scripts in your own Assembly Definition named NewAssembly. However, that assembly definition does not have an Assembly Definition Resource for SuperTiled2Unity and SuperTiled2UnityEditor.

Either fix your NewAssembly assembly definition or remove it and you should be able to compile your custom importer.

Seanba
  • 141
  • 2
  • 5