Home / Demo / Cross Platform Access to Native Camera and Gallery

Cross Platform Access to Native Camera and Gallery

/
/
/
1914 Views

Following the last tutorials on native plugins – Android, iOS and WebGL – I’ve decided to create a cross platform controller to use native features on Unity. With this controller you can use a single call per feature, without worrying about the underlying platform:

  • Native.Instance.CameraPicture(filename, callback, maxSize);
  • Native.Instance.GalleryPicture(filename, callback, maxSize);
Complete project on GitHub

 

So far, only the Camera and Photo Gallery are implemented. I plan on adding more features such as Native Pickers, Share and Local Notifications. Any requests are always welcome.

Cross Platform Controller Breakdown

  • The Native.cs is the global “point of contact” with the native plugins; IMAGE1
  • At runtime, it adds the corresponding component according to the current platform;
  • The MediaBase.cs is the base class to all Media components;
  • Each Media.cs implements the specific native plugin implementation;

How to use it

  • Import the Native folder and the native libraries into your own project; IMAGE1 IMAGE2 IMAGE3
  • Check the example.scene and the ExampleMedia.cs for an example;

How to test it

Add all the scenes – intro, main, example – to the Build Settings Build and run the project for Android, iOS or WebGL. IMAGE4 IMAGE5

Happy Coding 🙂

  • Facebook
  • Twitter
  • Google+
  • Linkedin
  • Pinterest
  • Reddit

2 Comments

  1. Hi!

    Thank you for the quality of your content.
    I want to suggest a tutorial on Android billing (IABv3) plugin.
    Some asset store makers publish low quality undocumented expensive assets while your blog posts are as good as eppz’s!

    Regards,
    Hamza

    • Hey,
      I really appreciate your words.
      I have no experience with the Android billing (IABv3) plugin, but I’ll add it to my list for a future plugin.
      Thanks a lot once again.

Leave a Comment

Your email address will not be published. Required fields are marked *