Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Can't use this code "CameraDevice.Instance.SetFlashTorchMode(true);"

Discussion in 'Scripting' started by Thanitsak, Jan 14, 2017.

  1. Thanitsak

    Thanitsak

    Joined:
    Jan 4, 2016
    Posts:
    92
    Could someone please help me with this problem, I can't use this line of code to open flashlight in the real device. "CameraDevice.Instance.SetFlashTorchMode(true);" It said The name `CameraDevice' does not exist in the current context. Also will this work on both platform iOS and android?
    Much appreciate, and Thank You in advance!
     
  2. mightybob

    mightybob

    Joined:
    Mar 23, 2014
    Posts:
    75
    It's hard to tell without more (or all) of the code. One possible issue is:

    "CameraDevice" is declared inside a function, for loop, or if() and you are trying to access it outside of that function/for loop/if. e.g.

    Code (CSharp):
    1. //this does not work
    2. void Start() {
    3.     GameObject CameraDevice;
    4. }
    5.  
    6. void Update() {
    7.     CameraDevice.something();
    8. }
     
    dcoloma likes this.
  3. Thanitsak

    Thanitsak

    Joined:
    Jan 4, 2016
    Posts:
    92
  4. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    92
unityunity