Hello all,
I have a Invalid / Missing Importer issue, that seems to be frequent.
I’ve worked with XNA when it was still XNA and with the Content Pipeline. Everything I can find on this problem seems to want me to add Monogame.extended and I don’t want to! Although I plan to down the road a bit. I’m I missing anything in the code below? Thanks, Bubba
#pragma warning disable CS8603
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
namespace MGDevExt
{
public class MyObjExt
{
private string m_rawContent = string.Empty;
public string RawContent
{
get { return m_rawContent; }
set { m_rawContent = value; }
}
public MyObjExt() { }
}
[ContentImporter(".myobj", DefaultProcessor = nameof(MyObjExtImporter), DisplayName = "MyObjExtProcessor")]
class MyObjExtImporter : ContentImporter<string>
{
public override string Import(string filename, ContentImporterContext context)
{
context.Logger.LogMessage("Importing MyObjExt file: {0}", filename);
//using (StreamReader sr = new StreamReader(filename))
//{
// return sr.ReadToEnd();
//}
return "test";
}
}
[ContentProcessor(DisplayName = "MyObjExtProcessor")]
public class MyObjExtProcessor : ContentProcessor<string, MyObjExt>
{
public MyObjExtProcessor() { }
public override MyObjExt Process(string input, ContentProcessorContext context)
{
MyObjExt myObjExt = new MyObjExt();
myObjExt.RawContent = input;
return myObjExt;
}
}
[ContentTypeWriter]
class MyObjExtWriter : ContentTypeWriter<MyObjExt>
{
public override string GetRuntimeType(TargetPlatform targetPlatform)
{
return typeof(MyObjExt).AssemblyQualifiedName;
}
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
return typeof(MyObjExtReader).AssemblyQualifiedName;
}
protected override void Write(ContentWriter output, MyObjExt value)
{
output.Write(value.RawContent);
}
}
class MyObjExtReader : ContentTypeReader<MyObjExt>
{
protected override MyObjExt Read(ContentReader input, MyObjExt existingInstance)
{
MyObjExt myobjExt = new MyObjExt();
string content = input.ReadString();
myobjExt.RawContent = content;
return myobjExt;
}
}
}