Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/yujiap/unity-yuji.xyz/public_html/wp-content/plugins/social-networks-auto-poster-facebook-twitter-g/inc/nxs_functions_engine.php on line 266
Localizationパッケージを入れるとNewtonsoft.Json周りでエラーになる問題の解消 – ゆーじの技術ブログ

Localizationパッケージを入れるとNewtonsoft.Json周りでエラーになる問題の解消

エラー内容

UnityでPackage として用意されている Localization パッケージを PackageManager 経由で入れたとき、以下のようなコンパイルエラーがいくつか出るようになりました。

Library/PackageCache/com.unity.localization/Runtime/Property Variants/Tracked Objects/JsonSerializerTrackedObject.cs(3,7): error CS0246: The type or namespace name ‘Newtonsoft’ could not be found (are you missing a using directive or an assembly reference?)

色々いじっているとこんなエラーも

Plugin ‘Packages/com.unity.nuget.newtonsoft-json/Runtime/Newtonsoft.Json.dll’ has the same filename as Assembly Definition File ‘Packages/com.unity.nuget.newtonsoft-json/Runtime/Newtonsoft.Json.asmdef’. Rename the assemblies to avoid hard to diagnose issues and crashes.

 

原因

ローカライズ対応の準備をしている中で、VisualStudio を使って Google.Apis などの dll を Unity にインポートしたのですが、その際に Newtonsoft.Json.dll も一緒にインポートしていました。

しかし、Localization パッケージは Dependencies で Newtonsoft.Json が指定されているので、パッケージ導入時に勝手に入れてくれます。

そのため Newtonsoft.Json.dll と競合してしまい参照ができなくなっていたようです。たぶん

 

ちなみに参考にした記事はこちら。分かりやすかったです

 

解消方法

Newtonsoft.Json.dll を削除することで解消しました。

Localization パッケージによって自動的に入れられた Newtonsoft Json パッケージだけ残っている状態です。

 

Localization の機能も問題なく使えることを確認しました。

コメント