- Home /
Question by
SirDodgy · May 20, 2020 at 01:17 PM ·
componentsdots
Instantiated prefab missing ECS components
I'm instantiating this prefab:
With this code:
GameObject goPrefab;
if (AssetHandler.GetInstance().prefabData.TryGetValue(archPrefabToCreate, out goPrefab))
{
Entity spawnedEntity = entityManager.Instantiate(goPrefab);
}
The goPrefab is being found correctly, and the entity is being created, however its missing all components, such as mesh and translation.
Am I missing a step or something?
Comment
Answer by andrew-lukasik · May 20, 2020 at 03:23 PM
WORKING CODE SAMPLE (Nov 22, 2019)
You need to convert that GameObject to 'prefab' entity first:
var prefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy( goPrefab , settings );
var instanceEntity = entityManager.Instantiate( prefabEntity );
Your answer
Follow this Question
Related Questions
ECS - entity connection 1 Answer
How to have an array property in a component 2 Answers
Class as a member of IComponentData struct? 0 Answers
Entities are not rendering until the bottom left point is in camera 1 Answer
SystemBase ECS unity doesnt let me acess NativeMultiHashMap because it isnt readonly? 2 Answers