Alpaca Tech Blog

ゲーム作る系 草食動物の備忘録

【Unity】Asset入れた時のエラー対応

アセットストアの物そのまま入れて起こったエラー対策備忘録。

今後ここに追記していく予定です。

 

error CS0103: The name `AnimationUtility' does not exist in the current context

AnimationUtilityが利用できなくてエラー出ている状態です。

AnimationUtilityは、エディタ上でしか動かないので、

iOS等のビルドにするとエラーが出ます。

 

最近、AssetStoreの物をインポートしているとたまに出てきます。

 

▼対応

#if UNITY_EDITOR

AnimationUtility.....

#endif

 

エディタ上でしか動かないので、

AnimationUtilityを利用している箇所を#if UNITY_EDITOR ~ #endif で囲みましょう。

 

 

 

error CS0102: The type ~ already contains a definition for `postProcessing'

(Location of the symbol related to previous error)

既に変数が定義されているエラーです。

同じ名前が無いか確認してください。

 

タイトルのエラー場合postProcessing関連です。

現在、POSTPROCESSINGは、V1とV2があります。

これを両対応するために

 

#if UNITY_5_6_OR_NEWER && UNITY_POST_PROCESSING_STACK_V1 && AQUAS_PRESENT
PostProcessingBehaviour postProcessing;
#endif

#if UNITY_5_6_OR_NEWER && UNITY_POST_PROCESSING_STACK_V2 && AQUAS_PRESENT
PostProcessLayer postProcessing;
PostProcessVolume postProcessingVolume;
#endif

のように両対応するコードが書かれています。

f:id:alpacatech:20180919122657p:plain

 

▼PostEffectの場合の対策

メニューの

Edit->Player->OtherSettings->Scripting Define Symbolsに

UNITY_POST_PROCESSING_STACK_V1; UNITY_POST_PROCESSING_STACK_V2

両方書かれている場合、

どちらか一方にしてください。

わからない場合はV2を残した方がいいかも。