Пример #1
0
        /// <summary>
        /// Register callbacks and make first call to RemoteConfigDataManager, and initialize the UI.
        /// </summary>
        public void OnEnable()
        {
            Instance     = this;
            titleContent = new GUIContent("Remote Config Sync");

            // Initialize UI state if necessary.
            if (rootVisualElement.childCount == 0)
            {
                InitializeUI();
            }
            retrievingRemoteConfigData = false;

            SyncDataManager.DataRetrieved += RemoteConfigDataUpdatedCallback;
            SyncDataManager.DataUploaded  += RemoteConfigDataUpdatedCallback;
            SyncDataManager.RetrieveError += RemoteConfigErrorCallback;
            if (File.Exists(SyncDataManager.LocalFilePath))
            {
                var localContent = File.ReadAllText(SyncDataManager.LocalFilePath);
                RemoteConfigData            = RemoteConfigData.Deserialize(localContent);
                SyncDataManager.CurrentData = RemoteConfigData;
                ready = true;
                UpdateUI();
            }
            else if (!EditorApplication.isPlayingOrWillChangePlaymode)
            {
                GetRemoteConfigData();
            }
        }
Пример #2
0
        /// <summary>
        /// Deserialize the JSON RemoteConfigData into the CurrentData field.
        /// </summary>
        /// <param name="json">String data to deserialize.</param>
        private static void SetCurrentData(string json)
        {
            // Save to local docs file so it doesn't have to be retrieved on every compile time.
            if (!File.Exists(LocalFilePath))
            {
                File.Create(LocalFilePath).Close();
            }
            File.WriteAllText(LocalFilePath, json);

            CurrentData = RemoteConfigData.Deserialize(json);
        }