Unity Pit-Compile error

Source: Internet
Author: User


There is a StreamReader in the project to read a file, using the OpenText () method.

But unity suggests that the StreamReader class does not contain the OpenText () method, and that no extension methods are found.


This is very strange, StreamReader is the System.IO under the class, inside is indeed there is this method, but why unity is prompted to find a method?

After a variety of Baidu, eventually found the cause of the problem, because the current unity platform using the Webplayer platform, and the Webplayer platform is unable to operate these,

That is, the file IO is limited and cannot be used, so unity will make an error.


The workaround is also simple, just need to switch to another platform.

Attached error code: error is the 10th line of code.

1      PublicXcplist (stringFpath)2         {3FilePath = Path.Combine (Fpath,"Info.plist" );4             if( !System.IO.File.Exists (FilePath)) {5Debug.logerror (FilePath +"file does not exist under path" );6                 return;7             }8 9FileInfo Projectfileinfo =NewFileInfo (filePath);TenStreamReader sr =Projectfileinfo.opentext (); One              while(Sr.) Peek () >=0)  A             { - contents. Add (Sr. ReadLine ()); -             } the Sr. Close (); -  -}

Unity Pit-Compile error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.