Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Fedybix93 · Sep 02, 2015 at 09:37 AM · androidwebcamtexturewebcamflashlighttorch

Webcam Texture and Flashlite (Android)

Hello everyone, I had a problem to start the webcam of my Android smartphone with the torch. If I run before the code of the webcam you can be seen, but the flash does not light! but if I leave before the flash he works, but the webcam can not see! how do I fix?

This is the code in C#

         // ############## FLASH ON #############################
         
         AndroidJavaObject javaCamera;
         AndroidJavaClass cameraClass = new AndroidJavaClass("android.hardware.Camera");
         int camID = 0;
         javaCamera = cameraClass.CallStatic<AndroidJavaObject>("open", camID);
         AndroidJavaObject cameraParameters = javaCamera.Call<AndroidJavaObject>("getParameters");
         cameraParameters.Call("setFlashMode", "torch");
         javaCamera.Call("setParameters", cameraParameters);
         
         // ############## FLASH ON #############################
         
         // ############## WEBCAM PLAY #############################
 
         WebCamTexture webcamTexture = new WebCamTexture();
         Renderer renderer = GetComponent<Renderer>();
         renderer.material.mainTexture = webcamTexture;
         webcamTexture.Play();renderer.material.mainTexture = webcamTexture;
         webcamTexture.Play();
 
         // ############## WEBCAM PLAY #############################
 

I included these codes in the function start ();

The script must be applied on a 3D Panel

Comment
Add comment · Show 4
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 Ben-Stoneman ♦♦ · Sep 07, 2015 at 04:12 PM 0
Share

I'm looking into this, Can you answer some questions please:

  • When you say 3D Panel you mean a plane?

  • What version of Unity are you using?

  • What device are you building to?

avatar image Fedybix93 · Sep 07, 2015 at 09:02 PM 0
Share

Ben Stoneman

I'm using Unity in company with version 5.1.3 I meant a Plane, and I was developing on Android 4.3. (I downloaded all the sdk)

avatar image Ben-Stoneman ♦♦ Fedybix93 · Sep 08, 2015 at 04:12 PM 0
Share

I'm unable to get your script to work.

When making one from scratch I found that turning the flashlight off and on requires a plug-in:

http://answers.unity3d.com/questions/270832/how-to-turn-on-camera-light-make-a-flashlight-on-i.html

avatar image Fedybix93 Ben-Stoneman ♦♦ · Sep 08, 2015 at 05:51 PM 0
Share

Yes, but this only works for IOS and Android no :( it is possible that there is no one who can do this on Android?

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by GDesmoulins · Oct 12, 2015 at 12:52 PM

Hello Fedybix93, It seems that it's not possible to access both camera and Flash at the same time ! after days of tests and discussion with plugin makers, you can start a camera, or start using Flashlight, but no possible ways to use both with WebCamTexture ... i'm trying to use alternate ways, but it seems difficult... Don't hésitate to post there good tips ...

Comment
Add comment · Show 2 · 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 GDesmoulins · Oct 20, 2015 at 10:24 AM 1
Share

For the moment, the only effective solution i found was to use Vuforia pluggin, wich seems to use $$anonymous$$ovieTexture ins$$anonymous$$d of WebcamTextures ...

avatar image Dotby · Dec 31, 2015 at 04:24 AM 0
Share

Thank you for advice about Vuforia.

avatar image
0

Answer by Lanre · Mar 17, 2016 at 06:25 PM

Hi Fedybix93. Try the NatCam API. It supports torch control and many more features. And running the torch while the camera is running is on the roadmap.

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
avatar image
0

Answer by Dotby · Apr 17, 2016 at 03:34 PM

This is the answer: link text

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

6 People are following this question.

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

Related Questions

How to turn on flashlight when WebCamTexture is on? (Android camera2 api) 0 Answers

Webcamtexture with Android flashlight 0 Answers

Turn your Android device webcam (Camera) , flash light 3 Answers

How do I enable the Android lock screen in developer mode? 1 Answer

WebCamTexture.devices.Length returning 0 in Unity 2020.3.8f1 0 Answers


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