Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

An issue with accessing singleton entity within job component system

Discussion in 'Entity Component System' started by Curlyone, Jan 23, 2020.

  1. Curlyone

    Curlyone

    Joined:
    Mar 15, 2018
    Posts:
    41
    Hello, i am experiencing a weird issue while getting a singleton from job component system.
    This is my singleton entity.

    Code (CSharp):
    1.  
    2.         var kanwisSingleton = entityManager.CreateEntity(
    3.                 typeof(Kanwis),
    4.                 typeof(LocalMarketComparissionBuffer),
    5.                 typeof(KanwisSingleton)
    6.             );
    7.  
    Here is my job component system that consumes it:

    Code (CSharp):
    1.  
    2.         NativeArray<Entity> markets1 = new NativeArray<Entity>(100, Allocator.TempJob);
    3.  
    4.         var firstJob = new FirstJobStruct()
    5.         {
    6.             entities = markets1
    7.         }.Schedule(this, inputDependencies);
    8.  
    9.         var singleton = GetSingletonEntity<KanwisSingleton>();
    10.         var localbuffer = GetBufferFromEntity<LocalMarketComparissionBuffer>()[singleton];
    11.  
    12.         var marketbuffermanager = GetBufferFromEntity<MarketDataBuffer>(true);
    13.  
    14.         var secondJob = new SecondJobStruct()
    15.         {
    16.             buffer = localbuffer.AsNativeArray(),
    17.             entities = markets1,
    18.             marketDataBuffer = marketbuffermanager
    19.         }.Schedule(this, firstJob);
    20.  
    21.         return secondJob;
    22.  
    The system works but i am getting this from entity debugger:
    KanwisSingletonIssue.png

    And this "KanwisSingleton" spawns every frame. My systems takes 0.2 ms when it starts but starts to take 1 ms after 5-10 mins, not sure if this is a bug or i am doing something wrong. Any help is appreciated :)
     
    cjxm likes this.
  2. cjxm

    cjxm

    Joined:
    Feb 1, 2016
    Posts:
    6
    I am experiencing the same issue. After updating to the last version of Entities singletons spawn every frame in the systems which consume them. I guess it's a bug.
     
  3. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148