Reference a ptototxt file from c++ plugin

I’m writing a plugin in c++ (for Android) where i need to use a prototxt file (or any other file like .txt or .png)
Where should i put those files in order for Unity to be able to find them?

i tried putting them in the Assets dir, but the app wasn’t able to find them.

Rather than trying to load the file from the plugin, the better idea would be to pass the text into the plugin.

You can store text within the project as TextAssets, and then access data at runtime. Just alter the plugin to load the data from a string it is given.

Or you could try placing your text file into StreamingAssets and then figure out where they went on android.

Thank you! that’s working for the prototxt file, which is basically a text file. i also have a binary file (.caffemodel), how can i add it as well without corrupting its contents

You can use TextAsset.bytes instead.

https://docs.unity3d.com/ScriptReference/TextAsset-bytes.html

This is counterintuitive (as it is a “text” asset while you want a “binary” data), but absolutely should work. You might need to pass the data size into the plugin as well.