phantom
phantom

Reputation: 41

EasyAR camera flash

using EasyAR with unity 3d

i wanted to enable camera flash

i have used this code but it didnt work

it shows me errors in these line

cameraDevice.CameraParameters.FlashTorchMode

Error CS1061 'object' does not contain a definition for 'FlashTorchMode' and no accessible extension method 'FlashTorchMode' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

using UnityEngine;
using easyar;

public class FlashController : MonoBehaviour
{
    private CameraDeviceBehaviour cameraDevice;

    private void Start()
    {

        // Get the CameraDeviceBehaviour component
        cameraDevice = GetComponent<CameraDeviceBehaviour>();
    }

    public void EnableFlash()
    {
        // Enable the flash
        cameraDevice.CameraParameters.FlashTorchMode = true;
    }

    public void DisableFlash()
    {
        // Disable the flash
        cameraDevice.CameraParameters.FlashTorchMode = false;
    }
}

Upvotes: -2

Views: 33

Answers (1)

derHugo
derHugo

Reputation: 90749

Searching in the API - Version 4.6 (always your first best friend in such cases) I can only see CameraDevice.setFlashTorchMode which is a method not a property.

I think it was like that already before (at least down to the docs of 1.3 I found) so you probably rather have to use

public void EnableFlash()
{
    // Enable the flash
    cameraDevice.Device.setFlashTorchMode(true);
}

public void DisableFlash()
{
    // Disable the flash
    cameraDevice.Device.setFlashTorchMode(false);
}

Note that in earlier versions the method started upper case, in later ones lower case.

Didn't find any CameraDeviceBehaviour though .. only in older versions CameraDeviceBaseBehaviour e.g. in v2 so you seem to either use an older version or are doing something wrong ;)

In the newer the equivalent seems to be CameraDeviceFrameSource.

The error message you show us indicates that the compiler doesn't even know cameraDevice.CameraParameters or maybe already CameraDeviceBehaviour. Otherwise it would say

Error CS1061 'TheExactClass' does not contain ...

instead of the general object. So there have to be some more errors you didn't show us.

Upvotes: 0

Related Questions