Search Unity

Conversion workflow feels messy. Am I doing it right?

Discussion in 'Entity Component System' started by illinar, Jul 21, 2021.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    I have a character controller. It can be entierly converted to entities, except the camera.

    upload_2021-7-21_10-33-21.png

    Am I supposed to just leave it like that when it loads, with all the objects just sitting there, and just take control of the camera? Would it make sense to delete converted objects and unparent the Camera?

    What happens in build? The same objects get loaded along with the entities generated in editor? It says only runtime data gets into build, so are they not loaded? Are they loaded without authoring components? So GO still stay and get loaded?
     
  2. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Also, the way I reference the Camera is via custom managed IComponentData CameraReference

    upload_2021-7-21_11-24-29.png

    Is that a good way to do it? I mean there is a companion game object system, and I can't figure out how that one is working.
     
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,255
    The main camera doesn't work in side a Companion GameObject. I usually make a MonoBehaviour for the entity that I want to hold the camera along with a GameObjectConversionSystem for it: https://github.com/Dreaming381/lsss-wip/blob/master/Assets/_Code/Components/CameraManager.cs

    Then I have a system which updates the camera transform manually in a job like so: https://github.com/Dreaming381/lsss...Graphics/CameraManagerCameraSyncHackSystem.cs

    A trick I like to use, is I like to make a child GameObject to the Camera, and then give the child the CameraManager and Convert To Entity (and destroy). With this configuration, I can save the Camera as a prefab and reuse it across multiple scenes.