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

Cross Platform Access to Native Camera and Gallery

/
/
/
1029 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 🙂

Leave a Comment

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