Search Unity

How do i get the EntityManager in the current preview ??

Discussion in 'Entity Component System' started by Held0fTheWelt, Apr 21, 2019.

  1. Held0fTheWelt

    Held0fTheWelt

    Joined:
    Sep 29, 2015
    Posts:
    173
    Last edited: Apr 21, 2019
  2. rsodre

    rsodre

    Joined:
    May 9, 2012
    Posts:
    229
    Code (CSharp):
    1. public static EntityManager EM
    2. {
    3.     get { return World.Active.EntityManager; }
    4. }
    5.  
     
    lclemens likes this.
  3. Held0fTheWelt

    Held0fTheWelt

    Joined:
    Sep 29, 2015
    Posts:
    173
    Now i feel dumb, but thank you ^^
     
  4. Chris-Herold

    Chris-Herold

    Joined:
    Nov 14, 2011
    Posts:
    116
    If you need it in a System, it's part of the base class, so you can just write this.EntityManager to get it.


    Code (CSharp):
    1.  public abstract class ComponentSystemBase
    2. {
    3.         protected internal EntityManager EntityManager { get; }
    4. }
     
    Held0fTheWelt likes this.
  5. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    761
    This have changed slightly in the newer versions of the entities package. You can't use World.Active.EntityManager anymore - now it is typically:

    Code (CSharp):
    1. World.DefaultGameObjectInjectionWorld.EntityManager
     
    Abrazos and Ajasmm02 like this.