public static async Task Main() { Write("Enter URL:> "); var url = ReadLine(); var uri = new Uri(url); var request = HttpWebRequestExt.Create(uri) .DoNotTrack() .Accept(Any); using var response = await request .GetAsync() .ConfigureAwait(false); var contentType = Lookup(response.ContentType); WriteLine($"Status {response.StatusCode}"); WriteLine($"Content-Type {contentType.Value}"); WriteLine($"Content-Length {response.ContentLength}"); var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var fileName = Path.Combine(desktop, PathExt.FixPath(uri.PathAndQuery.Substring(1))); var fileExt = Path.GetExtension(fileName).Substring(1); if (contentType?.PrimaryExtension is object && !contentType.Extensions.Contains(fileExt)) { fileName += "." + contentType.PrimaryExtension; } var file = new FileInfo(fileName); file.Directory.Create(); using var outStream = file.Create(); using var body = response.GetResponseStream(); using var progStream = new ProgressStream(body, response.ContentLength, new ConsoleProgress(), false); await progStream.CopyToAsync(outStream) .ConfigureAwait(false); }
public void FixPath1() { var path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var fixedPath = PathExt.FixPath(path); Assert.AreEqual(path, fixedPath); }
public override void Activate() { var targetGroup = Project.CurrentBuildTargetGroup; if (targetGroup == BuildTargetGroup.Android) { if (Name == "GoogleARCore") { PlayerSettings.Android.ARCoreEnabled = true; } else if (Name == "GoogleVR") { FileExt.Copy( PathExt.FixPath("Assets/GoogleVR/Plugins/Android/AndroidManifest-6DOF.xml"), PathExt.FixPath("Assets/Plugins/Android/AndroidManifest.xml"), true); } } else if (targetGroup == BuildTargetGroup.iOS) { if (Name == "UnityARKitPlugin") { ApplleiOS.RequiresARKitSupport = true; if (string.IsNullOrEmpty(PlayerSettings.iOS.cameraUsageDescription)) { PlayerSettings.iOS.cameraUsageDescription = "Augmented reality camera view"; } } } }
public void FixPath2() { var path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var brokenPath = path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); Assert.AreNotEqual(path, brokenPath); var fixedPath = PathExt.FixPath(brokenPath); Assert.AreEqual(path, fixedPath); }
/// <summary> /// When called from the Unity Editor, loads an asset from disk to use as a property in /// a Unity component. /// </summary> /// <param name="path"></param> /// <returns></returns> public static T EditorLoadAsset <T>(string path) where T : Object { var fixedPath = PathExt.FixPath(path); if (File.Exists(fixedPath)) { return(UnityEditor.AssetDatabase.LoadAssetAtPath <T>(fixedPath)); } else { return(UnityEditor.AssetDatabase.GetBuiltinExtraResource <T>(path)); } }
/// <summary> /// When called from the Unity Editor, loads an audio clip from disk to use as a property in /// a Unity component. /// </summary> /// <param name="path"></param> /// <returns></returns> public static T LoadAsset <T>(string path) where T : Object { return(Resources.Load <T>(PathExt.FixPath(path))); }
/// <summary> /// When called from the Unity Editor, loads an un-typed asset that can be inspected /// as a SerializedObject. /// </summary> /// <param name="path"></param> /// <returns></returns> public static UnityEditor.SerializedObject EditorLoadAsset(string path) { return(UnityEditor.AssetDatabase.LoadAllAssetsAtPath(PathExt.FixPath(path)) .Select(obj => new UnityEditor.SerializedObject(obj)) .FirstOrDefault()); }
/// <summary> /// When called from the Unity Editor, loads un-typed assets that can be inspected /// as SerializedObjects. /// </summary> /// <param name="path"></param> /// <returns></returns> public static IEnumerable <UnityEditor.SerializedObject> EditorLoadAllAssets(string path) { return(UnityEditor.AssetDatabase.LoadAllAssetsAtPath(PathExt.FixPath(path)) .Select(obj => new UnityEditor.SerializedObject(obj))); }