Search Unity

Question Android app with configuration file

Discussion in 'Editor & General Support' started by Michael512, Jan 17, 2023.

  1. Michael512

    Michael512

    Joined:
    Jan 26, 2015
    Posts:
    10
    Hello,

    I have a configuration file named "App" located at "Assets/Resources/App".
    I dont have any issue reading it from Unity Editor, but obvisouly, when deployed on mobile, the path is not good anymore.

    I tried things like this but path is still not good and leads to a FileNotFoundException

    Code (CSharp):
    1. #if UNITY_EDITOR
    2.             streamReader = new StreamReader("Assets/Resources/App");
    3. #else
    4.  
    5.             streamReader = new StreamReader(Application.persistentDataPath + @"/App");
    6. #endif
    Do I have to put config file to a specific directory when building on mobile ?
    I spent some time this morning looking for any answers, but most of them leads to "use PlayerPref".
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Michael512 likes this.
  3. Michael512

    Michael512

    Joined:
    Jan 26, 2015
    Posts:
    10