Unity IAP: Unity In-App Purchasing requires Unity Gaming Services to have been initialized before use.
Unity IAP API를 사용하기 전에 Unity Gaming Services를 초기화해야 한다.
코드리스 IAP에서는 IAP Catalog에서 Automatically initialize Unity Gaming Services를 선택하여 Unity 게임 서비스 자동 초기화를 활성화할 수 있다. 이 경우 애플리케이션이 시작될 때 Unity 게임 서비스가 즉시 초기화된다.
코드리스를 사용하지 않는 일반적인 환경에서는 초기화 코드를 작성해서 Unity 게임 서비스를 초기화 해야 한다.
private const string Environment = "production";
async void Start()
{
try
{
var options = new InitializationOptions()
.SetEnvironmentName(environment);
await UnityServices.InitializeAsync(options);
}
catch (Exception exception)
{
// An error occurred during services initialization.
}
}