Unity Community

Results 1 to 14 of 14

  1. Posts

    Getting a .txt file onto the iPhone

    Hi guys,

    I've got an app that stores its level data in a couple different .txt files. It reads, parses, and can write the text files just fine.

    Here's my problem. One of the text files I want to be able to be downloaded from a server. That works fine. The other one I want to come from the build. For some reason, even though I have a documents folder (with the txt files) inside the asset folder, when I do a build, it doesn't seem to copy the txt files over to the iPhone. (my reader function errors out saying the file doesn't exist)

    what do I have to do to get the txt file from the Asset folder into the iPhone build?

  2. Location
    Santa Fe, New Mexico, USA
    Drop it into the Resources folder
    That's what I've done for localization strings.

  3. Posts
    Where is the Resources Folder? Is that somewhere in the Assets folder that I'm missing?

  4. Location
    Zürich, Switzerland
    Its in there after you created it within the Assets folder

  5. Posts
    So I created a Resources folder under /Assets, dropped the text files in there, built the game, and the iphone is still reporting that the files don't exist

  6. Location
    Zürich, Switzerland
    and you loaded it through
    1. TextAsset test = Resources.Load("nameOfTextfile") as TextAsset;
    2. Debug.Log(test.text);

    anything thats in the project will not end as distinct accessable file on the device (with exception of the StreamingAssets folder, unsure though what types are supported there), they will end in as assets you load with Resources.load or have assigned directly on a component

  7. Posts
    Is that Javascript?

    When I tried your code I got a "; expected" error.

    I tried it this way:

    1. var text : TextAsset = Resources.Load("nameOfTextfile");

    Which gave me an "Ambiguous Resources" error

  8. Location
    Virginia, USA
    Does naming your var something other than 'text' make a difference?

  9. Posts
    Doesn't matter what the variable name is. I've changed it a hundred times and it still doesn't work.

    I don't get it. I typed it in exactly like what was shown in the example in the scripting docs and I'm still getting the "ambiguous reference" error.

  10. Posts
    Do you have multiple files in that directory with the same first name but different extensions?
    Slender Man Chapter 1:Alone [Google Play Store] [iTunes]

    Slender Man Chapter 2:Survive [Google Play Store] [iTunes]

  11. Posts
    Nope. I have two files: extraLevels.txt and levels.txt

  12. Location
    Zürich, Switzerland
    expand the Resources.Load call to Resources.Load("textFilePath", typeof(TextAsset)) in C# or Resources.Load("textFilePath",TextAsset) in UnityScript so it explicitely filters for text assets only

  13. Posts
    Tried that already. Same Problem.

    I'm using the Indie version of 1.7 (for the iPhone). would that have anything to do with it?

  14. Posts
    Alright! Got it working.

    Instead of worrying about using Resources.Load or anything like that, I just created a text Asset var and dragged the .txt files onto them in the editor. works much easier! Don't know why I didn't think of that sooner!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts