Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Vegetus '78 · Dec 27, 2010 at 03:52 PM · hardwareunityiphone

Accessing the iOS Photo Picker?

Is there a way to access the iOS Photo Picker from Unity? I want my Unity application to let the user select a picture from the Photos application or take another picture using the camera, if the device has it. I was unable to find anything about it on the documentation.

Thanks in advance.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Peter G · Dec 27, 2010 at 04:04 PM

You have to use a plugin through obj-c. It's not that hard.

  • Hide or remove the Unity view.

  • Add a view controller with a view to the keyWindow.

  • Create a button or some event that opens an UIImagePickerController which you shouldn't need to subclass.

  • Have your viewController respond to the image picker delegate.

  • Once the user chooses an image save the image See SpinalJack's Post on getting the asset path. See below for code.

  • In Unity, use a WWW to load the image from the asset path.

  • When loading your data, the only thing you will need to remember is that WWW wants file: at the beginning and your plugin will not so add that after you send the asset path to your native code.


    (void)imagePickerController:(UIImagePickerController )picker didFinishPickingImage:(UIImage )selectedImage editingInfo:(NSDictionary *)editingInfo {

    NSData* imageData = UIImagePNGRepresentation(selectedImage);
    [imageData writeToFile:assetPath atomically:YES];
    [self dismissModalViewControllerAnimated:YES];
    

    }

    Comment
    Add comment · Show 3 · Share
    10 |3000 characters needed characters left characters exceeded
    ▼
    • Viewable by all users
    • Viewable by moderators
    • Viewable by moderators and the original poster
    • Advanced visibility
    Viewable by all users
    avatar image Vegetus '78 · Dec 29, 2010 at 11:08 AM 0
    Share

    Looks nice, indeed. But how do I add Obj-C plugins to Unity? Thanks!

    avatar image Peter G · Dec 29, 2010 at 01:33 PM 0
    Share

    http://unity3d.com/support/documentation/$$anonymous$$anual/Plugins.html#iPhonePlugins and look at the Bonjour example. It makes more sense when you see it.

    avatar image Mike-B · May 22, 2013 at 10:04 PM 0
    Share

    why do we need to hide or remove the unity view? is it incorrect to present the image picker directly from the keywindow unityViewController?

    avatar image
    0

    Answer by xpkoalz · Dec 10, 2014 at 10:06 AM

    How do I hide Unity View? I can't find a simple or straight-forward answer to this..

    Comment
    Add comment · Share
    10 |3000 characters needed characters left characters exceeded
    ▼
    • Viewable by all users
    • Viewable by moderators
    • Viewable by moderators and the original poster
    • Advanced visibility
    Viewable by all users

    Your answer

    Hint: You can notify a user about this post by typing @username

    Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

    Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Access to iPad2/iOS camera as texture 4 Answers

    Unity Freezes and Deletes Everything in My Scene 0 Answers

    Make custom input devices available to scripting via "Input" 2 Answers

    Controller Not Recognized on One Computer 0 Answers

    Porting Unity Web Player game to iPhone using Unity 1.7 iPhone 1 Answer


    Enterprise
    Social Q&A

    Social
    Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

    Footer

    • Purchase
      • Products
      • Subscription
      • Asset Store
      • Unity Gear
      • Resellers
    • Education
      • Students
      • Educators
      • Certification
      • Learn
      • Center of Excellence
    • Download
      • Unity
      • Beta Program
    • Unity Labs
      • Labs
      • Publications
    • Resources
      • Learn platform
      • Community
      • Documentation
      • Unity QA
      • FAQ
      • Services Status
      • Connect
    • About Unity
      • About Us
      • Blog
      • Events
      • Careers
      • Contact
      • Press
      • Partners
      • Affiliates
      • Security
    Copyright © 2020 Unity Technologies
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell My Personal Information
    • Cookies Settings
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Explore
    • Topics
    • Questions
    • Users
    • Badges