Question: I have a file of size 1GB. I want to find out how many times the word "sosowhat" is found in the file. I've written a code using fgetc() which reads one character at a time from the file which is way too slower when it comes for a file of size 1GB. So I made a buffer of size 1000(using mmalloc) to hold 1000 words at a time from the file and I used the strstr() function to count the occurrence of the word "sosowhat". The logic is fine. But the problem is that if the part "so" of "sosowhat" is located at the end of the buffer and the "sowhat" part in the new buffer, the word will not be counted. So I used two buffers old\_buffer and current\_buffer. At the beginning of each buffer I want to check from the last few characters of old buffer. Is this possible? How can I go back to the old buffer? Is it possible without memmove()? As a beginner, I will be more than happy for your help.

Answer: 
The `RawImage`component should work with masks just like your normal `Image` component does. Granted that the checkmark `Maskable` is ticked.

Note that the `Mask` or `rect Mask 2D` should be the *parent* of the (raw)images you are trying to mask. The hierarchy should be something like this:

```
Canvas<br>
   | MaskObject (Contains (Raw)Image and Mask or Rect Mask 2d components)
       | Object to mask (Contains the (raw)image to mask)

```

[![Example](https://i.gyazo.com/5ca17bc75aac36691ef7c41ba5b73f07.png)](https://i.gyazo.com/5ca17bc75aac36691ef7c41ba5b73f07.png)Notice how the white square (Image) gets cut off by the red square (Mask).

The component types between the masking image and the masked image do not need to match either. A `RawImage` can mask an `Image` and vice versa.
[![Example](https://i.gyazo.com/442d8634c91013c5a64cb4271689c731.png)](https://i.gyazo.com/442d8634c91013c5a64cb4271689c731.png) The Masking objects are again shown in red, where the white are the masked objects. The GameObject's names show the used (raw)image component for that gameobject.

The only exception is the [`SpriteMask`](https://docs.unity3d.com/Manual/class-SpriteMask.html) which exclusively works with the `Sprite Renderer` component

There is not much explanation from Unity on masks... [This](https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-Mask.html) being the closest to an explanation there is

Some more info about masks:  

Masks work by comparing the ref(erence) values of the stencil buffers of the two (or more) objects (in this case images) and only drawing the pixels where the stencil buffer for both equals to 1 using the Stencil's Comp(arison) function. Meaning it is possible to create your own implementation of masks by creating a shader and implementing the [Stencil buffer](https://docs.unity3d.com/Manual/SL-Stencil.html), this comes in handy when for example you want something like an inversed mask, where pixels are drawn everywhere except where the mask is (creating holes in an image) :)
just put the raw image as a child of a UI image and call the parent image "Mask" then put in any shape of sprite in the "Mask" image. Go to 'add component' then 'UI' then add 'mask'. Please look at this link <https://learn.unity.com/tutorial/ui-masking#6032b6fdedbc2a06c234cd3e> it work well for me