prefab in subscene not getting prefab tag

might be missing something dumb here, I’m just getting started with ECS…

I created a new subscene and added a Prefab to it (it has a Baker that adds a FlutterUnit tag component). I’m under the impression a Prefab tag will get automatically added so it doesn’t show up in queries and won’t render, but it’s not:

is there something special I need to do to get it to add the Prefab Tag? thanks!

I think you have added the prefab to the scene as a regular scene object. To bake a prefab, you need to have another scene object that bakes your prefab by calling GetEntity on it. This returns a reference to the prefab entity that you can store in a component (eg. for spawning at runtime).

There’s a difference between prefabs and prefab instances. What you have in the scene is a prefab instance, as opposed to a prefab that lives as a file in the project. You need to bake a reference to the prefab itself.

thanks! I’m actually modifying Brian Will’s Entities Ball Tutorial walkthrough, and he has a prefab instance in the subScene, which shows a Prefab component added to it so it doesn’t show up in queries or render… Next to that he has a Config object that references the prefab itself and calls GetEntity on it so he can instance it in the System (this bit works fine for me). When I add a prefab instance to the subScene it’s not adding a Prefab component automatically like his, I was wondering why.

If you could link the exact material you’re referring to, that would be helpful.

The screenshot just shows a prefab entity loaded in the world in the entity inspector, it’s not showing a prefab instance in the authoring subscene.

Prefab instances can more or less be treated as a normal object in a scene. They represent a thing that exists in the scene and can be interacted with. Dragging a prefab into a scene or authoring subscene creates a new prefab instance, and when added to an authoring subscene, is baked as a living object just like any other scene object. The source prefab itself on the other hand is something that doesn’t “exist” in any given scene until you instantiate an instance of it. Baking a reference to a prefab will properly bake an entity with the Prefab IComponentData. Baking a reference to a normal scene object or a prefab instance (which as I said, you can treat as a scene object) will bake it as a reference to an entity living in the world as an instance.

sure thing, here is the video with timestamp:

in the video I believe it is both a prefab instance in the authoring subScene and it’s corresponding baked entity in the entity inspector

overall from a few quick tests it does seem your explanation is correct over the video: prefab instances are baked, no prefab tag is added, and they act like any other scene object (not excluded from rendering or anything).

appreciate the clarification :slight_smile:

Regrettably, the embedded video player removed the timestamp.

I will say, having scrubbed around for a second, at 21:07 you can see the Obstacle Prefab field and the Player Prefab field in the config object refer to objects named Obstacle and Player respectively, but no such objects exist in the authoring subscene, so those must be referring to prefabs, not prefab instances.

shoot… it starts at 9:55

It is not a prefab instance. At points 3:55 and 21:07, there is no evidence of any prefab instances in the authoring subscene, the only GameObjects there are the Plane and Config objects.

The Obstacle prefab entity in the Entity Hierarchy comes from a baker handling the Config object’s reference to the Obstacle GameObject prefab (not prefab instance) stored in the project.