Search Unity

Ressource.load fail when file is too long

Discussion in 'Scripting' started by Damerzone, Nov 14, 2017.

  1. Damerzone

    Damerzone

    Joined:
    Jul 8, 2015
    Posts:
    1
    Hi guys,

    I must say, I'm running out of solution. Here is the problem:

    I'm using the Ressource.Load API to load a json file in order to load my scene properties and when my JSON is too long, the file is just not loaded.

    Here is the code:

    Code (csharp):
    1.  
    2.  public static string LoadResourceTextfile(string path)
    3.     {
    4.  
    5.         TextAsset targetFile = Resources.Load(path) as TextAsset;
    6.  
    7.         Debug.Log("loaded:" + targetFile);
    8.  
    9.         return targetFile.text;
    10.     }
    11.  
    12.     public void InitInformation()
    13.     {
    14.         ProcessList m_jsonList = new ProcessList();
    15.         string text;
    16.  
    17.         text = LoadResourceTextfile("ProcessList/process");
    18.  
    19.         m_jsonList = m_jsonList.FromJson(text);
    20.  
    21.         foreach (Process process in m_jsonList.Process)
    22.         {
    23.             InstantiateProcess(process.ProcessName);
    24.         }
    25.  
    26.     }
    27.  
    I guess I'm doing this the wrong way, hope you'll help me !

    Regards,
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    What do you mean the file is too long? The file path or the contents of the file?
    What happens when you read it and its too long, is the contents different?
     
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    How big is your json file size? I have some fairly large ones in an app and have never had issues. Are you certain you just don't have an error in your json file that stops it?
     
    karl_jones likes this.