When my game loads up, there is a large lag spike causing Unity’s default splash screen’s background to hang for a second and also my single animation lags partway through.
I know it is because of the IAP InitializePurchasing() method because when I comment it out everything works fine.
private void InitializePurchasing()
{
// If we have already connected to Purchasing ...
if(IsInitialized())
{
// ... we are done here.
return;
}
// Create a builder, first passing in a suite of Unity provided stores.
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
// add the products to the builder
foreach(string s in Enum.GetNames(typeof(ProductID)))
{
//builder.AddProduct(s, ProductType.Consumable);
}
// Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
// and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
UnityPurchasing.Initialize(this, builder);
}
As you can see, I even removed adding products to the builder to see if that was the issue.
I am using the latest Unity beta version and also building for iOS.
Unfortunately there isn’t much we can suggest. We are a pass through service for the store APIs, and we don’t add any processing ourselves. I can say that the store test environments are typically quite a bit slower than the live environments in case you are using TestFlight (Apple) or Alpha/Beta/Internal testing (Google). Are you initializing in Start or Awake ? Also the device logs may provide more information How To - Capturing Device Logs on iOS
private void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
private void Start()
{
// If we haven't set up the Unity Purchasing reference
if(m_StoreController == null)
{
// Begin to configure our connection to Purchasing
InitializePurchasing();
}
}
Also, what exactly should I look for in the device logs? (I see the IAP initializing and adding TransactionObserver)
From what you said about live environment being much faster, do you think I could safely assume that would be the case as I googled around and haven’t seen anyone else bring up this lag issue?
You would look for any errors or repeated log entries that might imply a loop. But yes, I believe you would be safe. Your code is the same code that I use.