Search Unity

Creating a UI Mask

Discussion in 'UGUI & TextMesh Pro' started by Shadowing, Dec 28, 2018.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I'm not sure why creating a UI mask isn't working for me.

    Isn't it this below?

    Hierarchy
    Code (csharp):
    1.  
    2. Mask
    3.    Image
    4.  
    Mask Game Object has Components Mask, Image and Canvas Renderer
    Image Game Object has Components Canvas Renderer and Image

    I'm using Unity Standard UIMask Image
    As you can see the image has square corners



    The mask when I disable the Image Game Object


     
    jesseparsons1 likes this.
  2. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    I have tested myself and this works for me.
    upload_2018-12-28_20-24-54.png
     
    a1anas1a and jesseparsons1 like this.
  3. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Thanks for the reply man.
    ya idk what the heck.

    Certain canvas settings maybe?

    I created a Scroll View just now with in the same canvas and the mask works fine for that.
     
  4. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Ehh just noticed its working now.
    All I did was just go back to the scene.
    Canvas isn't updating or something idk.
    I hit save scene earlier though. As well as disabling canvas and enabling it.
     
  5. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I notice this removes my Shadow effect now though :(
     
  6. Hummelvogel

    Hummelvogel

    Joined:
    Apr 4, 2018
    Posts:
    8
    Older thread, I know, but I ran into the same problem and thought I'd post my solution in case anyone stumbles upon this thread in the future.

    Had the same problem with masking not working. Turns out, my child object had a material with a texture on in, but no sourceImage (Sprite). I worked when I duplicated the material's texture as a UI Sprite, the slapped it onto the SourceImage slot and removed the material altogether.

    (Bit of a shame though, I wanted said child object to be rendered additive, which I found no way of making possible without the use of a material. Oh well.)
     
  7. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    ya its impossible to make it addictive without a material.
     
  8. Hummelvogel

    Hummelvogel

    Joined:
    Apr 4, 2018
    Posts:
    8
    I cobbled together a shader the other day in Amplify that did the trick for me. I used the Legacy/DefaultUI Template, set the blend mode to additive and piped BaseTexture, Vertex Color and a Mask Texture into the output node - däng, UI Masking. I wonder why this isn't a default shader in Unity, or am I missing something?
     
  9. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    ya idk. been using Unity for 5 years still barely understand shader stuff lol