I am new to Unity. I have an Android library jar that I want to offer also as a plugin with Unity.
Within the library jar I have a folder html which contains a file temp.json. In the jar file (if I unzip it) the structure is like this: html/temp.json (Note here that jar works fine when running with any Android app outside Unity)
These are the steps that I followed to call my library through Unity:
1) Created folder Assets/Plugins/ Android in my Unity project hierarchy
2) Placed my library jar file there along with AndroidManifest.xml
3) Created a bridge.cs file that I use to call the functions in the jar file
Functions from the jar are called, but within the code of the jar somewhere on the Android side during the library lifecycle I call:
InputStream inputStream = MyClass.class.getClassLoader()
.getResourceAsStream("html/temp.json");
and I get a ResourceNotFound exception
From what I have read Unity ignores these files(like .json) when packaging. Therefore from what I understood in order to keep them in the Jar when packaging I created the following Unity structure:
Assets/Plugins/Android/assets/StreamingAssets/html/temp.json
I realise that any file that is placed within the StreamingAssets folder get copied in the assets folder of the library.
and in Java I call now:
inputStream = activity.getResources().getAssets().open("html/temp.json");
However I still get an exception that the file is not found.
Can anyone please help me/explain to me the procedure I have to follow to be able to read these files on the Java side while executing on Unity for Android?