Search Unity

ECS How to set an entity layer?

Discussion in 'Entity Component System' started by closeapps, Apr 16, 2019.

  1. closeapps

    closeapps

    Joined:
    May 24, 2016
    Posts:
    3
    My game has a set of lights and each of them illuminates a different layer.
    I'm using ECS in a specific part of the game, but all instantiated entities are being illuminated by the light that illuminates the default layer.
    This means that the "entity is on the default layer".
    How can I change the layer of an entity?
     
    addent likes this.
  2. closeapps

    closeapps

    Joined:
    May 24, 2016
    Posts:
    3
    up
     
  3. Hronom

    Hronom

    Joined:
    Nov 4, 2018
    Posts:
    1
  4. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    (edit: sadly, not true as of the time of writing, thanks to @tertle for the correction, see below)

    With hybrid rendering:

    Code (CSharp):
    1.             entityManager.SetSharedComponentData<RenderMesh>(entity, new RenderMesh
    2.             {
    3.                 mesh = theMesh,
    4.                 material = theMaterial,
    5.                 subMesh = 0,
    6.                 layer = 0, // Here
    7.                 castShadows = ShadowCastingMode.On,
    8.                 receiveShadows = true
    9.             });
     
    Last edited: Jul 15, 2019
    PrimalCoder and EirikWahl like this.
  5. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Pretty sure last time I checked RenderMesh layer is never used and is more of a placeholder for now unfortunately to the OP.
     
    florianhanke likes this.
  6. Forest3

    Forest3

    Joined:
    May 3, 2014
    Posts:
    15
    (Replying to this kind of old thread because it still shows up as one of the first entries in google.)

    I checked Florianhanke's suggestion in version 2019.2.11f1, and it works as expected.
     
  7. kro11

    kro11

    Joined:
    Sep 23, 2019
    Posts:
    105
    Is it possible to it now using burst?