Hello everyone.
The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Options
Load XML Files on HoloLens in runtime
Hello,
For my 3d maps project I'm trying load XML file that consists of the building heights and shapes. I have about 100 .xml files, and I created each of them as a serialized version of my data structure called MeshData. To load them in runtime, I got helped from @HoloSheep 's posts;
https://forums.hololens.com/discussion/comment/7133/#Comment_7133
https://forums.hololens.com/discussion/comment/10580#Comment_10580'
However, it didn't workout for me since I didn't know how and where to put my XML files in HoloLens. I cannot make my program to find the xml files, although I uploaded them in the assets of mu Unity projects. Here is my code;
private GameObject _container; private void BuildVectorTile() { _container = new GameObject("Buildings"); _container.transform.SetParent(tileObject.transform, true); string xmlText = ""; Stream stream2 = null; //MemoryStream xmlStream = new MemoryStream(); XmlSerializer ser = new XmlSerializer(typeof(MeshData)); for (int i = 0; i < 99; i++) { #if WINDOWS_UWP Task task = new Task( async () => { StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(MeshFolderName); StorageFile file = await folder.GetFileAsync("foo0.xml"); //var xmlFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///" + "foo" + i + ".xml")); //Windows.Data.Xml.Dom.XmlDocument xdoc = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(xmlFile); //xmlText = xdoc.GetXml(); //xdoc.Save( xmlStream ); stream2 = await file.OpenStreamForReadAsync(); }); try { task.Start(); task.Wait(); } catch (Exception e) { Debug.Log(e); throw; } using (var stream = stream2) { MeshData newFoo = (MeshData)ser.Deserialize(stream); CreateGameObject(newFoo, _container); } #else using (var stream = File.OpenRead("C:\\Users\\yusuf\\Documents\\FinalExported\\" + "foo" + i + ".xml")) { MeshData newFoo = (MeshData)ser.Deserialize(stream); CreateGameObject(newFoo, _container); } #endif } }
Help please.
0
Answers
@yusuf
If you are deploying the files with the app package, you will want to use the
await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///" + "foo" + i + ".xml"));
syntax.
Be sure to set the properties correctly on those files in visual studio:
HTH
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
Thanks a lot @HoloSheep ! Using
var xmlFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///" + "foo" + i + ".xml"));
, and changing the foo.xml's properties (Copy if newer), it worked!Now I have a follow-up question though. After the above code,
xmlFile
returns a System.__ComObject. When I pass that object tostream2 = await xmlFile.OpenStreamForReadAsync();
, and try to use thestream2
inMeshData newFoo = (MeshData)ser.Deserialize(stream2);
, it gives the following error;"There is an error in XML document (1, 31)."
Please see picture;