Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

using ecs with hdrp, component group with typeof(Light) not working

Discussion in 'Entity Component System and C# Job system' started by kstothert, Feb 9, 2019.

  1. kstothert

    kstothert

    Joined:
    Dec 8, 2016
    Posts:
    45
    Code (CSharp):
    1.  lamp = GetComponentGroup(
    2. typeof(Lamp),
    3. typeof(Light)
    4. );
    when I check which light component is being referenced it's coming from UnityEngine.Light. I thought there would be a new light component in the hdrp code so i dug around but could find nothing.

    adding
    Code (CSharp):
    1. using UnityEngine.Experimental.Rendering.HDPipeline;
    does not work either
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    273
    I think HDRP uses UnityEngine.Light and there is no other light component anywhere.
     
  3. kstothert

    kstothert

    Joined:
    Dec 8, 2016
    Posts:
    45
    but the system does not run because the component group signature isn't matching. It has to be looking for a different Light component than the one the is attached via the GameObjectEntity.

    My intellisense is ignoring preview packages so I am unable to see where the Light component is coming from that is being referenced in the hdrp preview code. If I could just see where they are getting it from i could add that using directive
     
  4. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    273
    I did a quick test and it finds my lamps.

    Code (CSharp):
    1. public class LightSystem : ComponentSystem {
    2.   ComponentGroup m_lightGroup;
    3.  
    4.   protected override void OnCreateManager() {
    5.     base.OnCreateManager();
    6.     m_lightGroup = GetComponentGroup(typeof(Light));
    7.   }
    8.  
    9.   protected override void OnUpdate() {
    10.     var lightCount = m_lightGroup.CalculateLength();
    11.     Debug.Log($"System is running with {lightCount} lights");
    12.   }
    13. }
    Can you show me the definition for Lamp type.
     
    kstothert likes this.
  5. kstothert

    kstothert

    Joined:
    Dec 8, 2016
    Posts:
    45
    i figured it out...I was adding the light directly to my lamp GO which included a MeshRenderer component (as did my actual componentgroup signature) when i added the light it automatically removed the mesh renderer preventing the system from running. of course it makes sense that it can't be a mesh and a light source.

    thanks for the sanity check.
     
    GilCat likes this.