Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Can UnityPurchasingEditor.TargetAndroidStore be called via command line with -batchMode?

Discussion in 'Unity Distribution Portal (UDP)' started by bmorgan-ksg, Sep 8, 2022.

  1. bmorgan-ksg

    bmorgan-ksg

    Joined:
    Dec 13, 2016
    Posts:
    11
    We have a build pipeline that opens the Unity IDE in batch mode and invokes a method that first configures a number of project settings, based on command line arguments it is passed, before eventually building the player.

    I have been attempting to integrate the UnityPurchasingEditor.TargetAndroidStore API into this process and have found that calling this method with AppStore.UDP as a parameter results in a dialog that reads "In order to use this functionality, you must install or update the Unity Distribution Portal Package". This is despite the package being present in both the Packages/manifest.json file and Library/PackageCache folder.

    If I manually set the store to UDP by using the "SwitchStore" menu item or by directly manipulating the BillingMode.json file and then run the same build script (with calls to UnityPurchasingEditor.TargetAndroidStore removed) everything works as expected.

    I am using Unity 2020.3.34f along with v4.4.1 of the com.unity.purchasing package and v2.0.0 of the com.unity.purchasing.udp package.

    Is there something I am missing here that will allow me to use the UnityPurchasingEditor.TargetAndroidStore when building from the command line using batchMode?

    EDIT - It's also worth noting that I have unsuccessfully attempted to call it from a IPreprocessBuildWithReport.OnPreprocessBuild method, thinking that package resolution when Unity is opened may have been the issue.
     
    Last edited: Sep 8, 2022
  2. John_Corbett

    John_Corbett

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @bmorgan-ksg

    I haven't tested this myself, but I do know that the detection of the presence (or lack of presence) of the UDP package in that Editor function calls some Package Manager functions, which may not be available in batch mode. I could test this to confirm.

    In order to avoid this, instead of calling
    UnityPurchasingEditor.TargetAndroidStore
    , I recommend directly manipulating the billingmode.json file.

    Did I understand that doing so worked for you? Is this something that you could do in your pipeline and resolve your issue?

    If so, please go ahead with that. I don't think any negative consequences will occur. In order to fix
    UnityPurchasingEditor.TargetAndroidStore
    , we would need to make a patch for the IAP Package for Batch mode call to it without running the check as we have it.

    I hope this helps. Either way, please let us know.

    Thanks!
     
  3. bmorgan-ksg

    bmorgan-ksg

    Joined:
    Dec 13, 2016
    Posts:
    11
    Thanks for the reply. I'll implement something that works around this limitation.