示例#1
0
    public static void InitPurchaseSDK(string url, string userID, string platformType, string productIdJsonArray, string gameID, string token, string scene = null)
    {
        Debug.Log("into InitPurchaseSDK");
        Debug.Log("url " + url);
        Debug.Log("userID " + userID);
        Debug.Log("platformType " + platformType);
        Debug.Log("productIdJsonArray " + productIdJsonArray);
        Debug.Log("gameID " + gameID);
        Debug.Log("token " + token);
        Debug.Log("scene " + scene);
        Debug.Log("base64PublicKey " + base64PublicKey);

        isUseStaticInit = true;

        if (Instance == null)
        {
            Debug.Log("Initialize SdkdsPurchase");
            GameObject gameobject = GameObject.Find("PurchaseUtil");
            if (gameobject == null)
            {
                gameobject = new GameObject("PurchaseUtil");
            }
            if (gameobject != null)
            {
                gameobject.AddComponent <SdkdsPurchaseUtils> ();
            }
        }

#if (UNITY_EDITOR || DISBLE_PLATFORM)
#elif UNITY_ANDROID
        gpPaySdkUtils_unity = SdkdsPurchaseUtils.LoadJavaClass("com.sdkds.gppay.PaySdk");
        // set debug
        Instance.setDebug(isDebugMode);
        //game object that can receive unity msg
        string unity_msg_receiver = "PurchaseUtil";

        if (scene == null)
        {
            gpPaySdkUtils_unity.CallStatic("SdkdsInitPurchase", SingletonHolder.instance_context, base64PublicKey, url, gameID, userID, platformType, productIdJsonArray, token, unity_msg_receiver);
        }
        else
        {
            gpPaySdkUtils_unity.CallStatic("SdkdsInitPurchase", SingletonHolder.instance_context, base64PublicKey, url, gameID, userID, platformType, productIdJsonArray, token, scene, unity_msg_receiver);
        }
#elif UNITY_IOS || UNITY_IPHONE
        SDKDSInitPurchaseUtils();
        if (scene == null)
        {
            Debug.Log("init Static Purchase scene is null");
            SDKDSInitPurchase(url, userID, platformType, productIdJsonArray, gameID, token);
        }
        else
        {
            Debug.Log("init Static Purchase scene is " + scene);
            SDKDSInitPurchase(url, userID, platformType, productIdJsonArray, gameID, token, scene);
        }
#else
#endif
    }