Search Unity

How to get Resources file path on Android device?

Discussion in 'Scripting' started by Deleted User, Apr 24, 2019.

  1. Deleted User

    Deleted User

    Guest

    How to get Resources file path on Android device?
    I need a path to my code.

    Code (CSharp):
    1. string path;
    2. XmlDocument doc = new XmlDocument();
    3. doc.Load(path);
    Currently, I use:
    Code (CSharp):
    1. var textAsset = (TextAsset)Resources.Load("LevelsXML");
    2. XmlDocument doc = new XmlDocument();
    3. doc.LoadXml(textAsset.text);
    4.  
    5. LevelLoad = 1;
    6.  
    7. XmlNode node = doc.DocumentElement.SelectSingleNode("//level[@id='" + LevelLoad + "']");
    8. Debug.Log(node.InnerText);
    but Debug looks like:
    Code (CSharp):
    1. 1,1528920000000000000000000000000000000000000001110000000000110000000000110000000000000000000000000000000000000000000000000000000000000000000000000000004-44393-3404-3
    file looks like:
    Code (CSharp):
    1. <level id="1">
    2.     <time>1,152892</time>
    3.     <platform>000000000000000000000000000000000000000111000000000011000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000</platform>
    4.     <camera>
    5.       <posX>4</posX>
    6.       <posY>-4</posY>
    7.       <size>4</size>
    8.     </camera>
    9.     <moveBlock1>
    10.       <positionPlatform>39</positionPlatform>
    11.       <posX>3</posX>
    12.       <posY>-3</posY>
    13.     </moveBlock1>
    14.     <finishBlock1>
    15.       <positionPlatform>40</positionPlatform>
    16.       <posX>4</posX>
    17.       <posY>-3</posY>
    18.     </finishBlock1>
    19.   </level>
    Does not read the <> tags for me.
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Files and folders in the special Resources folder don't change between editor and build versions. The only difference is that they're all bundled up into a single asset file. If you're actually trying to load content through file IO, you're going about it in the wrong way. You should continue to do it the same way you do it in the editor, through Resources.Load -- or better yet just directly creating references in the inspector.