public override void InsertValue(string key, object val, System.Type fieldType) { // Make sure this key hasn't been queued up already and create a write queue entry string formattedValue = CloudDataTypeSerialization.SerializeValue(val, fieldType); int count = m_WriteQueue.Count(item => (item.sheetKey == key)); if (count == 0) { m_WriteQueue.Enqueue(GetInsertQueueEntry(key, formattedValue)); } }
// Finds all fields in current object with the CloudDataField attribute and attempts to set the value from cloud data public virtual void UpdateCloudDataFields(bool forceInsertNewValues = false) { var cloudDataFields = GetAllCloudDataFields(); foreach (var pair in cloudDataFields) { var info = pair.Key; var cloudDataAttr = pair.Value; // try to load the custom cloud data sheet specified by the attribute BaseCloudDataSheet sheet = defaultCloudDataSheet; if (cloudDataAttr.sheetPath != null) { sheet = CloudDataManager.GetSheet(cloudDataAttr.sheetPath); if (sheet == null) { Debug.LogWarning(string.Format("[CloudDataField] No CloudDataSheet with path '{0}' found for {1}.{2}", cloudDataAttr.sheetPath, this.GetType().FullName, info.Name)); } } // make sure a sheet was found if (sheet == null) { Debug.LogWarning(string.Format("[CloudDataField] No cloud data sheet found for field {0}.{1}", this.GetType().FullName, info.Name)); continue; } // get the key for this field and check if the sheet contains it string cloudDataKey = this.GetType().FullName + "." + info.Name; if (sheet.ContainsKey(cloudDataKey)) { object newFieldValue = sheet.GetValue(cloudDataKey); CloudDataTypeSerialization.DeserializeValue(this, info, newFieldValue); } #if UNITY_EDITOR else if (forceInsertNewValues || (CloudDataManager.instance.autoSaveNewFieldsToCloudOnPlay && Application.isPlaying)) { object newVal = info.GetValue(this); sheet.InsertValue(cloudDataKey, newVal, info.FieldType); } #endif } }