问题
I have a Unity application for iOS and I need to fetch an image from the iPhones photos library and then use it within unity as a texture/2D sprite. I can not find any information on how it could be done.
Any help is much appreciated. :)
回答1:
For something like this, I think that you are going to need a native plugin. You can either write it yourself (maybe the harder way) or try to find one from the asset store. I don't remember if this is the case anymore, but you may need to have paid for Unity to use / create plugins however.
If you want to try the native plugin route, which is actually a lot of fun in my experience, here is the start of the documentation for it.
https://docs.unity3d.com/Manual/NativePlugins.html
I would suspect that you would need to make APIs that are accessible to the Unity side of code that let you call into Objective-C which in turn would call the relevant bits of code at the platform level.
回答2:
Check this out: http://answers.unity3d.com/questions/1143996/open-ios-media-browser-and-import-selected-image-a.html And scroll all the way down
I believe it answers your question of accessing an image from the photo library. Good luck!
来源:https://stackoverflow.com/questions/46674027/how-to-fetch-a-photo-from-photos-library-into-unity-game-on-an-ios-device