Exemple #1
0
        /// <summary> Produce a JSONObject by combining a JSONArray of names with the values
        /// of this JSONArray.
        /// </summary>
        /// <param name="names">A JSONArray containing a list of key strings. These will be
        /// paired with the values.
        /// </param>
        /// <returns> A JSONObject, or null if there are no names or if this JSONArray
        /// has no values.
        /// </returns>
        /// <throws>  JSONException If any of the names are null. </throws>
        public virtual JSONObject toJSONObject(JSONArray names)
        {
            if (names == null || names.length() == 0 || length() == 0)
            {
                return(null);
            }
            JSONObject jo = new JSONObject();

            for (int i = 0; i < names.length(); i += 1)
            {
                jo.put(names.getString(i), this.opt(i));
            }
            return(jo);
        }
    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
    }
Exemple #3
0
 /// <summary> Produce a JSONObject by combining a JSONArray of names with the values
 /// of this JSONArray.
 /// </summary>
 /// <param name="names">A JSONArray containing a list of key strings. These will be
 /// paired with the values.
 /// </param>
 /// <returns> A JSONObject, or null if there are no names or if this JSONArray
 /// has no values.
 /// </returns>
 /// <throws>  JSONException If any of the names are null. </throws>
 public virtual JSONObject toJSONObject(JSONArray names)
 {
     if (names == null || names.length() == 0 || length() == 0)
     {
         return null;
     }
     JSONObject jo = new JSONObject();
     for (int i = 0; i < names.length(); i += 1)
     {
         jo.put(names.getString(i), this.opt(i));
     }
     return jo;
 }