Search Unity

Unity can't find camera inside nested prefab

Discussion in 'Prefabs' started by pyjamaslug, Aug 24, 2019.

  1. pyjamaslug

    pyjamaslug

    Joined:
    Jul 5, 2017
    Posts:
    51
    I have a hierarchy like the one attached where the active scene has a prefab containing a camera cluster and it is nested inside another prefab. Both prefabs are instantiated at runtime and the cameras are parented to the containing prefab so that they move around when it does.
    The problem is that unity thinks there is no camera.main and so I get nothing rendered to the display. If I put the camera cluster directly in the scene, then it works fine but that is not what I want.
    Is this the expected behaviour, or am I doing something wrong? nested prefabs.png
     
  2. pyjamaslug

    pyjamaslug

    Joined:
    Jul 5, 2017
    Posts:
    51
    OK, finally whittled it down to a root cause - nothing to do with nested prefabs at all.