public override void Test()
        {
            ISN_NSUbiquitousKeyValueStore.Synchronize();


            //Probably need to add more data types to test later.
            //but we only save string on iOS part so this should be enouph
            string testString = "testString";

            ISN_NSUbiquitousKeyValueStore.SetString("test_key_string", testString);
            ISN_NSKeyValueObject kvObject = ISN_NSUbiquitousKeyValueStore.KeyValueStoreObjectForKey("test_key_string");

            if (!kvObject.StringValue.Equals(testString))
            {
                SetResult(SA_TestResult.WithError("String value is wrong"));
                return;
            }


            ISN_NSUbiquitousKeyValueStore.Reset();



            SetResult(SA_TestResult.OK);
        }
Beispiel #2
0
        public ISN_NSKeyValueObject KeyValueStoreObjectForKey(string key)
        {
            string val = PlayerPrefs.GetString(key);

            if (string.IsNullOrEmpty(val))
            {
                return(null);
            }
            var obj = new ISN_NSKeyValueObject(key, val);

            return(obj);
        }
Beispiel #3
0
        void OnGUI()
        {
            if (GUI.Button(new Rect(170, 70, 150, 50), "Set String"))
            {
                ISN_NSUbiquitousKeyValueStore.SetString("string key", "string value");
            }

            if (GUI.Button(new Rect(170, 130, 150, 50), "Get String"))
            {
                ISN_NSKeyValueObject kvObject = ISN_NSUbiquitousKeyValueStore.KeyValueStoreObjectForKey("string key");

                if (kvObject != null)
                {
                    Debug.Log("key: " + kvObject.Key + " value: " + kvObject.StringValue);
                }
                else
                {
                    Debug.Log("ICloud key Not found");
                }
            }

            if (GUI.Button(new Rect(330, 70, 150, 50), "Set Float"))
            {
                valueF += 1.1f;
                ISN_NSUbiquitousKeyValueStore.SetFloat("float key", valueF);
            }

            if (GUI.Button(new Rect(330, 130, 150, 50), "Get Float"))
            {
                ISN_NSKeyValueObject kvObject = ISN_NSUbiquitousKeyValueStore.KeyValueStoreObjectForKey("float key");

                if (kvObject != null)
                {
                    Debug.Log("key: " + kvObject.Key + " FloatValue: " + kvObject.FloatValue);
                }
                else
                {
                    Debug.Log("ICloud key Not found");
                }
            }

            if (GUI.Button(new Rect(490, 70, 150, 50), "Set Bytes"))
            {
                byte[] data = Encoding.UTF8.GetBytes("bytes value");
                ISN_NSUbiquitousKeyValueStore.SetBytes("bytes key", data);
            }

            if (GUI.Button(new Rect(490, 130, 150, 50), "Get Bytes"))
            {
                ISN_NSKeyValueObject kvObject = ISN_NSUbiquitousKeyValueStore.KeyValueStoreObjectForKey("bytes key");

                if (kvObject != null)
                {
                    Debug.Log("key: " + kvObject.Key + " value: " + kvObject.BytesArrayValue);

                    Debug.Log("StringData = " + kvObject.StringValue);
                    for (int i = 0; i < kvObject.BytesArrayValue.Length; i++)
                    {
                        Debug.Log("bytes " + kvObject.BytesArrayValue[i]);
                    }
                }
                else
                {
                    Debug.Log("ICloud key Not found");
                }
            }
        }