• 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 LijuDeveloper · Dec 04, 2014 at 04:09 AM · androidflashlighthardware

Accessing Android Hardware

How to access android hardwares like , LED , flashlight, camera etc using C# code. Any available free plugins ?

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
1

Answer by Prasanna · Dec 04, 2014 at 07:02 AM

@LijuDeveloper, you can use webcamtexture for accessing device camera. The following script for this.

 using UnityEngine; 
 using System.Collections;
 using System.IO;
 public class Camera_View : MonoBehaviour 
 { 
     private WebCamTexture webcamTexture;
     private Quaternion baseRotation;
     void Start() 
     {
         webcamTexture = new WebCamTexture();
         renderer.material.mainTexture = webcamTexture;
         baseRotation = transform.rotation;
         webcamTexture.Play();
     }
     void Update() 
     {
         transform.rotation = baseRotation * Quaternion.AngleAxis(webcamTexture.videoRotationAngle, Vector3.zero);
     }
 }

Drag this script into cube or plane, set the background resolution.

Here is the Link

Comment
Add comment · Show 5 · 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 LijuDeveloper · Dec 04, 2014 at 10:18 AM 0
Share

Any available free plugins ?

avatar image Prasanna · Dec 04, 2014 at 11:02 AM 0
Share

I don't know.

avatar image Prasanna · Dec 05, 2014 at 08:44 AM 0
Share

If you are satisfied with my answer kindly accepted the answer and give a vote for me.

avatar image LijuDeveloper · Dec 08, 2014 at 05:28 AM 0
Share

Thank you Prasanna for your camera accessing script . Its working . But how to save this picture , how to access LED , notification light, flash light ?

avatar image Prasanna · Dec 08, 2014 at 05:37 AM 1
Share

Use this script for taking screenshots and save it into "Android/Data/Com.YourCompany.YourProduct/File/" folder. First do this go to Build Settings -> Player Settings -> Others -> Bundle Identifiers(com.Your_Company_Name.Your_Product) type those and go to Configuration in same player settings and change External(Sd Card) in Write access.

Drag this script into Camera and add guitexture for button.

 using UnityEngine;
 using System.Collections;
 
 public class Capture : $$anonymous$$onoBehaviour 
 {
     // Store more screenshots...
     private int Screen_Shot_Count = 0;
     // Screenshot taking by touch the button.
     public GUITexture Capture_$$anonymous$$odel;
 
     void Update()
     {
         if (Input.touches.Length > 0)
         // Finger hit the button position.
         if(Capture_$$anonymous$$odel.HitTest (Input.GetTouch(0).position))
         {
             if (Input.GetTouch(0).phase == TouchPhase.Began)
             {
                 // Screenshot name.
                 string Screen_Shot_File_Name;
                 do
                 {
                     // Increament the screenshot count.
                     Screen_Shot_Count++;
                     // Save the screenshot name as Screenshot_1.png, Screenshot_2.png, ...
                     Screen_Shot_File_Name = "Screenshot_" + Screen_Shot_Count + ".png";    
                 } 
                 while (System.IO.File.Exists(Screen_Shot_File_Name));
                 // Taking Screenshot.
                 Application.CaptureScreenshot(Screen_Shot_File_Name);
             }
         }
     }
 }

Here you go.

avatar image
2

Answer by tanoshimi · Dec 10, 2014 at 07:46 AM

You'll need to write a plugin. Or try an asset such as https://www.assetstore.unity3d.com/en/#!/content/23891 (untested, but claims to provide access to various hardware/is features)

Comment
Add comment · Show 1 · 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 AWE_liam · Jun 03, 2016 at 03:43 PM 0
Share

It doesn't seem that they have any kind of camera hardware methods. The seem to advertise just about everything else.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Plugin android native camera 0 Answers

Android to unity INPUT 0 Answers

Webcamtexture with Android flashlight 0 Answers

Trying to change a texture with picture from camera 3 Answers

Digital Hardware Key - Android 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