public IEnumerator Download(Promise <bool> loadComplete) { using (UnityWebRequest www = new UnityWebRequest(Url, "GET", new DownloadHandlerBuffer(), null)) { www.timeout = 5000; #if UNITY_2017_2_OR_NEWER yield return(www.SendWebRequest()); #else yield return(www.Send()); #endif if ((int)www.responseCode >= 400) { Debug.LogErrorFormat("{0} - {1}", www.responseCode, www.url); throw new Exception("Response code invalid"); } if (www.downloadedBytes > int.MaxValue) { throw new Exception("Stream is larger than can be copied into byte array"); } var meshes = PointFileReader.Read(www.downloadHandler.data); foreach (Mesh m in meshes) { var go = new GameObject(); go.transform.parent = this.transform; go.AddComponent <MeshFilter>().sharedMesh = m; go.AddComponent <MeshRenderer>().material = new Material(ShaderOverride); } loadComplete.Resolve(true); } }
private void ChooseFileOfPoints_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog(); Nullable <bool> result = openFileDlg.ShowDialog(); if (result == true) { PointFileReader pointFileReader = new PointFileReader(); PointsFile.Content = result.Value; points.AddRange(pointFileReader.ReadPoints(new FileStream(openFileDlg.FileName, FileMode.Open, FileAccess.Read))); } ((Button)sender).IsEnabled = false; }