Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

applying textures without changing the color of the object

Discussion in 'Getting Started' started by raghadalghonaim, Jul 21, 2020.

  1. raghadalghonaim

    raghadalghonaim

    Joined:
    Apr 22, 2020
    Posts:
    54
    Sorry if this is a dumb question, I'm a newb to Unity.

    I'm wondering if it's possible to apply a texture to an object without replacing its current color?

    e.g. if I have a blue sphere, and I applied a texture to it, I need everything to change but not its color (I want it to stay blue). Removing the color (or base map) sometimes helped but not with all the materials.
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,553
    You need to write a shader that multiplies the texture by base object color.
     
  3. raghadalghonaim

    raghadalghonaim

    Joined:
    Apr 22, 2020
    Posts:
    54
    Thanks for your reply, could you point me out to a good resource for learning how to build shaders?

    Thanks.
     
  4. niknakgames

    niknakgames

    Joined:
    Aug 7, 2015
    Posts:
    25
    Code (CSharp):
    1. var materials = renderer.materials
    2. materials[0] = newMaterial
    3. render = materials
    Psuedo code but you could swap the materials on the renderer. Just have the new material be the same blue with a texture attached. Hope this helps.