NGUI – Free Version won’t compile for WP8 – How to FIX

So I am working on porting the Skeleton Dude starter kit I built to Windows Phone from Windows 8 Store and ran into the following problem…

“Error building Player: Exception: Error: method `System.Byte[] System.IO.File::ReadAllBytes(System.String)` doesn’t exist in target framework. It is referenced from Assembly-CSharp.dll at System.Byte[] NGUITools::Load(System.String).”

NGUIPhone8Issue

If you click on the error, it doesn’t navigate you anywhere useful.  Luckily after a few scans through the NGUI source code the issue is easy enough to find.  Look for the block of code in NGUITools.cs around line 769.

/// <summary>

/// Load all binary data from the specified file.

/// </summary>

staticpublicbyte[] Load (stringfileName)

{

#if UNITY_WEBPLAYER || UNITY_FLASH || UNITY_METRO

return null;

#else

if (!NGUITools.fileAccess) returnnull;

stringpath=Application.persistentDataPath+“/”+fileName;

if (File.Exists(path))

{

returnFile.ReadAllBytes(path);

}

returnnull;

#endif

}

 

Simply change the pre-compilation directive to the following check:

#if UNITY_WEBPLAYER || UNITY_FLASH || UNITY_METRO || UNITY_WP8

returnnull;

#else

 

4 thoughts on “NGUI – Free Version won’t compile for WP8 – How to FIX

    • I’m glad to have helped. If you run into any other issues, make sure you make use of the contact section of the page and I can help out.

Leave a Reply

Your email address will not be published. Required fields are marked *