Search Unity

Shader does not obey Rect Mask 2D

Discussion in 'Shaders' started by yanivng, Oct 2, 2019.

  1. yanivng

    yanivng

    Joined:
    May 21, 2017
    Posts:
    43
    Hi,

    I wrote a customer shader whose purpose is to change the color of a gray button to some predefined color (this way I am saving some memory). This is working.
    However, for some reason, the shader does not obey the "Rect Mask 2D" component and I am getting the following result:

    The area circled in red should have been removed. The shader source is attached.
    Any help is highly appreciated!

    Thanks,
    Yaniv
     

    Attached Files:

    Last edited: Oct 4, 2019
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    I'm no UI shader expert but I've made one or two in the past - are you sure you have all the necessary Tags and keywords etc. there that exist in UI-Default.shader, for example?

    I think it's better to download the Unity shader sources from the download archive (https://unity3d.com/get-unity/download/archive) and then get the appropriate archive from the dropdown (Built in shaders). Clone the default shader or whatever is closest to your needs and modify it to match your shader. I'm pretty sure (although I didn't try) that you will get it to work that way.
     
    yanivng likes this.
  3. yanivng

    yanivng

    Joined:
    May 21, 2017
    Posts:
    43
    Thanks @Olmi . Actually I started from scratch and cloned one of the shaders, that did the trick.
    Thanks!