【Godot】エラー "Condition "!script_data" is true." を黙らせる

発生した現象

Godot EngineでC++等使ってNativeScriptを実装してゲーム作りをしていると、こんなエラーを見ることがあります。

f:id:ueshita:20210418184021p:plain

実行して戻ってくると。

f:id:ueshita:20210418184058p:plain

エラーが2倍に増える。

めっちゃウザい!

発生条件

  • GDNativeのDLLが2つ以上ある
  • Godotエディタのフォーカスが外れた後、再度フォーカスする

解決方法

ネイティブライブラリ(dllとかsoとか)を指定しているファイルGDNativeLibaryのプロパティのReloadableのチェックを外すだけです。

f:id:ueshita:20210418184620p:plain

原因

GodotのDLLのリロード処理が上手く行われていないんですかね?

Reloadableの詳細は次の通りです。

https://docs.godotengine.org/en/stable/classes/class_gdnativelibrary.html#class-gdnativelibrary-property-reloadable

[原文] If true, the editor will temporarily unload the library whenever the user switches away from the editor window, allowing the user to recompile the library without restarting Godot.

[日本語訳] true の場合、ユーザーがエディタ ウィンドウから離れると、エディタは一時的にライブラリをアンロードし、ユーザーは Godot を再起動せずにライブラリを再コンパイルできます。

ReloadableがOFFになるとエディタ起動中はDLLがロードしっぱなしになるため、GDNativeの変更中はビルドのたびにエディタ終了して再起動する必要がありそうです。 (Unityのネイティブプラグイン開発の悪夢再び…)

ReloadableがONのGDNativeLibraryが1つだけの時はエラー出ないので、GDNativeの変更が終わったらReloadableをOFFにする運用がよさそう?