Search Unity

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:
    117
    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:
    117
  4. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94