Read TMX File as TextAsset
I'm creating a simple editor window to work as an automated map parser using a TMX file(from Tiled) as input and creating the whole thing using prefabs straight to the scene editor. I have a pretty good idea of how to do that already, with one little problem: I'm unable to open the TMX file as a TextAsset, because Unity seems to not recognize its extension as a valid TextAsset extension. So far the only way to access the file seems to be using C# standard library functions and accessing thee path directly which I think would be less than ideal(for one, I have no idea how that would work in different builds; but that's a topic for later, if needed.)
So, cutting short to the question: is there a way for me to tell Unity to open TMX as a TextAsset in the same way it'd do an XML? Would I have to associate the extension to some custom asset type I'll have to create for this?
Answer by Statement · Oct 11, 2015 at 08:57 AM
There shouldn't be any problem using System.IO.File to read the file in the editor. Alternatively, some people have put work in making their own custom format importers and build strongly typed representations with ScriptableObject derived scripts. I haven't done so myself but it looks feasible.
However, if you also need to access the file contents at runtime in builds, you can place the file in StreamingAssets and load it from Application.streamingAssetsPath. Alternatively, you could write a build script which copies or renames the TMX files to txt files and keep using TextAsset.
Thanks, plenty of resources there :V I'm going to use this one for now to convert the T$$anonymous$$X to an X$$anonymous$$L extension(since it is an X$$anonymous$$L anyway) and use it as a TextAsset. $$anonymous$$aybe later I'll deal with a custom asset with the data I want from it.
Your answer
Follow this Question
Related Questions
Customizing multi player 1 Answer
Deserializing XML not working with WebGL 1 Answer
leaderboard data - xml, database or PlayerPrefs 0 Answers
Reading XML on Mono Fails - IL2CPP works?! 0 Answers
Character Customization 0 Answers