Search Unity

Question How to instantiate a hybrid prefab?

Discussion in 'Entity Component System' started by HeyZoos, Jul 1, 2021.

  1. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    I want to use a prefab with an animator and skinned mesh renderer, I'd like for this prefab to be converted with references to the Unity components. This happens when converting the prefab using `Convert and Inject Game Object`.

    However, when I convert using `Convert and Destroy` or when I use `
    GameObjectConversionUtility.ConvertGameObjectHierarchy()` - it throws away the reference data. How do I register a prefab with component references such that I can use it in other systems via `EntityManager.Instantiate`?
     
  2. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    352
    You can use ConversionSystem.AddHybridComponent or use EntityManager.AddComponentObject
     
  3. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    Should that go in the code that's instantiating? Or in the authoring component?
     
  4. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    352
    In autrhoring component