Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question IAP requires UGS to be initialized?

Discussion in 'Unity IAP' started by SnappleMessiah, Aug 12, 2022.

  1. SnappleMessiah

    SnappleMessiah

    Joined:
    Jul 4, 2015
    Posts:
    14
    I'm using Gley Easy IAP, so maybe there is a conflict there? I removed the Unity IAP package and reimported to my project to make sure there wasn't any duplicate. I've tried a few things to see if UGS would be initialized but I have had no success. First was enabling the automatic initialization in the IAP catalog and then I tried the below script.

    Tried adding a script with the below code:
    Code (CSharp):
    1. using System;
    2. using Unity.Services.Core;
    3. using Unity.Services.Core.Environments;
    4. using UnityEngine;
    5.  
    6. public class InitializeUnityServices : MonoBehaviour
    7. {
    8.     public string environment = "production";
    9.  
    10.     async void Start()
    11.     {
    12.         try
    13.         {
    14.             var options = new InitializationOptions()
    15.                 .SetEnvironmentName(environment);
    16.  
    17.             await UnityServices.InitializeAsync(options);
    18.         }
    19.         catch (Exception exception)
    20.         {
    21.             // An error occurred during services initialization.
    22.         }
    23.     }
    24. }
    25.  
    Also tried just using UnityServices.InitializeAsync without all the other lines.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Your code is correct. Also, IAP will work without UGS initialization, you will receive a warning but it will still function. But you won't get dashboard revenue reporting. But you can still track your IAP revenue on the respective store dashboards.
     
  3. SnappleMessiah

    SnappleMessiah

    Joined:
    Jul 4, 2015
    Posts:
    14
    Any reason why the warning still populates? Also, why it wouldn't state UIAP will still function versus stating Unity IAP requires UGS to be initialized before use? In any event, thank you for your response! :)
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You didn't mention that you were still getting the warning, understood now. Are you sure you are initializing UGS before IAP? Please show your code for both. Use Debug.Log to confirm UGS initializes first.
     
  5. SnappleMessiah

    SnappleMessiah

    Joined:
    Jul 4, 2015
    Posts:
    14
    I had the UGS initialization in a separate script from Gley's IAP initialization, so I'm assuming the IAP initialization was being executed prior to UGS. I've now placed them both in the same Start method which seems to have solved the problem (no more warning!).
    - Script execution order is something I often overlook :confused:
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Don't guess, use Debug.Log to find out for sure!
     
  7. toru_inoue

    toru_inoue

    Joined:
    Aug 7, 2013
    Posts:
    8
    Last edited: Feb 25, 2023
  8. Dennis_eA

    Dennis_eA

    Joined:
    Jan 17, 2011
    Posts:
    375
    Hi @toru_inoue ,

    where can I find more info about what the custom?? symbol DISABLE_RUNTIME_IAP_ANALYTICS does? A Google search gives me no results. Thx