유니티(Unity) ‘RequestConfiguration.Builder’ is obsolete: ‘Use RequestConfiguration directly instead’ 경고 해결

개요

유니티에 Google Mobile Ads Unity Plugin 을 이용하여 광고를 연동했는데 ‘RequestConfiguration.Builder’ is obsolete: ‘Use RequestConfiguration directly instead’ 경고가 나타났습니다. 당장 문제가 되지는 않지만 향후에 결국 스크립트를 변경해야 할 것 같아 해결하기로 했습니다.

원인

원래 스크립트의 코드는 다음과 같습니다.

RequestConfiguration requestConfiguration =
        new RequestConfiguration.Builder()
        .SetTagForChildDirectedTreatment(TagForChildDirectedTreatment.Unspecified)
        .SetTestDeviceIds(deviceIds).build();

new RequestConfiguration.Builder() 이 부분에서 ‘RequestConfiguration.Builder’ is obsolete: ‘Use RequestConfiguration directly instead’ 경고가 발생합니다. Builder() 를 사용해서 경고가 발생합니다.

그리고 AdRequest 도 동일한 경고가 발생했습니다. 원래 스크립트의 코드는 다음과 같습니다.

return new AdRequest.Builder()
        .AddKeyword("unity-admob")
        .Build();

해결

Builder 를 사용하지 않도록 코드를 수정하면 됩니다.

RequestConfiguration requestConfiguration = new RequestConfiguration();
requestConfiguration.TagForChildDirectedTreatment = TagForChildDirectedTreatment.Unspecified;
requestConfiguration.TestDeviceIds = deviceIds;

AdRequest adRequest = new AdRequest();
HashSet<string> keyword = new HashSet<string>();
keyword.Add("unity-admob");
adRequest.Keywords = keyword;

return adRequest;

이번 글에서는 간단하게 ‘RequestConfiguration.Builder’ is obsolete: ‘Use RequestConfiguration directly instead’ 경고를 해결하는 방법을 알아보았습니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Time limit is exhausted. Please reload the CAPTCHA.