public override void OnFlowSettingsGUI() { if (GameData.settings == null) { GameData.settings = GameData.GetSettingsFile(); } var settings = GameData.settings; if (settings == null) { EditorGUILayout.HelpBox(string.Format(FlowAddon.MODULE_HAS_ERRORS, "Settings file not found (GameDataSettings)."), MessageType.Error); } else { GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel); if (this.editor == null) { this.editor = Editor.CreateEditor(settings); } if (this.editor != null) { this.editor.OnInspectorGUI(); } } }
private static string[] FindAndLoadScriptingAssemblies(string gameDataPath) { var gameDataSettings = GameDataSettings.Load(gameDataPath); // enumerate loaded assemblies by name and fullname var loadedAssemblies = ( from assembly in AppDomain.CurrentDomain.GetAssemblies() where assembly is AssemblyBuilder == false && string.IsNullOrEmpty(assembly.Location) == false let assemblyName = assembly.GetName(false) from name in new[] { assemblyName.Name, assemblyName.FullName } select new { name, assembly.Location } ).ToLookup(a => a.name, a => a.Location); // get scripting assemblies from gamedata settings and add all internal scripting assemblies with prefix "Assembly-" var scriptingAssemblies = (gameDataSettings.ScriptingAssemblies ?? Enumerable.Empty <string>()) .Union(loadedAssemblies.Where(k => k.Key.StartsWith("Assembly-", StringComparison.Ordinal)).Select(k => k.Key).Distinct()); var foundScriptingAssemblies = new HashSet <string>(); foreach (var assemblyName in scriptingAssemblies) { var path = assemblyName; // found as path if (File.Exists(path)) { foundScriptingAssemblies.Add(Path.GetFullPath(path)); continue; } path = loadedAssemblies[assemblyName].FirstOrDefault(); if (path != null && File.Exists(path)) { foundScriptingAssemblies.Add(Path.GetFullPath(path)); continue; } try { var assembly = AppDomain.CurrentDomain.Load(assemblyName); if (File.Exists(assembly.Location)) { foundScriptingAssemblies.Add(Path.GetFullPath(assembly.Location)); } continue; } catch (Exception loadError) { if (Settings.Current.Verbose) { Debug.LogWarning("Failed to load assembly with name '" + assemblyName + "':\r\n" + loadError); } } Debug.LogWarning("Failed to find scripting assembly with name '" + assemblyName + "'."); } return(foundScriptingAssemblies.ToArray()); }
protected override void OnInspectorGUI(GameDataSettings settings, GameDataServiceItem item, System.Action onReset, GUISkin skin) { if (settings == null) { return; } var data = FlowSystem.GetData(); if (data == null) { return; } GUILayout.Label("URL:"); var newKey = GUILayout.TextArea(settings.url); if (newKey != settings.url) { settings.url = newKey; UnityEditor.EditorUtility.SetDirty(settings); } UnityEditor.EditorGUI.BeginDisabledGroup(item.processing); if (GUILayout.Button(item.processing == true ? "Loading..." : "Load", skin.button) == true) { if (item.processing == false) { item.processing = true; // Connecting this.OnEditorAuth(item.authKey, (result) => { //UnityEditor.EditorApplication.delayCall += () => { this.StartCoroutine(this.GetData(settings.url, (res) => { if (res.hasError == false) { GameDataSystem.TryToSaveCSV(res.data); } item.processing = false; })); //}; }); } } UnityEditor.EditorGUI.EndDisabledGroup(); }
public override void EditorLoad(GameDataSettings settings, GameDataServiceItem item) { if (item.processing == false) { item.processing = true; // Connecting this.OnEditorAuth(item.authKey, (result) => { //UnityEditor.EditorApplication.delayCall += () => { this.StartCoroutine(this.GetData(settings, (res) => { if (res.hasError == false) { GameDataSystem.TryToSaveCSV(res.data); } item.processing = false; })); //}; }); } }
protected override void OnInspectorGUI(GameDataSettings settings, GameDataServiceItem item, System.Action onReset, GUISkin skin) { if (settings == null) { return; } var data = FlowSystem.GetData(); if (data == null) { return; } if (settings.url == null) { settings.url = string.Empty; } GUILayout.Label("URL:"); var newKey = GUILayout.TextArea(settings.url); if (newKey != settings.url) { settings.url = newKey; UnityEditor.EditorUtility.SetDirty(settings); } GUILayout.Label(string.Format("ETag: {0}", settings.eTag)); UnityEditor.EditorGUI.BeginDisabledGroup(item.processing); if (GUILayout.Button(item.processing == true ? "Loading..." : "Load", skin.button) == true) { this.EditorLoad(settings, item); } UnityEditor.EditorGUI.EndDisabledGroup(); }
protected override void OnInspectorGUI(GameDataSettings settings, GameDataServiceItem item, System.Action onReset, GUISkin skin) { if (settings == null) return; var data = FlowSystem.GetData(); if (data == null) return; GUILayout.Label("URL:"); var newKey = GUILayout.TextArea(settings.url); if (newKey != settings.url) { settings.url = newKey; UnityEditor.EditorUtility.SetDirty(settings); } UnityEditor.EditorGUI.BeginDisabledGroup(item.processing); if (GUILayout.Button(item.processing == true ? "Loading..." : "Load", skin.button) == true) { if (item.processing == false) { item.processing = true; // Connecting this.OnEditorAuth(item.authKey, (result) => { //UnityEditor.EditorApplication.delayCall += () => { this.StartCoroutine(this.GetData(settings.url, (res) => { if (res.hasError == false) { GameDataSystem.TryToSaveCSV(res.data); } item.processing = false; })); //}; }); } } UnityEditor.EditorGUI.EndDisabledGroup(); }
public override void OnInspectorGUI() { var gameDataAsset = (Object)this.target; var gameDataPath = FileAndPathUtils.MakeProjectRelative(AssetDatabase.GetAssetPath(gameDataAsset)); var assetPath = FileAndPathUtils.MakeProjectRelative(AssetDatabase.GetAssetPath(Selection.activeObject)); if (GameDataTracker.IsGameDataFile(assetPath) == false) { this.DrawDefaultInspector(); return; } if (this.lastAsset != gameDataAsset || this.gameDataSettings == null) { this.gameDataSettings = GameDataSettings.Load(gameDataPath); this.gameDataSettings.ScriptingAssemblies = this.gameDataSettings.ScriptingAssemblies ?? new string[0]; this.lastAsset = gameDataAsset; this.newScriptingAssembly = null; this.newScriptingAssemblyName = null; } GUI.enabled = true; GUILayout.Label(Path.GetFileName(gameDataPath), EditorStyles.boldLabel); this.gameDataSettings.Generator = (int)(GameDataSettings.CodeGenerator)EditorGUILayout.EnumPopup(Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_GENERATOR, (GameDataSettings.CodeGenerator) this.gameDataSettings.Generator); if (this.gameDataSettings.Generator != (int)GameDataSettings.CodeGenerator.None) { this.codeGenerationFold = EditorGUILayout.Foldout(this.codeGenerationFold, Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_GENERATION_LABEL); if (this.codeGenerationFold) { this.gameDataSettings.AutoGeneration = EditorGUILayout.Toggle(Resources.UI_UNITYPLUGIN_INSPECTOR_AUTO_GENERATION, this.gameDataSettings.AutoGeneration); var codeAsset = !string.IsNullOrEmpty(this.gameDataSettings.CodeGenerationPath) && File.Exists(this.gameDataSettings.CodeGenerationPath) ? AssetDatabase.LoadAssetAtPath <TextAsset>(this.gameDataSettings.CodeGenerationPath) : null; var assetAsset = !string.IsNullOrEmpty(this.gameDataSettings.AssetGenerationPath) && File.Exists(this.gameDataSettings.AssetGenerationPath) ? AssetDatabase.LoadAssetAtPath <ScriptableObject>(this.gameDataSettings.AssetGenerationPath) : null; if (codeAsset != null) { this.gameDataSettings.CodeGenerationPath = AssetDatabase.GetAssetPath(EditorGUILayout.ObjectField(Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_GENERATION_PATH, codeAsset, typeof(TextAsset), false)); } else { this.gameDataSettings.CodeGenerationPath = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_GENERATION_PATH, this.gameDataSettings.CodeGenerationPath); } if (this.gameDataSettings.Generator == (int)GameDataSettings.CodeGenerator.CSharpCodeAndAsset) { if (assetAsset != null) { this.gameDataSettings.AssetGenerationPath = AssetDatabase.GetAssetPath(EditorGUILayout.ObjectField(Resources.UI_UNITYPLUGIN_INSPECTOR_ASSET_GENERATION_PATH, assetAsset, typeof(ScriptableObject), false)); } else { this.gameDataSettings.AssetGenerationPath = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_INSPECTOR_ASSET_GENERATION_PATH, this.gameDataSettings.AssetGenerationPath); } } if ((this.gameDataSettings.Generator == (int)GameDataSettings.CodeGenerator.CSharp || this.gameDataSettings.Generator == (int)GameDataSettings.CodeGenerator.CSharpCodeAndAsset) && Path.GetExtension(this.gameDataSettings.CodeGenerationPath) != ".cs") { this.gameDataSettings.CodeGenerationPath = Path.ChangeExtension(this.gameDataSettings.CodeGenerationPath, ".cs"); } if (this.gameDataSettings.Generator == (int)GameDataSettings.CodeGenerator.CSharpCodeAndAsset && Path.GetExtension(this.gameDataSettings.AssetGenerationPath) != ".asset") { this.gameDataSettings.AssetGenerationPath = Path.ChangeExtension(this.gameDataSettings.AssetGenerationPath, ".asset"); } this.gameDataSettings.Namespace = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_NAMESPACE, this.gameDataSettings.Namespace); this.gameDataSettings.GameDataClassName = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_API_CLASS_NAME, this.gameDataSettings.GameDataClassName); this.gameDataSettings.DocumentClassName = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_DOCUMENT_CLASS_NAME, this.gameDataSettings.DocumentClassName); this.gameDataSettings.LineEnding = (int)(GameDataSettings.LineEndings)EditorGUILayout.EnumPopup( Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_LINE_ENDINGS, (GameDataSettings.LineEndings) this.gameDataSettings.LineEnding); this.gameDataSettings.Indentation = (int)(GameDataSettings.Indentations)EditorGUILayout.EnumPopup( Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_INDENTATION, (GameDataSettings.Indentations) this.gameDataSettings.Indentation); this.gameDataSettings.Options = (int)(CodeGenerationOptions)EditorGUILayout.EnumMaskField( Resources.UI_UNITYPLUGIN_INSPECTOR_CODE_OPTIONS, (CodeGenerationOptions)this.gameDataSettings.Options); } } this.scriptingAssembliesFold = EditorGUILayout.Foldout(this.scriptingAssembliesFold, Resources.UI_UNITYPLUGIN_INSPECTOR_SCRIPTING_ASSEMBLIES_LABEL); if (this.scriptingAssembliesFold) { for (var i = 0; i < this.gameDataSettings.ScriptingAssemblies.Length; i++) { var watchedAssetPath = this.gameDataSettings.ScriptingAssemblies[i]; var assetExists = !string.IsNullOrEmpty(watchedAssetPath) && (File.Exists(watchedAssetPath) || Directory.Exists(watchedAssetPath)); var watchedAsset = assetExists ? AssetDatabase.LoadMainAssetAtPath(watchedAssetPath) : null; if (watchedAsset != null) { this.gameDataSettings.ScriptingAssemblies[i] = AssetDatabase.GetAssetPath(EditorGUILayout.ObjectField(Resources.UI_UNITYPLUGIN_INSPECTOR_ASSET_LABEL, watchedAsset, typeof(Object), false)); } else { this.gameDataSettings.ScriptingAssemblies[i] = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_INSPECTOR_NAME_LABEL, watchedAssetPath); } } EditorGUILayout.Space(); this.newScriptingAssembly = EditorGUILayout.ObjectField("<" + Resources.UI_UNITYPLUGIN_INSPECTOR_ADD_ASSET_BUTTON + ">", this.newScriptingAssembly, typeof(Object), false); if (Event.current.type == EventType.repaint && this.newScriptingAssembly != null) { var assemblies = new HashSet <string>(this.gameDataSettings.ScriptingAssemblies); assemblies.Remove(""); assemblies.Add(AssetDatabase.GetAssetPath(this.newScriptingAssembly)); this.gameDataSettings.ScriptingAssemblies = assemblies.ToArray(); this.newScriptingAssembly = null; GUI.changed = true; } EditorGUILayout.BeginHorizontal(); this.newScriptingAssemblyName = EditorGUILayout.TextField("<" + Resources.UI_UNITYPLUGIN_INSPECTOR_ADD_NAME_BUTTON + ">", this.newScriptingAssemblyName); if (GUILayout.Button(Resources.UI_UNITYPLUGIN_INSPECTOR_ADD_BUTTON, EditorStyles.toolbarButton, GUILayout.Width(70), GUILayout.Height(18))) { var assemblies = new HashSet <string>(this.gameDataSettings.ScriptingAssemblies); assemblies.Remove(""); assemblies.Add(this.newScriptingAssemblyName); this.gameDataSettings.ScriptingAssemblies = assemblies.ToArray(); this.newScriptingAssemblyName = null; GUI.changed = true; this.Repaint(); } GUILayout.Space(5); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); GUILayout.Label(Resources.UI_UNITYPLUGIN_INSPECTOR_ACTIONS_GROUP, EditorStyles.boldLabel); if (EditorApplication.isCompiling) { EditorGUILayout.HelpBox(Resources.UI_UNITYPLUGIN_COMPILING_WARNING, MessageType.Warning); } else if (CoroutineScheduler.IsRunning) { EditorGUILayout.HelpBox(Resources.UI_UNITYPLUGIN_COROUTINE_IS_RUNNIG_WARNING, MessageType.Warning); } EditorGUILayout.BeginHorizontal(); GUI.enabled = !CoroutineScheduler.IsRunning && !EditorApplication.isCompiling; if (GUILayout.Button(Resources.UI_UNITYPLUGIN_INSPECTOR_EDIT_BUTTON)) { AssetDatabase.OpenAsset(gameDataAsset); this.Repaint(); } if (this.gameDataSettings.Generator != (int)GameDataSettings.CodeGenerator.None && string.IsNullOrEmpty(this.gameDataSettings.CodeGenerationPath) == false) { if (GUILayout.Button(Resources.UI_UNITYPLUGIN_INSPECTOR_RUN_GENERATOR_BUTTON)) { CoroutineScheduler.Schedule(Menu.GenerateCodeAndAssetsAsync(gameDataPath, ProgressUtils.ReportToLog(Resources.UI_UNITYPLUGIN_INSPECTOR_GENERATION_PREFIX + " ")), "generation::" + gameDataPath) .ContinueWith(_ => this.Repaint()); } } GUI.enabled = !CoroutineScheduler.IsRunning && !EditorApplication.isCompiling; if (GUILayout.Button(Resources.UI_UNITYPLUGIN_INSPECTOR_VALIDATE_BUTTON)) { CoroutineScheduler.Schedule(Menu.ValidateAsync(gameDataPath, ProgressUtils.ReportToLog(Resources.UI_UNITYPLUGIN_INSPECTOR_VALIDATION_PREFIX + " ")), "validation::" + gameDataPath) .ContinueWith(_ => this.Repaint()); } if (GUILayout.Button(Resources.UI_UNITYPLUGIN_INSPECTOR_BACKUP_BUTTON)) { this.Backup(gameDataPath); } if (GUILayout.Button(Resources.UI_UNITYPLUGIN_INSPECTOR_RESTORE_BUTTON)) { this.Restore(gameDataPath); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; if (GUI.changed) { this.gameDataSettings.Save(gameDataPath); } }
public override System.Collections.Generic.IEnumerator <byte> GetData(GameDataSettings settings, System.Action <GameDataResult> onResult) { if (Application.internetReachability == NetworkReachability.NotReachable) { onResult.Invoke(new GameDataResult() { hasError = true, errorText = "No Connection", data = string.Empty }); yield break; } if (Application.isPlaying == false || this.serviceManager.logEnabled == true) { if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) { UnityEngine.Debug.LogFormat("[ GameData ] Loading: {0}", settings.url); } } var eTag = settings.eTag; var eTagPrefsKey = "GameDataSystem.GoogleService.ETag"; if (PlayerPrefs.HasKey(eTagPrefsKey) == true) { eTag = PlayerPrefs.GetString(eTagPrefsKey); } #if !UNITY_SWITCH var www = UnityWebRequest.Get(settings.url); www.SetRequestHeader("ETag", eTag); www.SendWebRequest(); #else var form = new WWWForm(); form.AddField("ETag", eTag); var www = new WWW(settings.url, form); #endif #if UNITY_EDITOR if (Application.isPlaying == false) { while (www.isDone == false) { #if !UNITY_SWITCH var progress = www.downloadProgress; #else var progress = www.progress; #endif if (UnityEditor.EditorUtility.DisplayCancelableProgressBar("Wait a while", "...", progress) == true) { break; } } UnityEditor.EditorUtility.ClearProgressBar(); #if !UNITY_SWITCH eTag = www.GetResponseHeader("ETag"); #else www.responseHeaders.TryGetValue("ETag", out eTag); #endif if (eTag != null) { settings.eTag = eTag; PlayerPrefs.SetString(eTagPrefsKey, eTag); } } else { #endif while (www.isDone == false) { yield return(0); } #if !UNITY_SWITCH eTag = www.GetResponseHeader("ETag"); #else www.responseHeaders.TryGetValue("ETag", out eTag); #endif if (eTag != null) { PlayerPrefs.SetString(eTagPrefsKey, eTag); } #if UNITY_EDITOR } #endif #if !UNITY_SWITCH var data = www.downloadHandler.text; #else var data = www.text; #endif onResult.Invoke(new GameDataResult() { hasError = !string.IsNullOrEmpty(www.error), data = data, errorText = www.error }); www.Dispose(); www = null; }
public override void OnInspectorGUI() { var gameDataAsset = (Object)this.target; var gameDataPath = FileUtils.MakeProjectRelative(AssetDatabase.GetAssetPath(gameDataAsset)); if (Array.IndexOf(Settings.Current.GameDataPaths, FileUtils.MakeProjectRelative(AssetDatabase.GetAssetPath(Selection.activeObject))) == -1) { this.DrawDefaultInspector(); return; } if (this.lastAsset != gameDataAsset || this.gameDataSettings == null) { this.gameDataSettings = GameDataSettings.Load(gameDataPath); this.lastAsset = gameDataAsset; } GUI.enabled = true; GUILayout.Label(Path.GetFileName(gameDataPath), EditorStyles.boldLabel); this.gameDataSettings.Generator = (int)(GameDataSettings.CodeGenerator)EditorGUILayout.EnumPopup(Resources.UI_UNITYPLUGIN_WINDOWCODEGENERATOR, (GameDataSettings.CodeGenerator)this.gameDataSettings.Generator); if (this.gameDataSettings.Generator != (int)GameDataSettings.CodeGenerator.None) { this.gameDataSettings.AutoGeneration = EditorGUILayout.Toggle(Resources.UI_UNITYPLUGIN_WINDOWAUTOGENERATION, this.gameDataSettings.AutoGeneration); var codeAsset = !string.IsNullOrEmpty(this.gameDataSettings.CodeGenerationPath) && File.Exists(this.gameDataSettings.CodeGenerationPath) ? AssetDatabase.LoadAssetAtPath<TextAsset>(this.gameDataSettings.CodeGenerationPath) : null; var assetAsset = !string.IsNullOrEmpty(this.gameDataSettings.AssetGenerationPath) && File.Exists(this.gameDataSettings.AssetGenerationPath) ? AssetDatabase.LoadAssetAtPath<ScriptableObject>(this.gameDataSettings.AssetGenerationPath) : null; if (codeAsset != null) this.gameDataSettings.CodeGenerationPath = AssetDatabase.GetAssetPath(EditorGUILayout.ObjectField(Resources.UI_UNITYPLUGIN_WINDOWCODEGENERATIONPATH, codeAsset, typeof(TextAsset), false)); else this.gameDataSettings.CodeGenerationPath = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_WINDOWCODEGENERATIONPATH, this.gameDataSettings.CodeGenerationPath); if (gameDataSettings.Generator == (int)GameDataSettings.CodeGenerator.CSharpCodeAndAsset) { if (assetAsset != null) this.gameDataSettings.AssetGenerationPath = AssetDatabase.GetAssetPath(EditorGUILayout.ObjectField(Resources.UI_UNITYPLUGIN_WINDOWASSETGENERATIONPATH, assetAsset, typeof(ScriptableObject), false)); else this.gameDataSettings.AssetGenerationPath = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_WINDOWASSETGENERATIONPATH, this.gameDataSettings.AssetGenerationPath); } if ((this.gameDataSettings.Generator == (int)GameDataSettings.CodeGenerator.CSharp || this.gameDataSettings.Generator == (int)GameDataSettings.CodeGenerator.CSharpCodeAndAsset) && Path.GetExtension(this.gameDataSettings.CodeGenerationPath) != ".cs") this.gameDataSettings.CodeGenerationPath = Path.ChangeExtension(this.gameDataSettings.CodeGenerationPath, ".cs"); if (this.gameDataSettings.Generator == (int)GameDataSettings.CodeGenerator.CSharpCodeAndAsset && Path.GetExtension(this.gameDataSettings.AssetGenerationPath) != ".asset") this.gameDataSettings.AssetGenerationPath = Path.ChangeExtension(this.gameDataSettings.AssetGenerationPath, ".asset"); this.gameDataSettings.Namespace = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_WINDOWCODENAMESPACE, this.gameDataSettings.Namespace); this.gameDataSettings.GameDataClassName = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_WINDOWCODEGAMEDATACLASSNAME, this.gameDataSettings.GameDataClassName); this.gameDataSettings.DocumentClassName = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_WINDOWCODEENTRYCLASSNAME, this.gameDataSettings.DocumentClassName); this.gameDataSettings.LineEnding = (int)(GameDataSettings.LineEndings)EditorGUILayout.EnumPopup(Resources.UI_UNITYPLUGIN_WINDOWCODELINEENDINGS, (GameDataSettings.LineEndings)this.gameDataSettings.LineEnding); this.gameDataSettings.Indentation = (int)(GameDataSettings.Indentations)EditorGUILayout.EnumPopup(Resources.UI_UNITYPLUGIN_WINDOWCODEIDENTATION, (GameDataSettings.Indentations)this.gameDataSettings.Indentation); this.gameDataSettings.Options = (int)(GameDataSettings.CodeGenerationOptions)EditorGUILayout.EnumMaskField(Resources.UI_UNITYPLUGIN_WINDOWCODEOPTIONS, (GameDataSettings.CodeGenerationOptions)gameDataSettings.Options); } EditorGUILayout.Space(); GUILayout.Label(Resources.UI_UNITYPLUGIN_WINDOWACTIONSGROUP, EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); GUI.enabled = !CoroutineScheduler.IsRunning && !EditorApplication.isCompiling && string.IsNullOrEmpty(this.gameDataSettings.CodeGenerationPath) == false; if (GUILayout.Button(Resources.UI_UNITYPLUGIN_WINDOWEDITBUTTON)) { AssetDatabase.OpenAsset(gameDataAsset); } if (this.gameDataSettings.Generator != (int)GameDataSettings.CodeGenerator.None) { if (GUILayout.Button(Resources.UI_UNITYPLUGIN_WINDOWRUNGENERATORBUTTON)) { CoroutineScheduler.Schedule(Menu.GenerateCodeAndAssetsAsync(gameDataPath, ProgressUtils.ReportToLog(Resources.UI_UNITYPLUGIN_WINDOWGENERATIONPREFIX + " ")), "generation::" + gameDataPath); } } GUI.enabled = !CoroutineScheduler.IsRunning && !EditorApplication.isCompiling; if (GUILayout.Button(Resources.UI_UNITYPLUGIN_WINDOWVALIDATEBUTTON)) { CoroutineScheduler.Schedule(Menu.ValidateAsync(gameDataPath, ProgressUtils.ReportToLog(Resources.UI_UNITYPLUGIN_WINDOWVALIDATIONPREFIX + " ")), "validation::" + gameDataPath); } GUI.enabled = true; if (GUILayout.Button(Resources.UI_UNITYPLUGIN_WINDOWUNTRACTBUTTON)) { Settings.Current.RemoveGameDataPath(gameDataPath); Settings.Current.Save(); } EditorGUILayout.EndHorizontal(); if (GUI.changed) { this.gameDataSettings.Save(gameDataPath); } }
public override System.Collections.Generic.IEnumerator <byte> GetData(GameDataSettings settings, System.Action <GameDataResult> onResult) { if (Application.isPlaying == false || this.serviceManager.logEnabled == true) { Debug.LogFormat("[ GameData ] Loading: {0}", settings.url); } var eTag = settings.eTag; var eTagPrefsKey = "GameDataSystem.GoogleService.ETag"; if (PlayerPrefs.HasKey(eTagPrefsKey) == true) { eTag = PlayerPrefs.GetString(eTagPrefsKey); } var www = UnityWebRequest.Get(settings.url); www.SetRequestHeader("ETag", eTag); www.Send(); #if UNITY_EDITOR if (Application.isPlaying == false) { while (www.isDone == false) { if (UnityEditor.EditorUtility.DisplayCancelableProgressBar("Wait a while", "...", www.downloadProgress) == true) { break; } } UnityEditor.EditorUtility.ClearProgressBar(); eTag = www.GetResponseHeader("ETag"); if (eTag != null) { settings.eTag = eTag; PlayerPrefs.SetString(eTagPrefsKey, eTag); } } else { #endif while (www.isDone == false) { yield return(0); } eTag = www.GetResponseHeader("ETag"); if (eTag != null) { PlayerPrefs.SetString(eTagPrefsKey, eTag); } #if UNITY_EDITOR } #endif onResult.Invoke(new GameDataResult() { hasError = !string.IsNullOrEmpty(www.error), data = www.downloadHandler.text, errorText = www.error }); www.Dispose(); www = null; }