Search Unity

public struct Disabled : IComponentData not working with ForEach (or disable render on Entities)

Discussion in 'Graphics for ECS' started by GDevTeam, Jun 28, 2020.

  1. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    I have my ForEach setup properly (other than the ref Disabled disabled is not working, thought it's in the arguments for ForEach).

    I have the component attached to the Prefab that's turned into Entities (used to create thousands).

    Code (CSharp):
    1. using Unity.Entities;
    2.  
    3. [GenerateAuthoringComponent]
    4. public struct Disabled : IComponentData
    5. { }
    Anyone know why this would not Disable the Entities in a Scene? Known issues? No code errors, even code smells from what I can tell. And the other parts of this operation work as expected. I'm running it with burst off and with .Run().

    I've been looking at this for almost two hours trying everything I can. I rather be able to disable a renderer if possible even.

    I even tried this example, no luck.
    https://forum.unity.com/threads/is-there-a-way-to-disable-entities.671458/#post-5585695

    Anyone have a suggestion?
     
  2. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Is this mean be used with fluent queries and excluding Disable components?
     
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,267
    Unity already defines a Disabled component. And by default, disabled GameObjects in a subscene will convert into disabled entities. Otherwise, you can add the built-in Disabled tag component for entities you want to disable, or use EntityManager.SetEnabled, which will apply also to all entities in the LinkedEntityGroup.
     
  4. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    I didn’t know this was available, I remember talks about it.
     
  5. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    You'll have a chuckle on this one. I thought I had to create the Authoring Component manually. Which i did gleefully. But thanks DreamingImLatios, you alerted me that it's a built-in component. I never thought to check that before. (face palm)

    Thanks!