Log in or register to post comments

Weird behavior on enable/disable QCARBehavior with Android plugins

July 27, 2013 - 7:27am #1

Hello again,

 

This time I experiencing something rather unusual with Unity and Android. I'm trying to open Android webview on Unity button press. So far everything works well. Add in the Vuforia SDK and still everything works perfect. The problem arises when I try to disable the Camera in the scene.

I've a "Toggle Camera" button on my main scene. and a few buttons in the footer of the scene. These button link to varios webpages in webviews. I've a native close button on the webview to close it. Here's what's happening:

Case 1: QCARBehavior enabled at start. When I click for a webpage, a new webview opens(in full screen). On closing it, I'm back to my AR View. So far, so good. I can use the "Toggle Camera" button to toggle the state of the camera

Case 2: QCARBehavior disabled at start. When I click on the toggle button, the camera turns on. When the camera is on, the webpages work perfect.

Case 3: In either of the cases, if the camera is off, and I open any webpage, it opens correctly. On closes on pressing the close button. But the "Toggle Camera" button doesn't function anymore. The app force closes on pressing the button. Any idea what mst be going wrong here?

 

In summary, cameraON->Webview->Close->ToggleCamera works perfect. but CameraOFF->Webview->Close->ToggleCamera doesn't work.

I'd be really grateful if somebody here can throw some light on this issue. I'll post my code if necessary!

 

Regards,

Parth Darji

AR Software Specialist

DuMedia, Inc.

Weird behavior on enable/disable QCARBehavior with Android plugi

August 15, 2013 - 7:36am #8

Weird behavior on enable/disable QCARBehavior with Android plugi

August 11, 2013 - 4:28am #7

Hello again,

I tried to use the gree plugin that you mentioned and everything seemed to work fine. But on further investigation, I found that the new webview created from this plugin isn't clickable/scrollable. I need some html content to be viewed on a button press. For this I'm using a webview.

I tried to use the plugin without importing the Vuforia plugin, and found that touch/scroll worked fine. So I came to the conclusion that the plugin needs to be modified to be compatible with Vuforia. Hence I did the following:

-In the source java file, I replaced all the instances of UnityPlayer with QCARUnityPlayer. Theoretically, this should solve the issue, but unfortunately, it doesn't.

 

Has anyone managed to get this working? I'm on a project deadline and need to deliver this project very soon. I'd be grateful if someone can guide me in the right direction.

 

Regards,

pd

Weird behavior on enable/disable QCARBehavior with Android plugi

July 28, 2013 - 7:55am #6

Okay, just a little update: I tried to use the plugin you mentioned. and the camera behavior works perfect now. Thanks for the heads up. But, I'd still be interested in knowing what went wrong with the plugin I wrote!

Weird behavior on enable/disable QCARBehavior with Android plugi

July 27, 2013 - 9:25am #5

I built my own plugin. Do you want me to send you the project folder?

Weird behavior on enable/disable QCARBehavior with Android plugi

July 27, 2013 - 8:43am #4

Did you write your own webview plugin, or are you using this one - https://github.com/gree/unity-webview

 

Weird behavior on enable/disable QCARBehavior with Android plugi

July 27, 2013 - 8:28am #3

Hello David,

Thanks for your reply.

Yes I'm using a webview overlayed on the Unity player view.

I don't think this is an initialization issue. Because it happens irrespective of the QCARBehavior being disable in the "Start()" function or not. I mean it doesn't matter if I disable the QCARBehavior in the beginning of the scene or somewhere in between (using buttons). The problem occurs only in this case: if the camera is OFF, I call the webview and then close it. The camera won't start again.

 

Here's my camera toggle code, I just changed it to two buttons instead of a single toggle button:

if (!cameraEnabled)
        {
            if (GUI.Button(new Rect(ContentRect.width / 4, ContentRect.height / 4, ContentRect.width / 2, ContentRect.height / 2), "Toggle AR view"))
            {
                if(!this.GetComponent<QCARBehaviour>().enabled)
                    this.GetComponent<QCARBehaviour>().enabled = true;
                cameraEnabled = true;
                //this.GetComponent<QCARBehaviour>().enabled = this.GetComponent<QCARBehaviour>().enabled ? false : true;
            }
        }

        else
        {
            if (GUI.Button(new Rect(4 * Screen.width / 5, 0, Screen.width / 5, ContentRect.height / 5), "Close"))
            {
                
                //(QCARBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARBehaviour)).enabled = false;
                if (this.GetComponent<QCARBehaviour>().enabled)                
                    this.GetComponent<QCARBehaviour>().enabled = false;
                cameraEnabled = false;
            }
        }

 

Regards,

Parth Darji

AR Software Specialist

DuMedia, Inc

 

Weird behavior on enable/disable QCARBehavior with Android plugi

July 27, 2013 - 8:01am #2

You're using a webview overlayed on the Unity player view?

I suspect that this has something to do with the initialization of the QCARBehaviour.

Can you post the code you're using to toggle the camera?

Also in the OFF case, does this occur if the camera is first toggled off or only if the scene inits with the camera off?

Log in or register to post comments