Krys
Krys

Reputation: 91

Monogame Custom Importer/Processor not being detected by Content Manager

Pretty much what it says in the title.

I've built a second .dll file which contains my Content Importer/Processor and added that .dll file in my 'References' section for my Content Manager for my project, but nothing. The Manager doesn't detect my custom importer/processor. No idea what's going on and I wasn't able to find anyone else having an issue like this, so I was hoping someone more experienced could help me out here!

I am using Json.NET for the Json Deserialization by the way.

Thank you in advence :)

MapJson Code:

public class MapJson
{
    [JsonProperty("name")]
    public String Name = "";

    [JsonProperty("width")]
    public Int32 MapWidth = 0;

    [JsonProperty("height")]
    public Int32 MapHeight = 0;
}

Importer Code:

[ContentImporter(".amap", DefaultProcessor = "MapProcessor", DisplayName = "Map Importer - Engine")]
public class MapImporter : ContentImporter<MapJson>
{
    public override MapJsonImport(string filename, ContentImporterContext context)
    {
        string json = new FileHandle(filename).ReadAll();
        MapJson data = JsonConvert.DeserializeObject<MapJson>(json);
        return data;
    }
}

Processor Code:

[ContentProcessor(DisplayName = "Map Processor - Engine")]
public class MapProcessor : ContentProcessor<MapJson, MapJson>
{
    public override MapJson Process(MapJson input, ContentProcessorContext context)
    {
        return input;
    }
}

Writer Code:

[ContentTypeWriter]
public class MapWriter : ContentTypeWriter<MapJson>
{
    protected override void Write(ContentWriter writer, MapJson value)
    {
        writer.Write(value.Name);
        writer.Write(value.MapWidth);
        writer.Write(value.MapHeight);
    }
}

Reader Code:

public class MapReader : ContentTypeReader<Map>
{
    protected override Map Read(ContentReader reader, Map existingInstance)
    {
        MapJson data = new MapJson();
        data.Name = reader.ReadString();
        data.MapWidth = reader.ReadInt32();
        data.MapHeight = reader.ReadInt32();

        // this constructor just sets my 'Map' class's Name, MapWidth and MapHeight variables
        return new Map(data);
    }
}

Upvotes: 0

Views: 491

Answers (1)

Krys
Krys

Reputation: 91

Well uhh this is embarrassing...
The solution was to first build the game project, then to actually re-build the content importer/processor project, and then to link it with the content manager!
I feel so stupid haha

Upvotes: 0

Related Questions