アセットインポーターは、作成した Scripted Importer も含めて、一貫した (決定論的な) 結果を提供すべきです。つまり、同じ入力と一群の依存関係から、常に同じ出力を生成する必要があります。
インポーターが上記の状態であることを確認するために、現在プロジェクトにあるアセットのインポート結果の一貫性を確認する以下のような 2 つの方法があります。
エディターで 1 つまたは複数のアセットを手動で再インポートする。
-consistencyCheck コマンドライン引数を使ってエディターを開く。
アセットを手動で再インポートすると、Unity は新しいインポート結果が以前にキャッシュされたインポート結果と一致するかどうかを確認します。
手動での再インポートを始めるには、アセットを右クリックし、コンテキストメニューから Reimport を選択します。
次に、Unity はインポート結果の一貫性をチェックします。結果の不一致が検出されると、Unity はコンソールウィンドウに警告を表示し、どのインポーターが問題を起こしたのか、以下のような詳細を表示します。
Importer(<name of importer>) generated inconsistent result for asset(guid:<guid of the asset>) "<name of asset>"
ルートアセットを再インポートすると、Unity はその子アセットも再インポートして一貫性チェックを行います。
一貫性チェックの 2 つ目の方法は、-consistencyCheck コマンドライン引数を使って Unity を開くことです。これは、プロジェクト内のすべてのアセットとインポーターに対して一貫性チェックを行います。
コマンドライン引数 | 説明 | 例 |
---|---|---|
-consistencyCheck |
起動時に、一貫性チェックを行うようにエディターに指示します。デフォルトでは “ローカル” チェックを行います (下記参照)。 | -consistencyCheck |
-consistencyCheckSourceMode string |
アセットのインポートを比較する際に、一貫性チェックツールがチェックするソースを設定します。設定可能な値は “local” か “cacheserver” の 2 つです。 “local” は、すべてのアセットをローカルに再インポートし、インポートが前回のものと異なるかどうかをチェックします。 “cacheserver” は、キャッシュサーバーにアセットのメタデータを問い合わせ、ローカルでの結果がキャッシュサーバーのものと一致するかどうかを比較します。この場合、すべてのアセットの再インポートは行われません。 |
-consistencyCheckSourceMode local -consistencyCheckSourceMode cacheserver |
起動中に矛盾が確認された場合は、コンソールとエディターのログファイルに記録されます。
一貫性チェッカーは、キャッシュ可能なアセットのインポートのみをチェックします。そのため、ScriptedImporter のキャッシュを無効にすると、そのインポートの一貫性チェックも無効になります。ScriptedImporter のキャッシュを無効にする方法については、AssetImporters.StiptedImporterAttribute を参照してください。
キャッシュサーバーを検証ソースとして使用するには、Unity Accelerator のドキュメントを参照してください。
インポーターの矛盾が検出されると、その問題に関する詳細な情報がエディターログに記録されます。これには以下が含まれます。
一貫性チェックの失敗の原因となったアセット
そのアセットの GUID
アセットのインポート結果のコンテンツハッシュ
アセットの前回の訂正との比較
以下は、インポーターの矛盾を示すエディターログの例です。
ConsistencyChecker - guid: a1945cd7aab67441ba89015f97494624, dependenciesHash.value: fb8cfb407bba82d4daded6031688ba9b, artifactid: 07078a054d3f597b4c2cc47e8e4c0bde, producedFiles[0].extension: , producedFiles[0].contentHash: 8490a5ed35a4361d679e6055a386969e
ConsistencyChecker - guid: a1945cd7aab67441ba89015f97494624, dependenciesHash.value: fb8cfb407bba82d4daded6031688ba9b, artifactid: 07078a054d3f597b4c2cc47e8e4c0bde, producedFiles[1].extension: .info, producedFiles[1].contentHash: 4bd9140e19d2e44782f1131172e514ba
ConsistencyChecker - guid: a1945cd7aab67441ba89015f97494624, dependenciesHash.value: fb8cfb407bba82d4daded6031688ba9b, artifactid: 646d6432767729ea7d288c636183de97, producedFiles[0].extension: , producedFiles[0].contentHash: 5ca760170f85012ce16aa8c22e8d9ea1
ConsistencyChecker - guid: a1945cd7aab67441ba89015f97494624, dependenciesHash.value: fb8cfb407bba82d4daded6031688ba9b, artifactid: 646d6432767729ea7d288c636183de97, producedFiles[1].extension: .info, producedFiles[1].contentHash: 4bd9140e19d2e44782f1131172e514ba
Importer(ScriptedImporter:Assembly-CSharp::RandomImporter) generated inconsistent result for asset(guid:a1945cd7aab67441ba89015f97494624) "Assets/first.rand"
キャッシュサーバーが利用できない場合、一貫性チェッカーはエディターログに警告を表示します。
プロジェクトにキャッシュサーバーが設定されていない場合は、以下のメッセージが表示されます。
ConsistencyChecker - Cacheserver is not enabled
Unity がキャッシュサーバーに接続できない場合、このメッセージが表示されます。
ConsistencyChecker - Not connected to accelerator/cacheserver
Unity エディターインストールの Data/Tools フォルダーにあるツール ‘binary2text’ を使って、ライブラリフォルダーの内容を調べ、実際にインポーターが生成したものを確認することができます。
例:
./Data/Tools/binary2text ./myProject/Library/Artifacts/84/8490a5ed35a4361d679e6055a386969e output_file
ハッシュ値は、アセットのコンテンツハッシュです。報告された矛盾を見つけ、チェック中にどのようなコンテンツが生成されたかを確認するには、エディターログを見ます。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.