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

Question Updated Entities version and now entities spawned runtime don't show up in the Entities Hierarchy

Discussion in 'Entity Component System' started by haxic, Sep 11, 2023.

  1. haxic

    haxic

    Joined:
    Jul 12, 2021
    Posts:
    20
    I updated a couple of DOTS/ECS packages e.g. Entities, Entities Graphics, Netcode for Entities, etc., from 1.0.11 to 1.0.14. Now when I inspect entities that got instantiated from prefabs during runtime/playmode I cannot see Runtime data for them. I can only see runtime data for entities that are pre-instantiated prior to going into playmode.

    I tried to reimport, unload and re-load the subscene, and update Unity from Unity 2022.3.0f1 to Unity 2022.3.9f1, change various settings, but it made no difference.
     
    Last edited: Sep 12, 2023
  2. haxic

    haxic

    Joined:
    Jul 12, 2021
    Posts:
    20
    Here is a screenshot illustrating the issue. "MediumTank" is an entity that was spawned during runtime/playmode - you can see it on the left side in the Scene view and in the center in the Entities Hierarchy. However, in the inspector the Authorings are being shown, not the runtime entity components. The Entities Hierarchy and Inspector are both set to show "Runtime":

    upload_2023-9-12_14-58-53.png

    I can't figure out why it won't display the Runtime entity components for entities instantiated during playmode.
     
    Last edited: Sep 12, 2023
  3. Richay

    Richay

    Joined:
    Aug 5, 2013
    Posts:
    75
    I often have to right-click on the Entities Hierarchy tab and select Reload for the list to present properly.
     
  4. haxic

    haxic

    Joined:
    Jul 12, 2021
    Posts:
    20
    I got my 'Entities Hierarchy' work again after I fidgeted with some settings. The remaining issue I got is with the 'Inspector' tab. It doesn't show 'Runtime' entity components for entities that got instantiated in playmode (as illustrated in the screenshot in my previous reply). It works fine for entities that are placed in the scene before entering playmode.

    One difference I notice between inspecting a pre-instantiated entity and a runtime-instantiated entity is that the runtime-instantiated entity refers to the prefab asset, the other one does not. Maybe it got something to do with how I instantiate entities from prefabs? This is the authoring for my "tank factory". It's essentially a singleton entity that holds the tank prefab.

    Code (CSharp):
    1. public class TankFactoryAuthoring : MonoBehaviour {
    2.   public GameObject TankPrefab;
    3.  
    4.   class Baker : Baker<TankFactoryAuthoring> {
    5.     public override void Bake(TankFactoryAuthoring authoring) {
    6.       var entity = GetEntity(TransformUsageFlags.Dynamic);
    7.       AddComponent(entity, new TankFactoryComponent() {
    8.         TankPrefab = GetEntity(authoring.TankPrefab, TransformUsageFlags.Dynamic),
    9.       });
    10.     }
    11.   }
    12. }
    In my tank spawner system I spawn tanks from my tankfactory like so:

    Code (CSharp):
    1. TankFactoryComponent tankFactory = SystemAPI.GetSingleton<TankFactoryComponent>();
    2. Entity unitEntity = commandBuffer.Instantiate(tankFactory.TankPrefab);
    Everything worked fine before I updated the packages though.
     
    Last edited: Sep 12, 2023
  5. haxic

    haxic

    Joined:
    Jul 12, 2021
    Posts:
    20