public static void Fetch() { string res; if (ResourceEditGetPoster.HttpGet("AssetProcessorDB", out res)) { try { JsonUtility.FromJsonOverwrite(res, AssetProcessorDB.DBInstance); EditorUtility.SetDirty(DBInstance); AssetDatabase.SaveAssets(); Debug.Log("Fetch ok."); } catch (Exception ex) { Debug.LogErrorFormat("{0}\n{1}", ex.Message, ex.StackTrace); } } }
public static bool Fetch(string dbKey, ResourceParamsDB db) { bool ret = false; string keysJson; if (ResourceEditGetPoster.HttpGet(dbKey, out keysJson)) { try { ret = true; var keys = JsonUtility.FromJson <ResourceKeys>(keysJson); int ct = 0; int totalCt = keys.Keys.Count; foreach (var key in keys.Keys) { string paramsJson; if (ResourceEditGetPoster.HttpGet(key, out paramsJson)) { try { var ps = JsonUtility.FromJson <ResourceParams>(paramsJson); db.AddOrMerge(key, ps); } catch (Exception ex) { Debug.LogErrorFormat("{0}\n{1}", ex.Message, ex.StackTrace); ret = false; } } ++ct; if (EditorUtility.DisplayCancelableProgressBar("Fetch", string.Format("{0}/{1}", ct, totalCt), ct * 1.0f / totalCt)) { break; } } if (ret) { Debug.Log("Fetch ok."); } } catch (Exception ex) { Debug.LogErrorFormat("{0}\n{1}", ex.Message, ex.StackTrace); } finally { EditorUtility.ClearProgressBar(); } } return(ret); }