コード例 #1
0
        protected void SaveSheetFinished(BaseCloudDataSheet sheet, bool success)
        {
            m_NumSheetsToSave--;
#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(gameObject);
#endif
        }
コード例 #2
0
        protected void Awake()
        {
            s_Instance = this;

            if (defaultCloudDataSheet == null)
            {
                var sheets = GetComponentsInChildren <BaseCloudDataSheet>();
                defaultCloudDataSheet = (sheets != null && sheets.Length > 0) ? sheets[0] : null;
            }

#if UNITY_EDITOR
            if (String.IsNullOrEmpty(organizationId))
            {
                organizationId = UnityEditor.PlayerSettings.companyName;
            }
            if (String.IsNullOrEmpty(projectId))
            {
                projectId = UnityEditor.PlayerSettings.productName;
            }
            if (String.IsNullOrEmpty(accessToken))
            {
                Debug.LogError("[Unity Cloud Data] No AccessToken defined in CloudDataManager (required to use cloud data)!");
            }
#endif

            if (refreshSheetsOnAwake)
            {
                RefreshAll(null);
            }
        }
コード例 #3
0
 protected void PostWriteRefreshFinished(BaseCloudDataSheet sheet)
 {
     onRefreshCacheComplete -= PostWriteRefreshFinished;
     if (m_WriteFinishCallback != null)
     {
         m_WriteFinishCallback(this, true);
     }
 }
コード例 #4
0
        void OnDestroy()
        {
            if (defaultCloudDataSheet != null)
            {
                defaultCloudDataSheet.onLoadFromCacheComplete -= OnCloudDataSheetRefreshCacheComplete;
                defaultCloudDataSheet.onRefreshCacheComplete  -= OnCloudDataSheetRefreshCacheComplete;
            }

            m_DefaultSheet = null;
        }
コード例 #5
0
        void OnSheetRefreshComplete(BaseCloudDataSheet sheet)
        {
            m_RefreshingCount--;
            sheet.onRefreshCacheComplete -= OnSheetRefreshComplete;

            if (m_RefreshingCount == 0 && m_RefreshAllDel != null)
            {
                m_RefreshAllDel();
            }

            m_RefreshAllDel = null;
        }
コード例 #6
0
        // 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
            }
        }
コード例 #7
0
 protected virtual void OnCloudDataSheetRefreshCacheComplete(BaseCloudDataSheet sheet)
 {
     UpdateCloudDataFields();
 }