/// <summary> /// 我们将编辑器的数据表述转化成实体最佳的运行时表述 /// </summary> /// <param name="entity">实体</param> /// <param name="dstManager">目标实体管理器</param> /// <param name="conversionSystem">转化系统</param> public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var spawnerData = new Spawner_FromEntity { Prefab = conversionSystem.GetPrimaryEntity(Prefab), //将Prefab转成实体Entity CountX = CountX, CountY = CountY }; dstManager.AddComponentData(entity, spawnerData); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var spawnerData = new Spawner_FromEntity { //被引用的预设因为做了声明将被转化成实体 //所以我们这里只是将游戏对象标记到一个引用该预设的实体上 Prefab = conversionSystem.GetPrimaryEntity(prefab), time = 5 }; dstManager.AddComponentData <Spawner_FromEntity>(entity, spawnerData); }
// Lets you convert the editor data representation to the entity optimal runtime representation public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var spawnerData = new Spawner_FromEntity { // The referenced prefab will be converted due to DeclareReferencedPrefabs. // So here we simply map the game object to an entity reference to that prefab. Prefab = conversionSystem.GetPrimaryEntity(Prefab), CountX = CountX, CountY = CountY }; dstManager.AddComponentData(entity, spawnerData); }
// Lets you convert the editor data representation to the entity optimal runtime representation public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var spawnerData = new Spawner_FromEntity { // The referenced prefab will be converted due to DeclareReferencedPrefabs. // So here we simply map the game object to an entity reference to that prefab. Prefab = conversionSystem.GetPrimaryEntity(Prefab), CountX = CountX, CountY = CountY }; //dstManager.SetComponentData(entity, new UnitNavAgentComponent { RandomThreshold = new float3(Random.Range(0f,10f),Random.Range(0f,10f),Random.Range(0f,10f)) }); //dstManager.AddComponentData(entity, xd); dstManager.AddComponentData(entity, spawnerData); }