Hi all,
I just added IAP to my project and it installed 2.2.2 by default (which I find odd as 4.x seems to be the current release). I then upgraded to 4.0.3 via the package manager and was promptly greeted with a bunch of warning logs:
Library\PackageCache\com.unity.purchasing@4.0.3\Editor\ServiceProjectSettings\Presenter\BasePurchasingState.cs(7,70): warning CS0618: ‘PurchasingServiceToggleEvent’ is obsolete: ‘Internal API, it will be removed soon.’
I have used Unity IAP in the past and am still using 2.x on other apps. I don’t want to use 2.x now because I want to avoid the upgrade hazzle latter on. Though 2.x seems to be the only version verified for Unity 2019 LTS.
In the manual it says (2019.4+ for 4.x)
What is the big difference between 3.x and 4.x (other than Samsung IAP no longer being included)?
My questions:
Is anyone having experience with 4.x / 3.x? Are those reliable?
Should I better stick with 2.x?
UPDATE: Have tried 3.2.3 now and that one looks okay. Still, I would be interested in what 4.x offers and if it is used successfully out in the wild.
Also, is there a manual page which tells me the version of native purchasing libs Unity IAP is using in the back? I find it cumbersome having to rely on random forum posts to gather that info or to check all the change logs.
We are now using Package Manager to manage Unity IAP installation. Once you upgrade to 3.x and above, you’ll want to delete /Assets/Plugins/UnityPurchasing. Ensure to make a project backup first. 4.0.3 includes many important bug fixes (as does each version, compared to the previous)
Thanks for your quick reply.
I have settled with 3.x for now but I will continue to check out an upgrade to 4.x.
The main reason I am not on 4.x is that it logged those deprecation warnings. Which I find odd as it’s newer than 3.x.
What triggered me to ask was the fact that it installed 2.x automatically after enabling IAP (I did NOT click that import button). I had no IAP (or any Unity Service) installed previously in the project. Maybe that’s something to consider changing. I am on Unity 2019.4.21.f1, maybe my version is just too old.
We would not install IAP automatically. You received those warnings likely because you have some obsolete libraries conflicting, you would to delete your /Library folder to confirm. We have not heard of those messages. 4.0.3 includes some important fixes.
Thanks again.
I’ll dump the Library folder and report back if the problem persists. I was firmly convinced that I had not installed any IAP lib beforehand but I trust your word on this. So probably that’s (part of) my issue.
I am still confused by the warning origin being reported as: “Library\PackageCache\com.unity.purchasing@4.0.3\Editor\ServiceProjectSettings\Presenter\BasePurchasingState.cs(7,70): warning CS0618:”.
Please notice the “4.0.3” there. Isn’t that an indicator for it originating in the 4.0.3 IAP package?
None of this is happening with 3.x btw. (not sure if that’s important).
Reimport has finished. I deleted and reimported IAP (just to make sure it’s a clean install).
Here are my findings:
One of the warnings is issued by this enum in “Library\PackageCache\com.unity.purchasing@4.0.3\Editor\ServiceProjectSettings\Entity\PurchasingServiceToggleEvent.cs”
using System;
namespace UnityEditor.Purchasing
{
/// <summary>
/// This is an internal API.
/// We recommend that you do not use it as it will be removed in a future release.
/// </summary>
[Obsolete("Internal API, it will be removed soon.")]
public enum PurchasingServiceToggleEvent
{
/// <summary>
/// This is an internal API.
/// We recommend that you do not use it as it will be removed in a future release.
/// </summary>
[Obsolete("Internal API, it will be removed soon.")]
Disabled,
/// <summary>
/// This is an internal API.
/// We recommend that you do not use it as it will be removed in a future release.
/// </summary>
[Obsolete("Internal API, it will be removed soon.")]
Enabled
}
}
It is used in “Library\PackageCache\com.unity.purchasing@4.0.3\Editor\ServiceProjectSettings\Presenter\BasePurchasingState.cs” Line 7
Library\PackageCache\com.unity.purchasing@4.0.3\Editor\ServiceProjectSettings\Presenter\BasePurchasingState.cs(7,70): warning CS0618: ‘PurchasingServiceToggleEvent’ is obsolete: ‘Internal API, it will be removed soon.’
using System.Collections.Generic;
using System.Linq;
using UnityEngine.UIElements;
namespace UnityEditor.Purchasing
{
internal abstract class BasePurchasingState : SimpleStateMachine<PurchasingServiceToggleEvent>.State
{
...
It seems logical to me that it would report these warnings. What am I missing?
Did you first delete the /Library folder as directed? So this occurs on a brand new project and importing IAP? (not reimport). Please confirm, I just did the same with Unity 2019.4.20.f1 and see no errors. However my suspicion is the same, you still have an old reference to this API which is now deprecated. Also, ensure you’ve deleted /Assets/Plugins/UnityPurchasing (the older IAP Asset folders)
“Did you first delete the /Library folder as directed?”
→ yes, completely. That’s why it took me a while to reply
“/Assets/Plugins/UnityPurchasing”
→ yes, double checked just now (even did a wildcard search on the folders to reveal anything remotely IAP like)
I’ll try to reproduce this tomorrow in a clean project. What I still don’t get (and I am sorry if it seems dumb) but how can it be an “old reference” if the deprecation is completely internal to the IAP package (both c# files are from that very package)?
Do you have a Repo which I can check against to confirm I actually have the right code? Maybe it’s a package caching issue outside of my project (but still on my machine)?
I guess I need some sleep.
Thanks again. I’ll report back (tomorrow) with my findings.
Update: Couldn’t resist. Completely new project (URP template, Deleted the sample assets). Imported IAP 4.0.3, same warnings. Unity 2019.4.21f1.
I did not use any templates when I tested, please confirm in your testing as well. I created a standard 3D project. You are correct, if this is indeed a brand new project, there would not be any old references. It does look like package cache issue, do you have another system to compare to by chance? It looks to unique to this system.
Verified with sha-1 that the hash is c7959a9b519b93c40c6922efdd761c62fa649a4f (it is).
Extracted the files, et voila, they are the same files as mentioned in one of my previous posts (“PurchasingServiceToggleEvent.cs” and “BasePurchasingState.c”). I even copied them to a new project (no packages involved) to make extra sure.
I don’t understand how you are not getting these warnings. They ought to be there with the given code in the package originating from Unity servers. Are you using a CDN, is maybe their cache freaking out on me?
Please try my suggestions, you have an older reference cached on this system. You are the only person we have seen that has reported this issue, it is unique to this system. You have an older version that still has a reference to ‘PurchasingServiceToggleEvent’ in the previous package, and it has now been deprecated.
I have now SSHed into one of my webservers and downloaded the files there and inspected them on the server. It’s in a different network (in a differenty country). Same result: “PurchasingServiceToggleEvent” is still used in BasePurchasingState.cs line 7 which in turn has a deprecation on it.
The only thing I can think of now is that the source which I am pulling from might be wrong (https://download.packages.unity.com/com.unity.purchasing). It would be nice to get the url confirmed and the hash for the correct (not outdated) package so I can really make sure I have the right one.
Here are the commands (if anyone wants to reproduce my steps):
mkdir unity
cd unity
wget https://download.packages.unity.com/com.unity.purchasing/-/com.unity.purchasing-4.0.3.tgz
tar zxvf com.unity.purchasing-4.0.3.tgz
cat package/Editor/ServiceProjectSettings/Presenter/BasePurchasingState.cs
cat package/Editor/ServiceProjectSettings/Entity/PurchasingServiceToggleEvent.cs
Yes, I know that. But to rule out any local caching issues I looked up where the package manager ui gets the data from and then tried to pull from there.
I used 2019.4.2.20f1 without issue. I imported similarly, added a script with using UnityEngine.Purchasing and added it to the MainCamera of the SampleScene, then pressed Play.
Yes, I believe you 100% but I can’t seem to make Unity import the right version on any machine I try. I’ll investigate some other unity versions next. If that doesn’t resolve it I’ll just stick with 3.x for now and try again later.
As you mentioned pressing play. It’s not a runtime issue for me. I simply get those warnings upon importing/compiling.