how to clip out ui element if they are not inside an element unity
// Add a "Rect Mask 2D" to the main parent
Here is what the above code is Doing:
1. Create a new GameObject
2. Add a RectMask2D component to it
3. Set the parent of the new GameObject to the main parent
4. Set the name of the new GameObject to “Rect Mask 2D”