Program Issues Going From Unity To HoloLens - Cannot convert from 'string' to 'System.IO.Stream'

前端 未结 2 1067
暗喜
暗喜 2021-01-22 13:20

I have a program written in Unity using C# that initializes a new StreamReader and proceeds to read the text data from a text file I have stored in Unity\'s resources folder. Ev

相关标签:
2条回答
  • 2021-01-22 13:49

    I agree with the others, this is likely caused by a diffence between mono in the editor and the .net that you are compiling with to get a UWP application. Try this instead:

    using(StreamReader sr = new StreamReader(new FileStream(Application.dataPath + metadata, FileMode.Open)))
    

    This should be legal mono and .net code.

    0 讨论(0)
  • 2021-01-22 14:02

    The API differs in some cases between Unity Mono and .NET on UWP. It could be the StremReader(string) ctor is missing from the UWP version.

    For instance, I had a case where Delegate.CreateInstance works in Editor but fails on Hololens and requires a different version.

    You can wrap things in macros or use the one UWP requires.

    0 讨论(0)
提交回复
热议问题