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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

XML in Assets root folder not in my App...

Discussion in 'iOS and tvOS' started by mmerlange, Oct 19, 2013.

  1. mmerlange

    mmerlange

    Joined:
    Jan 22, 2013
    Posts:
    9
    Hi,

    My app runs well on my computer.
    I need a couple of xml.
    So, at the start of my script, I tried to have dynamic paths such as Path.Combine(Application.dataPath, "myIcons.xml");
    myInventory.xml is at the root of the Assets folder.
    Works like a charm on my computer.

    But on the app (my first...), I get:
    Could not find file "/var/mobile/Applications/EA913129-B155-4790-A339-5AF4A8AD22E3/ProductName.app/Data/myIcons.xml"

    Anyone can help?

    Thanks and good we to everyone,
    Michaël
     
  2. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    When Unity makes a build, it doesn't know that you have script code that accesses files by name. Unity will package into the build everything it knows about from the various scenes you have. If your XML file was a text asset, then Unity would know about it. It's not, so getting these xml files into your application is your responsibility.
     
  3. mmerlange

    mmerlange

    Joined:
    Jan 22, 2013
    Posts:
    9
    Hi Thank you very much Graham,
    I learned so much through this problem.
    I tried various things but since I need my xml to be editable in ios, I understood that my xml must be stored in the Application.persistentDataPath (ie 'Documents' of ios)
    Graham, it seems that the "best" way is to use the new [PostProcessBuild] (http://docs.unity3d.com/Documentation/ScriptReference/PostProcessBuildAttribute.html). I tried a few scripts attached them as a component to a gameobject but I get compiler errors (The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?).

    What am I doing wrong please?

    Thanks again,
    Regards,
    Michaël