How do I know if an entity is a template or not

I just wonder if there is a way to validate if an entity returned by findByName is a template or not.

When I see the entity object, the template attribute is always false even though it’s a template in editor.

Hi @sooyong_Kim,

Templates are assets and they can’t be part of the scene hierarchy.

Whenever you instantiate a template, an entity is returned and that’s what you add to hierarchy. I don’t think there is a way to know if that entity came from a template (@yaustar).

You will have to keep track of those entities yourself, maybe a special tag that you add as soon as you instantiate?

I think it’s okay to identify if an entity is a template in editor, but it’s difficult to debug in script level.

It would be great if the api supports it.

Once a template is instantiated, it is an entity hierarchy, it is not possible to know it’s from an entity. I would workaround it by adding a tag to the entity root in the template asset.

1 Like

In Unity you can tell when a gameobject comes from a prefab because it’s blue. Would be nice if PlayCanvas did something similar.

In the Editor, template instances with have a diamond icon next to it on the left in the hierarchy view @Marks

Just at runtime, you can’t identity if an entity is an template instance or not.

1 Like