Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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:
    74
    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:
    3,984
    If this is Entities 1.0, swapping the MaterialMeshInfo is actually very efficient.
     
    slushieboy99 likes this.
  3. slushieboy99

    slushieboy99

    Joined:
    Aug 29, 2014
    Posts:
    74
    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:
    3,984
    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:
    74
    Believe it or not I was just working on implementing that. Thanks for the help!