0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MonoGameのカスタムパイプラインを作ろうとして躓いたところと対応

Posted at

概要

MonoGameのカスタムパイプラインを作成するにあたり参考にしたサイトと、躓いた箇所と対応方法
あとでちゃんとした記事にしたい

参考にしたサイト

このサイトのチュートリアルで、JSON形式のファイルのカスタムパイプラインの作成を参考にした。

躓きポイント

カスタムパイプラインのターゲットフレームワークのバージョンは6.0

Create the MonoGame Content Pipeline Extension Projectの章
ここでプロジェクトのターゲットフレームワークを 6.0 から変更してはいけない。
あとの章で説明されるが、このプロジェクトのビルドdllをMGCBエディタで参照します。
MGCBエディタは.NET6.0対応で8.0以降は対応していない、このプロジェクトのターゲットフレームワークを変更すると後々MGCBエディタが想定の動きをしてくれない。(2025/02/11)

書き込みデータのクラス名を統一

Create the MonoGame Content Pipeline Extension Projectの章
JsonContentProcessorResultクラスを作成する項目で、ソースコードのクラス名と説明文が統一されてない。
これ以降の文でも統一されていないので、都度読み替えましょう。

Runtimeパラメータ

Edit The JsonContentTypeWriterの章
MGCBエディタで設定するパラメータであるRuntimeパラメータを利用していない。
以下のソースコードを

JsonContentTypeWriter.cs
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;

using TInput = JsonContentPipelineExtension.JsonContentResult;

namespace JsonContentPipelineExtension
{
    [ContentTypeWriter]
    internal class JsonContentTypeWriter : ContentTypeWriter<TInput>
    {
        protected override void Write(ContentWriter output, TInput value)
        {
            output.Write(value.Json);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return "JsonContentPipeline.JsonContentReader, JsonContentPipeline";
        }
    }
}

こう置き換えた

JsonContentTypeWriter.cs
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;

using TInput = JsonContentPipelineExtension.JsonContentProcessorResult;

namespace JsonContentPipelineExtension
{
    [ContentTypeWriter]
    internal class JsonContentTypeWriter : ContentTypeWriter<TInput>
    {
        private string _RuntimeType;

        protected override void Write(ContentWriter output, TInput value)
        {
            _RuntimeType = value.RuntimeType;
            output.Write(value.Json);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            if (string.IsNullOrEmpty(_RuntimeType) == false)
            {
                return _RuntimeType;
            }
            else
            {
                return "JsonContentPipeline.JsonContentTypeReader, JsonContentPipeline";
            }
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?