Search Unity

3D GUI Element in Camera Layer Scaling Issue??

Discussion in 'Immediate Mode GUI (IMGUI)' started by ElectricAnt, Jan 10, 2011.

  1. ElectricAnt

    ElectricAnt

    Joined:
    Jul 13, 2010
    Posts:
    28
    Hello,

    I have a scene where I have some selectable objects. They are rendered in a camera layer at the default depth -1 with one camera. I have another camera layer which renders my 3D gui element at layer 0 (on top of the other layer). Everything renders as I would expect, but one of my 3Dgui element meshes is a zoom in button that decreases the main camera at depth -1 FOV. I have an opposite zoom out button also that increases the FOV. When I zoom in or out, the 3D gui element renders at a constant size and position like I want, but RayCasts against them fail after I zoom in or out past where the element would be if it were actually scaling. If I click on the element where it would be IF it were scaling then it works just like I clicked on the element as expected, but there is NO element there. Both cameras are rendering in perspective and mutually exclude the other camera's layer in their rendering. I have tried rendering the 3D gui layer in ortho but the problem is still the same.



    Is there a trick to this that I missed or is this a bug in the camera layers? Any help is greatly appreciated.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    If the two camera's FOVs are different then they are not interchangeable as far as ScreenPointToRay is concerned. You need to make sure that you generate the ray from the GUI camera for potential GUI clicks and from the scene camera for potential scene clicks. Depending on what you are doing, this may mean that you need to raycast from both cameras every time (ie, check if the GUI ray hits a GUI element and if not check if the scene ray hits a scene object).