Author Topic: NGUI 3.5.9 build error on windows apps store  (Read 3918 times)

MasashiWada

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
NGUI 3.5.9 build error on windows apps store
« on: May 10, 2014, 01:06:25 PM »
Windows Store Apps is not available System.IO.File class.
You can UnityEngine.Windows.File.ReadAllBytes.

ByteReader.cs
   static public ByteReader Open (string path)
   {
      FileStream fs = File.OpenRead(path);

      if (fs != null)
      {
         fs.Seek(0, SeekOrigin.End);
         byte[] buffer = new byte[fs.Position];
         fs.Seek(0, SeekOrigin.Begin);
         fs.Read(buffer, 0, buffer.Length);
         fs.Close();
         return new ByteReader(buffer);
      }
      return null;
   }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.5.9 build error on windows apps store
« Reply #1 on: May 11, 2014, 12:33:17 AM »
More WSA/WS8 fun... Change this function to be:
  1.         static public ByteReader Open (string path)
  2.         {
  3. #if UNITY_EDITOR || (!UNITY_FLASH && !NETFX_CORE && !UNITY_WP8)
  4.                 FileStream fs = File.OpenRead(path);
  5.  
  6.                 if (fs != null)
  7.                 {
  8.                         fs.Seek(0, SeekOrigin.End);
  9.                         byte[] buffer = new byte[fs.Position];
  10.                         fs.Seek(0, SeekOrigin.Begin);
  11.                         fs.Read(buffer, 0, buffer.Length);
  12.                         fs.Close();
  13.                         return new ByteReader(buffer);
  14.                 }
  15. #endif
  16.                 return null;
  17.         }

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: NGUI 3.5.9 build error on windows apps store
« Reply #2 on: May 11, 2014, 07:17:00 AM »
You can take a look at this repo:
https://github.com/windowsgamessamples/UnityPorting/tree/master/PlatformerPlugin/MyPluginUnity

It contains some useful thing for WP8/WSA. The thing is that in WP8/WSA everything as to be async and ReadAllByte is not. The functions in Legacy/System/IO/File.cs are using an async way. Try using these functions