Log in or register to post comments

question about multiple scenes with their own ARCamera and image targets

May 9, 2012 - 9:38am #1

Essentially, I have a base (empty) scene that only contains UI, and several other scenes that get loaded which contain the AR content (including the ARCamera).

When I load the first scene, it tracks no problem. As soon as I load another scene, it won't track. Keep in mind that each time I load a scene I'm creating an ARCamera, so this may be part of the problem, but I don't know. It all works fine in the Unity editor, but not on a device.

And note that whichever scene I load first, it works fine. But whenever I move to another scene, it no longer tracks.

Hope this makes some kind of sense.

Re: question about multiple scenes with their own ARCamera and i

May 23, 2012 - 6:24pm #14

I actually meant keeping the experiences in their own separate scene files and calling a regular scene load for each. Then each scene would have it's own camera and set of assets. Unity is pretty smart about clearing stuff out between scene loads and freeing up that memory. Additive scene loading requires a bit more hands-on for managing what you want to keep or discard. I just wasn't sure if its better to keep the AR Camera setup live throughout the game.

Instead of activating/deactivating those models entirely, you could just grab a reference to their individual mesh renderers and toggle those on or off.

Re: question about multiple scenes with their own ARCamera and i

May 23, 2012 - 12:31pm #13
patch24 wrote:

Hey Jack, so you'll have to forgive any dumb questions as I'm new to this stuff. I was just curious why you are doing an additive load? Is that a better way to go to preserve the ARCamera setup from your base scene?

This is simply because we don't want the user to have to load all experiences at once... too many models and the loading would take too long.

patch24 wrote:

With your 'hack' you mentioned, are you repo'ing the camera to the origin so that your objects don't appear first, before tracking engages? Have you tried keeping your objects hidden until the tracking kicks in?

Keeping the objects hidden would involved calling SetActiveRecursively on some pretty large models. We're trying to avoid that.

Re: question about multiple scenes with their own ARCamera and i

May 23, 2012 - 11:23am #12

Hey Jack, so you'll have to forgive any dumb questions as I'm new to this stuff. I was just curious why you are doing an additive load? Is that a better way to go to preserve the ARCamera setup from your base scene?
With your 'hack' you mentioned, are you repo'ing the camera to the origin so that your objects don't appear first, before tracking engages? Have you tried keeping your objects hidden until the tracking kicks in?

Re: question about multiple scenes with their own ARCamera and i

May 22, 2012 - 12:55pm #11

Figured out a hack:

Position the ARCamera at Vector3.zero whenever a scene is loaded.

Re: question about multiple scenes with their own ARCamera and i

May 22, 2012 - 9:49am #10

I want to resurrect this.

To recap, I have an ARCamera instance in the base scene and my concrete scenes get loaded additively.

I parent my concrete scenes to an empty GameObject that is the child of the image target itself (it's position is important).

Problem with this is that I can see the AR before there is even tracking. I think that what is happening is that the rendered are being disabled BEFORE the AR objects are parented (or grand-parented, to be precise) by the image target. So when they get added, the renderers are enabled and we can see the AR content.

Is that clear? Bottom line is that the AR objects get added to the image targets at run-time (because the image targets and ARCamera are in the base scene), but the AR shows up before there is tracking. Once tracking is gained, everything then behaves as expected.

Thanks!

Re: question about multiple scenes with their own ARCamera and i

May 10, 2012 - 3:55am #9

Yeah, I think I'm just going to keep the ARCamera instance in the base scene.

And when I load additively, I Destroy() the current scene's parent, which has the ARCamera as a child. So there shouldn't be any redundant instances.

Re: question about multiple scenes with their own ARCamera and i

May 9, 2012 - 6:25pm #8
Quote:

I'm loading them additively.

That may be your problem, if it's resulting in redundant instances of the ARCamera.

If you do need to load additively, then you might try using a single instance of the ARCamera that's persisted across scenes using the DontDestroyOnLoad() - http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html

Re: question about multiple scenes with their own ARCamera and i

May 9, 2012 - 5:26pm #7
DavidBeard wrote:

How are you loading the scenes? Are you using Application.LoadLevel, or are you loading them additively?

I'm loading them additively.

DavidBeard wrote:

To confirm, are the ARCameras each pre-configured? Have you tried querying them when the scene is loaded to determine their state and configuration? Do they share datasets?

Not exactly sure what you mean by preconfigured, but if you are asking whether I selected the dataset in the Inspector, etc., then yes.

And yes, they all share the same dataset.

Re: question about multiple scenes with their own ARCamera and i

May 9, 2012 - 2:02pm #6

How are you loading the scenes? Are you using Application.LoadLevel, or are you loading them additively?

I've developed Vuforia apps in Unity using this same organization - a UI scene w/ subsequent AR scenes - and haven't encountered any problems.

To confirm, are the ARCameras each pre-configured? Have you tried querying them when the scene is loaded to determine their state and configuration? Do they share datasets?

If you can't get it worked out, I can take a look at your project if you'd like.

Re: question about multiple scenes with their own ARCamera and i

May 9, 2012 - 11:19am #5
loic_illogika wrote:

I had an issue close to yours, if I start a scene with ARCamera and ImageTracking disabled, when I turn them on nothing happens. I have to let them activated at the beginning of the scene and disable them by code.
Maybe the initialization has to be completed at the beginning of the application, only one time.

Yes, that's possible. So for a workaround I'm keeping the ARCamera in the base scene for now.

Re: question about multiple scenes with their own ARCamera and i

May 9, 2012 - 10:28am #4

I had an issue close to yours, if I start a scene with ARCamera and ImageTracking disabled, when I turn them on nothing happens. I have to let them activated at the beginning of the scene and disable them by code.
Maybe the initialization has to be completed at the beginning of the application, only one time.

Re: question about multiple scenes with their own ARCamera and i

May 9, 2012 - 9:48am #3
DavidBeard wrote:

What do you mean by 'creating an ARCamera'? - you're instantiating one procedurally?

How are you adding the ARCamera to the additional scenes?

There should be no problem when using multiple scenes. So it may something arising from the way that you're including the ARCamera.

Sorry... all I mean is that each scene has it's own ARCamera. So whenever I load a scene, the ARCamera is being loaded as well. In other words, my base scene (that only has UI) has no ARCamera. But every other scene that gets loaded on top of the base scene has it's own ARCamera.

A scene may look like this:

SceneParent
-> ARCamera
-> ImageTarget
----> ARContent

Re: question about multiple scenes with their own ARCamera and i

May 9, 2012 - 9:46am #2

What do you mean by 'creating an ARCamera'? - you're instantiating one procedurally?

How are you adding the ARCamera to the additional scenes?

There should be no problem when using multiple scenes. So it may something arising from the way that you're including the ARCamera.

Log in or register to post comments