Search Unity

Why doesn't my animated mesh get rendered?

Discussion in 'Graphics for ECS' started by HeyZoos, May 9, 2020.

  1. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    I think it has something to do with my version not running the correct systems, here's a working sample:

    upload_2020-5-8_19-38-1.png

    Here's my version:

    upload_2020-5-8_19-39-44.png

    My version is running 3 fewer systems and also running a RigComputeMatricesSystem with different component requirements than the working sample.
     
  2. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    I found a solution, it seems to be because I instantiated my rig prefab at the same time that I converted the game object. When I broke the spawning event out into a separate system, everything seems to work fine. That is super perplexing to me, does anyone know why that might be the case?

    ORIGINAL
    Code (CSharp):
    1. public class AnimationAuthor : MonoBehaviour, IConvertGameObjectToEntity, IDeclareReferencedPrefabs
    2. {
    3.     public GameObject RigPrefab;
    4.  
    5.     public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem converter)
    6.     {
    7.         var rigPrefabEntity = converter.GetPrimaryEntity(RigPrefab)
    8.         var rigInstance = manager.Instantiate(rigPrefabEntity);
    9.     }
    10. }
    CORRECT
    Code (CSharp):
    1.  
    2.  
    3. public struct RigSpawner : IComponentData
    4. {
    5.     public Entity RigPrefab;
    6. }
    7.  
    8. public class AnimationAuthor : MonoBehaviour, IConvertGameObjectToEntity, IDeclareReferencedPrefabs
    9. {
    10.     public GameObject RigPrefab;
    11.  
    12.     public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem converter)
    13.     {
    14.         var rigPrefabEntity = converter.GetPrimaryEntity(RigPrefab);
    15.  
    16.         manager.AddComponentData(entity, new RigSpawner
    17.         {
    18.             RigPrefab = rigPrefabEntity
    19.         });
    20.     }
    21. }
    22.  
    23. [UpdateInGroup(typeof(InitializationSystemGroup))]
    24. public class SpawnRigSystem : ComponentSystem
    25. {
    26.     protected override void OnUpdate()
    27.     {
    28.         Entities.ForEach((Entity entity, ref RigSpawner spawner) =>
    29.         {
    30.             var rigInstance = EntityManager.Instantiate(spawner.RigPrefab);
    31.         });
    32.     }
    33. }
    34.  
     
  3. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Because the conversion of the rendering parts wasn't finished.

    You can't use runtime conversion with animation anyways as it uses editor only api's in more then one place. That's why the examples are using subscenes.
     
  4. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    Could you elaborate? The examples all include a sub scene with a spawner game object. But the spawners are still monobehaviour scripts. Does that mean the sub scenes, and by extension the spawners, run and load first?