ECS/Unity/UnityEntityManager.cs
/// <summary>
/// Instantiates only Entities with there Components from Prefab! 
/// Wont Instantiate GameObject itself!
/// Use InstantiateWithGameObject instead.
/// </summary>
Instantiates only Entities with there Components from Prefab.
Wont Instantiate GameObject itself.
Instantiates only Entities with there Components from Prefab . Wont Instantiate GameObject itself .
public void Instantiate(GameObject prefab, NativeArray<Entity> entityArray) {
            var gameObjectEntity = prefab.GetComponent<GameObjectEntity>();
            if (!gameObjectEntity) {
                throw new Exception(prefab.name + " cant be instantiate without " + typeof(GameObjectEntity).Name + " component");
            }
            ComponentWrapper[] components = gameObjectEntity.GetComponents();
            for (int i = 0; i < entityArray.Length; i++) {
                entityArray[i] = CreateEntity();
            }
            for (int i = 0; i < components.Length; i++) {
                for (int j = 0; j < entityArray.Length; j++) {
                    components[i].AddComponentToEntity(entityArray[j], this);
                }
            }
        }
public void Instantiate ( GameObject prefab , NativeArray < Entity > entityArray ) { var gameObjectEntity = prefab . GetComponent < GameObjectEntity > ( ) ; if ( ! gameObjectEntity ) { throw new Exception ( prefab . name + " " + typeof ( GameObjectEntity ) . Name + " " ) ; } ComponentWrapper [ ] components = gameObjectEntity . GetComponents ( ) ; for ( int i = 0 ; i < entityArray . Length ; i ++ ) { entityArray [ i ] = CreateEntity ( ) ; } for ( int i = 0 ; i < components . Length ; i ++ ) { for ( int j = 0 ; j < entityArray . Length ; j ++ ) { components [ i ] . AddComponentToEntity ( entityArray [ j ] , this ) ; } } }
Instantiates only Entities with there Components from Prefab!
Instantiates only Entities with there Components from Prefab!
prefab
GameObject
entityArray
NativeArray<Entity>