1
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?

JavaScript(.js)ファイルをAddressablesに登録したい

Posted at

環境

  • Unity 2022.3.4f1
  • Addressables 1.21.21

状況

NPCユニットの挙動をスクリプトで記述できるようにしたかったので、サンプルが簡単そうだったJint(JavaScriptインタプリタ)を導入しました。
、なぜか.jsファイルのみインスペクタにAddressablesのチェックボックスが現れません。Addressablesウィンドウにドラッグアンドドロップでも登録させてくれません。
TextAssetとして認識させる必要があるのか?と思いScriptedImporterを使用してTextAssetとして読み込んでも許してくれません。どうして……。

image.png

しょうがないので大量のDebug.Logを抱えて原因究明の旅に出ました1

原因

AddressableAssetUtility.cs
// 99行目
static HashSet<string> excludedExtensions = new HashSet<string>(new string[] { ".cs", ".js", ".boo", ".exe", ".dll", ".meta", ".preset", ".asmdef" });

名指しで弾かれてました。
隣に『.boo』も並んでいるので、おそらくはUnityScriptが使えたころの名残かな(詳しくは知りませんが……)。

解決策

Addressablesパッケージを丸々コピーして1行だけ差し替えました
1行書き換えるために突如10MB弱跳ね上がったリポジトリサイズの変貌に涙を禁じ得ない。

  1. 拡張子を.txtやらなんやらに変えればいい話ではありますが、シンタックスハイライトなしでコードを書くのも苦痛なので

1
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
1
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?