- Home /
How to access or reference assets from Unity's Assets folder in Android plugin library?
I have a font that I am using to design and edit scenes in Unity. I am having an android plugin library that displays native AlertDialog
in android. I want the dialog to display message using same font I use in Unity. I have placed that font in Unity's Assets/Fonts folder. I know that when font is used in any scene, it gets copied to final build apk. Now I want to access the same font and Android plugin's Java code. How can I achieve this?
Here is the Java code
Typeface typeface = Typeface.createFromAsset(mainActivity.getResources().getAssets(), "Fonts/lobster-regular.ttf");
I know my path is wrong, what is the correct way of referencing font placed inside Unity's Assets folder from Android plugin's Java code.
Also I had tried placing font in Unity's StreamimngAssets folder and I was able to call that font using createFromAsset(mainActivity.getResources().getAssets(), "fonts/lobster-regular.ttf")
. But the problem is that in this method I cannot use the font in Unity Editor while editing Scenes as font is placed in StreamingAssets folder.
So how can I reference Font placed in Assets folder from android plugin's Java code?