public IDisposable HttpGet(string url, Dictionary <string, string> headers, Action <string> onResponse) { return(ObservableWWW.Get(url, headers).Subscribe(onResponse)); }
protected override void OnBegin() { ObservableWWW.Get("http://liangxiegame.com/framework_package/get_all_package_info").Subscribe(response => { var responseJson = JObject.Parse(response); JArray packageInfosJson = responseJson ["all_package_info"] as JArray; var packageDatas = new List <PackageData> (); foreach (var demoInfo in packageInfosJson) { var name = demoInfo ["name"].Value <string> (); var package = packageDatas.Find(packageData => packageData.Name == name); if (package == null) { package = new PackageData() { Name = name, }; packageDatas.Add(package); } var version = demoInfo ["version"].Value <string> (); var url = demoInfo ["download_url"].Value <string> (); var installPath = demoInfo ["install_path"].Value <string> (); var release_note = demoInfo["release_note"].Value <string>(); var releaseItem = new ReleaseItem(version, release_note, "liangxie", "now"); package.PackageVersions.Add(new PackageVersion() { Version = version, DownloadUrl = url, InstallPath = installPath, Readme = releaseItem }); package.readme.AddReleaseNote(releaseItem); } packageDatas.ForEach(packageData => { packageData.PackageVersions.Sort((a, b) => GetVersionNumber(b.Version) - GetVersionNumber(a.Version)); packageData.readme.items.Sort((a, b) => GetVersionNumber(b.version) - GetVersionNumber(a.version)); }); mOnGet.InvokeGracefully(packageDatas); new PackageInfosRequestCache() { PackageDatas = packageDatas }.Save(); Finished = true; }, e => { mOnGet.InvokeGracefully(null); Log.E(e); }); }
private void OnGUI() { scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(400)); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("PersistanePath:"); GUILayout.TextField(Application.persistentDataPath); GUILayout.EndHorizontal(); if (GUILayout.Button("Go To Persistance")) { EditorUtility.RevealInFinder(Application.persistentDataPath); } DrawMenu(); isEnableGenerateClass = GUILayout.Toggle(isEnableGenerateClass, "auto generate class when build"); ResKitAssetsMenu.SimulateAssetBundleInEditor = GUILayout.Toggle(ResKitAssetsMenu.SimulateAssetBundleInEditor, "Simulation Mode"); GUILayout.BeginHorizontal(); GUILayout.Label("ResVersion:"); resVersion = GUILayout.TextField(resVersion); GUILayout.EndHorizontal(); if (GUILayout.Button("Generate Class")) { BuildScript.WriteClass(); AssetDatabase.Refresh(); } if (GUILayout.Button("Build")) { BuildWithTarget(EditorUserBuildSettings.activeBuildTarget); Close(); return; } if (GUILayout.Button("ForceClear")) { ForceClear(); } GUILayout.EndVertical(); GUILayout.Space(50); EditorGUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.Label("Url:"); mHttpUrl = GUILayout.TextField(mHttpUrl); GUILayout.EndHorizontal(); if (GUILayout.Button("Http Get")) { ObservableWWW.Get(mHttpUrl).Subscribe(response => { Log.E(response); }); } if (GUILayout.Button("Http Post")) { ObservableWWW.Get("http://127.0.0.1:8000/demo/save/?content=" + new OK().ToJson()).Subscribe(response => { Log.E(response); }); } }
protected override void OnBegin() { Dictionary <string, string> headers = null; if (User.Logined) { headers = new Dictionary <string, string>() { { "Authorization", "Token " + User.Token } }; } ObservableWWW.Get("http://liangxiegame.com/api/packages/", headers).Subscribe(response => { var responseJson = JArray.Parse(response); var packageInfosJson = responseJson; var packageDatas = new List <PackageData> (); foreach (var packageInfo in packageInfosJson) { var name = packageInfo["name"].Value <string>(); var package = packageDatas.Find(packageData => packageData.Name == name); if (package == null) { package = new PackageData() { Name = name, }; packageDatas.Add(package); } var version = packageInfo["version"].Value <string>(); var url = packageInfo["file"].Value <string>(); // download_url var installPath = packageInfo["install_path"].Value <string>(); var releaseNote = packageInfo["release_note"].Value <string>(); var createAt = packageInfo["create_at"].Value <string>(); var creator = packageInfo["creator"].Value <string>(); var releaseItem = new ReleaseItem(version, releaseNote, creator, DateTime.Parse(createAt)); var typeName = packageInfo["type"].Value <string>(); var accessRightName = packageInfo["access_right"].Value <string>(); var packageType = PackageType.FrameworkModule; switch (typeName) { case "fm": packageType = PackageType.FrameworkModule; break; case "s": packageType = PackageType.Shader; break; case "agt": packageType = PackageType.AppOrGameDemoOrTemplate; break; case "p": packageType = PackageType.Plugin; break; } var accessRight = PackageAccessRight.Public; switch (accessRightName) { case "public": accessRight = PackageAccessRight.Public; break; case "private": accessRight = PackageAccessRight.Private; break; } package.PackageVersions.Add(new PackageVersion() { Version = version, DownloadUrl = url, InstallPath = installPath, Type = packageType, AccessRight = accessRight, Readme = releaseItem, }); package.readme.AddReleaseNote(releaseItem); } packageDatas.ForEach(packageData => { packageData.PackageVersions.Sort((a, b) => GetVersionNumber(b.Version) - GetVersionNumber(a.Version)); packageData.readme.items.Sort((a, b) => GetVersionNumber(b.version) - GetVersionNumber(a.version)); }); mOnGet.InvokeGracefully(packageDatas); new PackageInfosRequestCache() { PackageDatas = packageDatas }.Save(); Finished = true; }, e => { mOnGet.InvokeGracefully(null); Log.E(e); }); }
public void LoadScript(Action loadDone) { //初始化资源加载 string dllPath = ""; if (dllPath != "") { //反射 if (ILRuntimeScriptSetting.Default.HotfixRunMode == HotfixCodeRunMode.Reflection) { //反射模式只支持Editor PC Android if (File.Exists(dllPath)) //支持File操作 或者存在 { LoadDll(dllPath); loadDone.InvokeGracefully(); } else { //不支持file操作 或者不存在,继续尝试 var path = dllPath; if (Application.isEditor) { path = "file://" + path; } ObservableWWW.GetAndGetBytes(path).Subscribe(bytes => { LoadDll(bytes); loadDone.InvokeGracefully(); }, e => { Debug.LogError("DLL加载失败:" + e); }); } } //ILR else { //ILRuntime基于文件流,所以不支持file操作的,得拷贝到支持File操作的目录 //这里情况比较复杂,Mobile上基本认为Persistent才支持File操作, //可寻址目录也只有 StreamingAsset var firstPath = ILRuntimeScriptSetting.DllFilePersistentFullPath; var secondPath = ILRuntimeScriptSetting.DllFileStreamingFullPath; if (!File.Exists(dllPath)) //仅当指定的路径不存在(或者不支持File操作)时,再进行可寻址 { dllPath = firstPath; if (!File.Exists(firstPath)) { //验证 可寻址目录2 var source = secondPath; var copyto = firstPath; Debug.Log("复制到第一路径:" + source); ObservableWWW.GetAndGetBytes(source) .Subscribe(bytes => { copyto.CreateDirIfNotExists4FilePath(); File.WriteAllBytes(copyto, bytes); //解释执行模式 ILRuntimeScriptSetting.Default.HotfixRunMode = HotfixCodeRunMode.ILRuntime; LoadDll(copyto); loadDone.InvokeGracefully(); }, e => { Debug.LogError("可寻址目录不包括DLL:" + source); }); return; } } //解释执行模式 LoadDll(dllPath); loadDone.InvokeGracefully(); } } else { // pc 模式 ILRuntimeScriptSetting.Default.HotfixRunMode = HotfixCodeRunMode.Editor; LoadDll(""); loadDone.InvokeGracefully(); } }