1 (edited by digitalrock 2022-01-25 20:49:18)

Topic: Tileset HitTest error when camera outside frustum.

Hi Alex,

I have a Map Camera which slides in from the side of the device.  I use a Tileset control in my AR App, and map not visible to the AR camera via the culling.  So while the Map Camera is out-of-view, I get the following errors:

Screen position out of view frustum (screen pos 0.000000, 0.000000) (Camera rect 0 0 0 1024)
UnityEngine.Camera:ScreenPointToRay (UnityEngine.Vector3)
OnlineMapsTileSetControl:HitTest

I'm curious what is the best way to tackling having the map slide-in/out without getting the errors?  My thought was to disable the map renderer, till the Display Map Button is clicked.  Then, turn on renderer AND start camera slide into view.  I do think there is a possibility of a few errors each time however, due to the renderer being enabled slightly before camera rect is updated.

What do you think?

EDIT: Maybe it would be better to switch between Main-Camera and Map camera (and back again) based on if the Display Map Button is clicked.

Thanks.

Re: Tileset HitTest error when camera outside frustum.

Hello.

Try this (OnlineMapsTileSetControl.HitTest):

protected override bool HitTest(Vector2 position)
{
#if NGUI
    if (UICamera.Raycast(position)) return false;
#endif
    Rect rect = activeCamera.rect;
    if (rect.width == 0 || rect.height == 0) return false;
    return cl.Raycast(activeCamera.ScreenPointToRay(position), out lastRaycastHit, OnlineMapsUtils.maxRaycastDistance);
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Tileset HitTest error when camera outside frustum.

Thanks Alex.  That change definitely helped, but led to the next error.  Maybe I'm going about this incorrectly for what it is I'm trying to accomplish.  All I want to do is...

1.  Have an AR Camera where all the user sees is the 3D markers (via map) within AR scene. I have this working using Tileset.

2.  Have a slide-in map where the user can zoom, pan and rotate the Map.  I have the slide-in map working using ortho camera (NOT Texture on UI/Canvas). What I am trying to do is add the ability for the user to zoom, pan, and rotate (cameraOrbit) while the Map is in view.

3.  When map slides-back-out-of-view (user is back in AR world) the Tileset map/3D markers from step #1 are exactly as they were  (before any changes were made by user zoom/pan/orbit).

To accomplish step #2 I added the Map Camera to the tileset map and give User Control and Zoom, plus added CameraOrbit component.  By "assigning" the Map Camera to the tileset, I started receiving the frustum errors, which is why I created this post. 

I spent a little time looking at the Tileset with Map Camera UI tutorial.
...and before I make a hot-mess of everything I thought I would check...
...just want to make sure I'm doing things the write way; I tend to make things way too difficult.

Thanks.

Re: Tileset HitTest error when camera outside frustum.

Please show the stack trace of next error.

Unfortunately, I don't know if you're doing the right thing or not.
For more or less simple cases, I can give advice on a short description of the problem.
But this is not your case.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.