private IEnumerator SetRandomValues(float timeDelay) { while (true) { Debug.Log("Setting new random values..."); store.SetBool(UnityEngine.Random.Range(0, 1) > 0.5, "BoolKey"); store.SetDouble(UnityEngine.Random.Range(0.0f, 1.0f), "DoubleKey"); store.SetString(strings[UnityEngine.Random.Range(0, strings.Length)], "StringKey"); store.Synchronize(); Debug.Log("Waiting for " + timeDelay + "seconds..."); yield return(new WaitForSecondsRealtime(timeDelay)); Debug.Log("done waiting"); } }
private void SetItem(string key, object value) { if (value == null) { if (IsRoaming) { _store.Remove(key); } else { _defaults.RemoveObject(key); } } else { TypeCode code = Type.GetTypeCode(value.GetType()); switch (code) { case TypeCode.String: if (IsRoaming) { _store.SetString(key, value.ToString()); } else { _defaults.SetString(value.ToString(), key); } break; case TypeCode.Int32: if (IsRoaming) { _store.SetLong(key, (long)value); } else { _defaults.SetInt((int)value, key); } break; case TypeCode.Double: if (IsRoaming) { _store.SetDouble(key, (double)value); } else { _defaults.SetDouble((double)value, key); } break; case TypeCode.Single: if (IsRoaming) { _store.SetDouble(key, (double)value); } else { _defaults.SetFloat((float)value, key); } break; case TypeCode.Boolean: if (IsRoaming) { _store.SetBool(key, (bool)value); } else { _defaults.SetBool((bool)value, key); } break; default: if (IsRoaming) { _store.SetValueForKey(IOSTypeConverter.ConvertToNSObject(value), new NSString(key)); } else { _defaults.SetValueForKey(IOSTypeConverter.ConvertToNSObject(value), new NSString(key)); } break; } } }
private void SetItem(string key, object value) { if (value == null) { if (IsRoaming) { _store.Remove(key); } else { _defaults.RemoveObject(key); } } else { TypeCode code = Type.GetTypeCode(value.GetType()); switch (code) { case TypeCode.String: if (IsRoaming) { _store.SetString(key, value.ToString()); } else { _defaults.SetString(value.ToString(), key); } break; case TypeCode.Int64: if (IsRoaming) { _store.SetLong(key, (long)value); } else { _defaults.SetInt((nint)value, key); } break; case TypeCode.Int32: if (IsRoaming) { _store.SetLong(key, (long)value); } else { _defaults.SetInt((int)value, key); } break; case TypeCode.Double: if (IsRoaming) { _store.SetDouble(key, (double)value); } else { _defaults.SetDouble((double)value, key); } break; case TypeCode.Single: if (IsRoaming) { _store.SetDouble(key, (double)value); } else { _defaults.SetFloat((float)value, key); } break; case TypeCode.Boolean: if (IsRoaming) { _store.SetBool(key, (bool)value); } else { _defaults.SetBool((bool)value, key); } break; default: if (IsRoaming) { _store[new NSString(key)] = IOSTypeConverter.ConvertToNSObject(value); } else { _defaults[key] = IOSTypeConverter.ConvertToNSObject(value); } break; } } if (_locality == ApplicationDataLocality.SharedLocal) { _defaults.Synchronize(); } }