Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help! Weirdness In Entities.ForEach

Discussion in 'Entity Component System' started by Filter_Feeder, Jul 3, 2021.

  1. Filter_Feeder

    Filter_Feeder

    Joined:
    Oct 19, 2017
    Posts:
    45
    I'm trying to use SystemBase to make jobs out of and entities.ForEach system I have set up. I'm having some strange issues with the system just not running anything (not even onStartRunning) when I'm trying to use a custom component as input, but working fine when using Translation.

    Code (CSharp):
    1. public class TerrainSystems : SystemBase
    2. {
    3. protected override void OnUpdate()
    4.     {
    5.     Debug.Log("Updating");
    6.         Entities.ForEach((ref Translation translation) =>
    7.         {
    8.             /*...*/
    9.         }).Schedule();
    10. }
    11. }
    The Above Example Works, but when I change it to *below* it does not run anything and It doesn't print "updating" and doesn't spawn entities (another method not shown).

    Code (CSharp):
    1. public class TerrainSystems : SystemBase
    2. {
    3. protected override void OnUpdate()
    4.     {
    5.     Debug.Log("Updating");
    6.         Entities.ForEach((ref GenericToxelData data) =>
    7.         {
    8.             /*...*/
    9.         }).Schedule();
    10. }
    11. }
    The "GenericToxelData" Looks like this.

    Code (CSharp):
    1. using Unity.Mathematics;
    2. using Unity.Entities;
    3. using UnityEngine;
    4.  
    5. public struct GenericToxelData : IComponentData
    6. {
    7.     public float3 windVector;
    8.     public float temperature;
    9.     public float airSubstance;
    10.  
    11.     public int xPos;
    12.     public int yPos;
    13.     public int zPos;
    14.  
    15. }
     
  2. SchnozzleCat

    SchnozzleCat

    Joined:
    Oct 23, 2013
    Posts:
    42
  3. Filter_Feeder

    Filter_Feeder

    Joined:
    Oct 19, 2017
    Posts:
    45
    Thanks, but there certainly are entities with such components, I see them in the entity debugger. Anyhow, it's even weirder because they don't even spawn when I add my custom component to the query.
     
  4. Filter_Feeder

    Filter_Feeder

    Joined:
    Oct 19, 2017
    Posts:
    45
    Furthermore, I have a Debug.Log-thing in the OnStartRunning which doesn't print
     
  5. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,697
    Maybe share your code, it will make it much easier for people to help.