Hey guys, sorry for bothering with this question but to be honest I can’t find an answer or a way for making it work propperly.
I’m just starting with Addressables and I’m having problems with XML Files.
My main problem is: how can I get the path to the file so I can Serialize and Deserialize my XML Files?
I need the path to use with FileStream.
using(var stream = new FileStream(path, FileMode.Create))
{
serializer.Serialize(stream, this);
}
I have my required files as Addressables and selected with AssetReference in my scripts so there’s no problem with this. The main problem for me now is how to retrieve the path to load the file.
I tried with this but I know that it will not work. Which is the code that I need to use to have the path?
Hope you can help me and sorry if it was answered many times or something like this. I searched a lot and I managed to make a few things but this seems very easy and the fundamental function of the Addressables and the only solution that I found was deprecated.
You can’t serialize assets on runtime and treat it as addressable asset. If you need to somehow serialize data to xml and store it, you should just save them in Application.persistentDataPath or something like that.
If you’ve created an asset with XML file as textasset and you want to load it, you have to find a way to convert “xml string” to object. May be use StringReader?
Addressables hides all the interaction with file pathes. Tha’s whole point of using Addressables, so you can have unified workflow between remote/local/whatever file and retrieve file contents. May be you should not use Addressables with what you are trying to do.
Okay, I guess I missunderstood the use of Addressables in this case.
I was trying to use Addressable XML files to work with them believing it was an alternative to Resources.Load() or persistentDataPath without using specific directories and work in editor or on built in in every platform but I guess i took it wrong and persistentDataPath is a better solution for this. Right?
My objetive is creating an Inventory and save it into a XML file.
I will continue using persistentDataPath. Thank you for your time