Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved [solved] Why doesnt my entity render in game view?

Discussion in 'Entity Component System' started by hughperkins, Jun 19, 2023.

  1. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    Screen Shot 2023-06-18 at 20.57.15.png Following the tutorial by Code Monkey at
    Got as far as 10:52. So, I've created a subscene, added a cube, added the SpeedAuthoring MonoBehaviour to it. When I press 'play', I dont see my code. I've tried both URP and BRP. My code is:

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using Unity.Entities;
    5. using UnityEngine;
    6.  
    7. public struct Speed: IComponentData
    8. {
    9. public float speed;
    10. }
    11.  
    and

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using Unity.Entities;
    5. using UnityEngine;
    6.  
    7. public class SpeedAuthoring : MonoBehaviour
    8. {
    9. public float speed;
    10. }
    11.  
    12. public class SpeedBaker : Baker<SpeedAuthoring>
    13. {
    14. public override void Bake(SpeedAuthoring authoring)
    15. {
    16. // TransformUsageFlags transformUsageFlags = new TransformUsageFlags();
    17. // TransformUsageFlags transformUsageFlags = TransformUsageFlags.Renderable;
    18. // TransformUsageFlags transformUsageFlags = TransformUsageFlags.NonUniformScale | TransformUsageFlags.Dynamic;
    19. TransformUsageFlags transformUsageFlags = TransformUsageFlags.NonUniformScale | TransformUsageFlags.Dynamic | TransformUsageFlags.Renderable | TransformUsageFlags.WorldSpace;
    20. Entity entity = GetEntity(transformUsageFlags);
    21. AddComponent(entity, new Speed {
    22. speed = authoring.speed
    23. });
    24. }
    25. }
    26.  
    As you can see, I've also tried a view different TransformUsageFlags bits.

    This is using Unity 2022.3.2f1, and Entities 1.0.10

    What do I need to change so I can see my cube in Game view? (It appears in Scene view, and in the small camera thumbnail in scene view).
     
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    if you havent added it, you need the entities graphics package and one of the renderpipelines(not builtin)
     
    hughperkins likes this.
  3. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    Awesome, thanks!