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?

Unityのプロジェクトに追加されたSourceGenerator用のdllの導入設定を自動化する機能を作りました

0
Posted at

はじめに

お恥ずかしながら、最近になってようやくSource Generatorに手を出し始めました。便利ですよね。
そんなSource GeneratorをUnityで使うためにはプロジェクトに追加するだけではなく、各種設定が必要になります。
その設定を手でやっていては大変なので、Source Generatorのdllの導入設定を自動化する仕組みを作ることにしました。

動作環境

  • Unity 2022.3.12f1以上
  • (Windows11 + Unity 6000.6.10f1で動作を確認)

使い方

こちらのリポジトリを導入すると、アセット追加メニューからSourceGeneratorTargetFolderMarkerというアセットを作成できるようになります。
SourceGeneratorTargetFolderMarkerがあるフォルダー以下に配置されたSource Generator用のDLLに対してインポート設定とラベル付けを行います。
また、SourceGeneratorTargetFolderMarkerがないフォルダーにあるSource Generator用のDLLに対してはラベルの除去のみ行います。
なお、対象となるDLLにAvoidAutoSrcGenConfigラベルを付与すると、処理の対象外にすることができます。

ライセンス

MITライセンスです

いい感じの使い道の案

今回作った仕組みは「dll追加後の設定を自動化する」ものなので、Source Generator用のdllを開発するプロジェクトでビルド後に「生成されたdllをSourceGeneratorTargetFolderMarkerがあるフォルダーにコピーする」処理を設定し併せて使うことで、特に新しいdllが増える時に真価を発揮するかと思われます。

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?