Search Unity

Prefabs ( with MeshRenderer children ) in Subscenes problem

Discussion in 'Graphics for ECS' started by ibbybn, Apr 12, 2021.

  1. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    I'm in the process of switching my project to DOTS especially because of the Hybrid Renderer but running into some workflow issues. ( 2020.3.3f1 All the latest packages )

    My usual prefab hierarchies for world building look like this:

    Rock_1_PREFAB:
    Rock_1_Mesh ( MeshFilter | MeshRenderer | LOD_Group )
    Rock_1_FRACTURE_CONTAINER
    piece0 ( MeshFilter | MeshCollider )
    piece1 ( MeshFilter | MeshCollider )
    piece2 ...​

    The Fracture Container is coming from Houdini ( Convex Hull Decomposition.. ) for collider generation.
    The LOD_Group is only used to set culling distance.
    I'd like to keep all this information together in one prefab obviously for fast world building iteration.
    When I put these prefabs into a subscene they don't show at all.
    Only when I move the Rock_1_Mesh directly under the root of the subscene do I see it with the Hybrid Renderer in game view.

    Am I missing something simple or is the current subscene workflow only for simple prefabs without hierarchies?

    EDIT after some investigating: The problem seems that MeshRenderers not directly under subscene root will only show at 0,0,0 world position. When moving the objects holding them they show at the correct place only to go back to 0,0,0 when entering play mode.
     
    Last edited: Apr 13, 2021
  2. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    Physics stuff gets auto unparented on conversion.
     
  3. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Yes but why don't i see the Rock_1_Mesh ( no physics stuff there ) in the game view with the hybrid renderer?
    I only see it if I take it out of the prefab to subscene root.
    Does the conversion just look at the whole prefab, see physics stuff there and ignore the whole prefab?
     
  4. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    Hmm, whats in the LOD_Group?
     
  5. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    It just has LOD0 ( MeshRend on same transform ) and Culling group.
     
  6. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    Does it show up without the lod?
     
  7. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Unfortunately not. It's also not showing without all the colliders. Also not if the prefabs unpacked completely. The rule seems to be the MeshRenderer can only be one step below subscene root or it won't show in the hybrid renderer.

    I've moved all the Mesh components to the prefabs root. But this won't work with prefabs with multiple meshes so this will be a bit of a painpoint when converting more of the scenes. Is this intended behaviour or something still being looked at?
    I assume scripting the conversion at runtime let's us decide exactly what is being converted? If so I might instead go that route and then instancing them to their positions from some list instead.
    Just seems like an unecessary step inbetween.
     
    Last edited: Apr 12, 2021
  8. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    wierd, doesn't happen for me:
    upload_2021-4-13_0-33-8.png
     
  9. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Oh nevermind. They DO show up in the game view.
    But exactly at 0,0,0 even though they show at the correct location in scene view.
     
  10. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    what versions Unity / URP / HR / DOTS are you using?
     
  11. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Try to move the root cube then move the child cubes and look at the gameview.
    The children will jump to 0,0,0 and then move from there. Once you move the root cube again the others jump to their correct spots again. This caught me out because I just drag and dropped all the prefabs from the scene into the subscenes.

    Basically I have to move all those prefabs just a bit once they're in the subscene otherwise they show up at 0,0,0. Good to know. :)
     
  12. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Aaand even though the game view shows it correctly when moving the prefabs in Play Mode they're back to 0,0,0. Strange to say the least.

    I'm on 2020.3.3f1 | Entities 0.17 preview 41 | HDRP 10.4.0 | Hybrid Renderer 0.11.0 preview 42
     
  13. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Ok so I can't reproduce this behaviour in the HybridHDRPSamples Project even though it has the same Packages installed.
    It also has nothing to do with subscenes.

    When I create a simple
    Cube + ConvertToEntity
    Cube2​
    hierarchy the Cube2 entity has its LocalToWorld exactly as its LocalToParent values which doesn't happen in the sample project. I'll just have to try moving everything over to a new project it seems..