Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

How To Use Rect Mask?

Discussion in 'UGUI & TextMesh Pro' started by DoctorBronze, Oct 23, 2020.

  1. DoctorBronze

    DoctorBronze

    Joined:
    Oct 13, 2020
    Posts:
    13
    I'm currently trying to make it so that it would only render a mesh in a specific area in my game, and so i've come across rect mask which seemingly could help me do just that, however no matter where i look, i can't find a proper explanation of how to use the rect mask, i tried to unity documentation but it didn't help, i tried to look for videos and only found 1 video in which they use rect mask, and in that video the guy doesn't even explain how to use it, he just shows off the fact that he uses it. So could someone please just tell me how do i freaking use it.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Well can you explain what are you actually trying to do?

    And are you talking about "Rect Mask 2D" or something else?

    Rect Mask 2D is for UGUI to mask UI elements. What are you going to use this mask for? I'm talking about this one: https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-RectMask2D.html

    "i tried to look for videos and only found 1 video in which they use rect mask, and in that video the guy doesn't even explain how to use it, he just shows off the fact that he uses it."

    Well you could have shared the link if you think it is related to your problem. "found 1 video" means nothing. Now everyone has to guess what you are doing...

    "I'm currently trying to make it so that it would only render a mesh in a specific area in my game"

    There is also sprite mask for sprites, but I have no idea, if that is actually something you need... you are talking about mesh, so maybe it is not for you...
    https://docs.unity3d.com/Manual/class-SpriteMask.html
     
  3. DoctorBronze

    DoctorBronze

    Joined:
    Oct 13, 2020
    Posts:
    13
    I'm trying to use a mask, and more specifically a rectmask2d in order to limit a code generated mesh so that it would only be rendered in a specific area but not outside of the area.

    The video which i found found is related to my problem which is that i can't find a proper explanation of how to use rectmask2d so to include the link wouldn't help because as i said in it there isn't actually an explanation of how to use rectmask just an examplatory use of said aforementioned rectmask2d.

    Also side note, in general i'm trying to use the limitation of mesh rendering to a certain area in order to solve a bigger problem i'm having with making a 2d side scroller field of view effect which interacts with walls.
     
    Last edited: Oct 24, 2020
  4. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    "Also side note, in general i'm trying to use the limitation of mesh rendering to a certain area in order to solve a bigger problem i'm having with making a 2d side scroller field of view effect which interacts with walls."

    Well I wouldn't call that a "side note" - you are trying to do 2D side scroller and somehow limit FOV with Rect Mask 2D which is a UI effect.

    And have you actually used UGUI? I mean, do you realize UI usually doesn't even exist in same scale as your level GameObjects or Tilemaps and AFAIK Rect Mask 2D only works with elements that are children of UI Canvas, so unless you are using UI components for level, I don't think you can use Rect Mask 2D for whatever you are trying to do.
     
    Last edited: Oct 24, 2020
  5. DoctorBronze

    DoctorBronze

    Joined:
    Oct 13, 2020
    Posts:
    13
    I did not, again there aren't a lot of examples and explanations that i found that explain properly what rect mask is and how to use it. So sorry for the trouble and i guess i gotta find another solution now.
     
  6. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    "I did not, again there aren't a lot of examples and explanations that i found that explain properly what rect mask is and how to use it."

    Rect Mask 2D works pretty much like Mask - which is why there probably isn't separate tutorials for it. You can simply watch official tutorials about UGUI Mask:



    And this is what RectMask2D link I posted earlier says:

    "A RectMask2D is a masking control similar to the Mask control. The mask restricts the child elements to the rectangle of the parent element. Unlike the standard Mask control it has some limitations, but it also has a number of performance benefits"

    I'm not saying you couldn't use UI for full screen effect, of course you can use it, but sounds like there was some confusion about Mask. Also, you could create some image effect shader too.
     
  7. DoctorBronze

    DoctorBronze

    Joined:
    Oct 13, 2020
    Posts:
    13
  8. lauriej1316

    lauriej1316

    Joined:
    Sep 10, 2020
    Posts:
    1
    This tone is just gross - why not explain the thing without being condescending or belittling, especially when the core problem here is that the Unity docs are lacking, making new components/techniques difficult to learn
     
  9. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,573
    Please don't resurrect a post from over a year ago to state something like this. If you have an issue, either reach out to the individual or report this post. I would certainly say that this not a good use of your first post.
     
    AndrewShh and MousePods like this.
  10. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,635
    So... RectMask2D - im presumign you dont need an "Image" component to use it? Im also presuming it will hide things like ui elements in a ScrollRect which are offscreen? Personally I see no speed ups (but its running like lightning here already). My mac using client ias having a lot of issues with the performance of my UI som im trying to optimise. Any other tips would be appreciated.