I'd like to include images in my Flutter application which are not asset images.
Let me clarify a bit. I am working with an embedded Unity application inside the Flutter app. I can communicate bidirectionally and part of the communication is sending a file location from Flutter to Unity, such that the Unity app can read that image and do something with it (e.g. a texture). But since assets are not directly accessible by location, I cannot give the path to the Unity part of the application.
So would there be a way to include images in the app and reference them by old school path?
Related
we are developing and AR artwork viewing app. users can browse artworks in our app which is based on flutter and artworks could be checked in AR by loading unity part. we use AWS as server to provie artworks images in flutter. right now the problem is that we dont know how to send image of artwork from flutter to unity.
I am developing a photo vault using Flutter. I need to list all the images in the mobile storage, and when the user picks one or more images. I need to move that image(s) into App Private. So that no other app can see it. So for moving the file, I need the location/path of the picked image(s). which no plugin on earth is providing.
Below is the list of plugins I tried. Each one of them provides the path of the image copied to the app private directory. No the original one
file_picker 2.1.6
image_picker 0.6.7+22
multi_image_picker 4.7.15
It would be a big help if you could suggestion some solution for it.
Thank You
I have included images from my PC instead of web images, do I need to use web images instead ?
You can include images from your PC too! But make sure you maintain a proper assets folder and update in pubspec.yaml such that you can use it in your app.
Refer: https://flutter.dev/docs/development/ui/assets-and-images
This font needs to be dynamically changed so I can't put it in Resources.
I haven't found any resources or way to achieve this, all talk about Resources.
EDIT: I did look into AssetBunble but it looked overkill so I thought maybe requiring the user to install the font on his machine but Font.CreateDynamicFontFromOSFont does nothing. Whatever the given input (even invalid), it will always return the same "Arial" font and nothing visually change.
I might look into AssetBundles again but I don't want Unity installed on the target machine and if I understood right, you can't build an assetbundle without running Unity.
There is no Unity API to load standard font from disk or web into Unity's Font.
If you use Font.CreateDynamicFontFromOSFont, the font must be installed on the device. This is easy to do on some platforms like Windows but extremely hard on devices like Android.
The recommended way to do this is to use AssetBundles. You will need the Unity Editor to create the AssetBundles but you don't need it to load the AssetBundles during run-time. Put the fonts in AssetBundles then build it and host it on the server. Use UnityWebRequest API to download the Assetbundle then extract the font from it. You can always update this Assetbundle on the server.
If you want the user to to able to load the font from any source, you can automate the building part by asking the user where the font is, take that font and send/upload it to your server with the UnityWebRequest API. On the server side, run Unity Editor in a headless mode, retrieve the font sent to it and build an Assetbundle from it then send it back to the player and load it on the client side.
So, UnityWebRequestAssetBundle.GetAssetBundle is used to download the AssetBundle and AssetBundle.LoadAssetAsync is used to the fonts in it.
There is no other way to do this unless you have the Unity source code which is really expensive. By doing it this way, you won't need the font to be installed and won't run into issues on mobile devices. This post shows how to build and load an Assetbundle but you have to do that in headless mode.
This question already has an answer here:
Download AssetBundle in hard disk
(1 answer)
Closed 4 years ago.
I'm using Asset Browser of Unity. I want to reduce my game. So I should make Asset Bundle(DLC) and when i click download button in phone, datas will download and load to phone as permanantly, it will download at once, after that user can play as offline. I builded my data in Asset Browser. how can i load it?
First, you need to build the asset bundles (with Asset bundle browser) and put them in a server that is publicly accesible. You need to use UnityWebRequest in your game to download your assetbundle from the server.
https://docs.unity3d.com/Manual/UnityWebRequest-DownloadingAssetBundle.html
Or you can use Unity Asset Bundle Manager (EDIT: Looks like Unity removed it from the asset store)
However, I have found this awesome tool, that I am actually using too, and it does a way better job. Just read the README, it is pretty straightforward. You just have to set the URL of your bundles, and then download bundles by specifying their name.
https://github.com/SadPandaStudios/AssetBundleManager