Search Unity

Resolved Best way to change a texture of an entity?

Discussion in 'Graphics for ECS' started by slushieboy99, Aug 27, 2023.

  1. slushieboy99

    slushieboy99

    Joined:
    Aug 29, 2014
    Posts:
    88
    Hi all,
    I've been looking everywhere for the best way to do this, not seeming to have any luck. It doesn't look like you can make a material property override for a texture, and swapping out the rendermesh seems inefficient. Is there a good way to override a texture of an entity at runtime?
    Thanks!
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,254
    If this is Entities 1.0, swapping the MaterialMeshInfo is actually very efficient.
     
    slushieboy99 likes this.
  3. slushieboy99

    slushieboy99

    Joined:
    Aug 29, 2014
    Posts:
    88
    I should've mentioned I'm using Entities 0.51. I'd rather not update at this time, but is there any other way to achieve this?
     
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,254
    If you know the textures you may want to swap to in advance, you can use a texture atlas or texture array and then use a material property to select the texture by UV offsets or index respectively.
     
    slushieboy99 likes this.
  5. slushieboy99

    slushieboy99

    Joined:
    Aug 29, 2014
    Posts:
    88
    Believe it or not I was just working on implementing that. Thanks for the help!