Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Windows Phone 8 Build Error (System.Byte[] System.IO.File . . .)

Discussion in 'Windows' started by randi23, Jun 23, 2014.

  1. randi23

    randi23

    Joined:
    Feb 17, 2014
    Posts:
    7
    Hi, I'm newbie here, when I try to buid & run my game for Windows Phone 8, I got this error :



    The 'GoSpline' class (and some other script) I use from other developer in Asset Store. This is 'nodeListFromAsset(System.String)' method :


    Code (CSharp):
    1. private static List<Vector3> nodeListFromAsset( string pathAssetName )
    2.     {
    3.         if( Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer )
    4.         {
    5.             Debug.LogError( "The Web Player does not support loading files from disk." );
    6.             return null;
    7.         }  
    8.      
    9.         var path = string.Empty;
    10.         if( !pathAssetName.EndsWith( ".asset" ) )
    11.             pathAssetName += ".asset";    
    12.      
    13.         if( Application.platform == RuntimePlatform.Android )
    14.         {
    15.             path = Path.Combine( "jar:file://" + Application.dataPath + "!/assets/", pathAssetName );
    16.      
    17.            WWW loadAsset = new WWW( path );
    18.            while( !loadAsset.isDone ) { } // maybe make a safety check here
    19.          
    20.             return bytesToVector3List( loadAsset.bytes );
    21.         }
    22.         else if( Application.platform == RuntimePlatform.IPhonePlayer )
    23.         {
    24.             // at runtime on iOS, we load from the dataPath
    25.             path = Path.Combine( Path.Combine( Application.dataPath, "Raw" ), pathAssetName );
    26.         }
    27.         else
    28.         {
    29.             // in the editor we default to looking in the StreamingAssets folder
    30.             path = Path.Combine( Path.Combine( Application.dataPath, "StreamingAssets" ), pathAssetName );          
    31.         }
    32.      
    33. #if UNITY_WEBPLAYER || NETFX_CORE
    34.         // it isnt possible to get here but the compiler needs it to be here anyway
    35.         return null;
    36. #else
    37.         var bytes = File.ReadAllBytes( path );
    38.         return bytesToVector3List( bytes );
    39. #endif
    40.     }

    I Think there is an error when try to load the asset from local resource on Windows Phone 8, or maybe it's not support ?

    Thanks,
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
  3. randi23

    randi23

    Joined:
    Feb 17, 2014
    Posts:
    7
    Thanks for your reply,
    I have try that, now the error has change to :


    How about that?
    Thanks
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    ConvertAll doesn't exist on Windows Phone.

    http://msdn.microsoft.com/en-us/library/windowsphone/develop/6sh2ey19(v=vs.105).aspx

    However, it should be pretty trivial to implement it yourself.

    Code (csharp):
    1. List<OutputType> ConvertAll<InputType, OutputType>(List<InputType> inputList, Func<InputType, OutputType> converter)
    2. {
    3.     var output = new List<OutputType>(inputList.Count);
    4.     for (int i = 0; i < inputList.Count; i++)
    5.     {
    6.         output.Add(converter(inputList[i]));
    7.     }
    8.  
    9.     return output;
    10. }
     
  5. randi23

    randi23

    Joined:
    Feb 17, 2014
    Posts:
    7

    OK, I will try later. I think my problem can be solved by that.
    Big Thanks anyway :D
     
  6. Amerging-Staar

    Amerging-Staar

    Joined:
    Jul 13, 2014
    Posts:
    3
    i hope that will work for me, but i cant implement that. Please help me :confused:

    Code (CSharp):
    1. Transform[] GetTransforms()
    2.     {
    3.                 if (SplineRoot != null)
    4.                 {
    5.                     List<Component> components = new List<Component>(SplineRoot.GetComponentsInChildren(typeof(Transform)));
    6.                     List<Transform> transforms = components.ConvertAll(c => (Transform)c);
    7.      
    8.                     transforms.Remove(SplineRoot.transform);
    9.                     transforms.Sort(delegate(Transform a, Transform b)
    10.                     {
    11.                         return a.name.CompareTo(b.name);
    12.                     });
    13.      
    14.                     return transforms.ToArray();
    15.                 }
    16.         return null;
    17.     }
    18. List<OutputType> ConvertAll<InputType, OutputType>(List<InputType> inputList, Func<InputType, OutputType> converter)
    19.     {
    20.         var output = new List<OutputType>(inputList.Count);
    21.         for (int i = 0; i < inputList.Count; i++)
    22.         {
    23.             output.Add(converter(inputList[i]));
    24.         }
    25.      
    26.         return output;
    27.     }
    It shows me Error
    Help me, i know there is a minor thing so i am feeling like a noob :(
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    It doesn't find Func delegate, which should be located in System namespace, do you have using System; written above?
     
  8. akkiDev

    akkiDev

    Joined:
    Aug 7, 2013
    Posts:
    70
  9. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Is your active platform in Editor is Windows Phone 8 or Windows Store Apps?
     
  10. matheuspb95

    matheuspb95

    Joined:
    Apr 16, 2015
    Posts:
    3
  11. m-sajjad

    m-sajjad

    Joined:
    May 27, 2015
    Posts:
    5
    this error is occur when i am going to build my project on widoew8
    i am also using leantween may be window is not suppoting leantween
    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-firstpass.dll at System.Collections.Generic.List`1<UnityEngine.Vector3> GoSpline::nodeListFromAsset(System.String).
    please any idea?
     
  12. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    Which version of Unity do you use? File.ReadAllBytes should be available in Unity 5.
     
  13. m-sajjad

    m-sajjad

    Joined:
    May 27, 2015
    Posts:
    5
    i am using unity 4.6.1f