Exemplo n.º 1
0
 public static void requestProducts(List<Purchasable> purchasables)
 {
     if (!m_iapInitComplete)
     {
         return;
     }
     #if UNITY_ANDROID && !UNITY_EDITOR
     JSONArray jsonArray = new JSONArray();
     int index = 0;
     foreach (Purchasable purchasable in purchasables)
     {
         jsonArray.put(index, purchasable.productId);
         ++index;
     }
     OuyaUnityPlugin.requestProducts(jsonArray.toString());
     jsonArray.Dispose();
     #endif
 }
Exemplo n.º 2
0
 /// <summary> Produce a JSONArray containing the values of the members of this
 /// JSONObject.
 /// </summary>
 /// <param name="names">A JSONArray containing a list of key strings. This
 /// determines the sequence of the values in the result.
 /// </param>
 /// <returns> A JSONArray of values.
 /// </returns>
 /// <throws>  JSONException If any of the values are non-finite numbers. </throws>
 public virtual JSONArray toJSONArray(JSONArray names)
 {
     if (names == null || names.length() == 0)
     {
         return null;
     }
     JSONArray ja = new JSONArray();
     for (int i = 0; i < names.length(); i += 1)
     {
         ja.put(this.opt(names.getString(i)));
     }
     return ja;
 }
Exemplo n.º 3
0
 /// <summary> Produce a JSONArray containing the names of the elements of this
 /// JSONObject.
 /// </summary>
 /// <returns> A JSONArray containing the key strings, or null if the JSONObject
 /// is empty.
 /// </returns>
 public virtual JSONArray names()
 {
     JSONArray ja = new JSONArray();
     System.Collections.IEnumerator keyIter = keys();
     while (keyIter.MoveNext())
     {
         ja.put(keyIter.Current);
     }
     return ja.length() == 0 ? null : ja;
 }
Exemplo n.º 4
0
    IEnumerator InvokeInitOuyaPlugin(bool wait)
    {
        if (wait)
        {
            yield return new WaitForSeconds(1f);
        }
        else
        {
            yield return null;
        }
        #if UNITY_ANDROID && !UNITY_EDITOR
        try
        {
            using (JSONArray jsonArray = new JSONArray())
            {
                int index = 0;
                foreach (OuyaGameObject.KeyValuePair kvp in OuyaPluginInitValues)
                {
                    try
                    {
                        using (JSONObject jsonObject = new JSONObject())
                        {
                            //Debug.Log(string.Format("key={0} value={1}", kvp.Key, kvp.Value));
                            jsonObject.put("key", kvp.Key);
                            jsonObject.put("value", kvp.Value);
                            jsonArray.put(index, jsonObject);
                        }
                    }
                    catch (Exception)
                    {

                    }
                    ++index;
                }

                string jsonData = jsonArray.toString();
                //Debug.Log("InvokeInitOuyaPlugin jsonData" + jsonData);

                OuyaSDK.initOuyaPlugin(jsonData);
            }
        }
        catch (Exception)
        {
            OnFailureInitializePlugin("Failed to invoke initOuyaPlugin.");
        }
        #endif
    }