コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

概要

public async UniTaskVoid Fade()
{
    await UniTask.Delay( 1 );
    transform.DOMoveX( 5, 1 );
}

上記のように非同期メソッドで DOTween の関数を呼び出した時に

warning CS4014: Because this call is not awaited, 
execution of the current method continues before the call is completed. 
Consider applying the 'await' operator to the result of the call.

この警告が出る場合、

public async UniTaskVoid Fade()
{
    await UniTask.Delay( 1 );
    var _ = transform.DOMoveX( 5, 1 );
}

このように書くと警告が消える