I have a UI ScrollRect with a UI Mask script component attached to it. It is properly masking it’s child elements which were created in the editor. Example: The ScrollRect contains a map image with child objects which are indicators of positions of importance on the map, such as the player’s location. These are being moved by script and properly masked by the UI Mask script component.


PROBLEM: When adding map indicators at runtime via script, the added objects are NOT being masked by the UI Mask in the UI ScrollRect, even though they are parented to to the same objects and at the same level in the hierarchy as the working components.


How can I set an instantiated object to apply the UI Mask in it’s parent?

i have never used this, but UI elements have a property call maskable that you can set to bool or false, can you try setting the myImage.maskable = true; when you instantiate it?

Thank you @xxmariofer for the help, I’ve found the issue:

I was directly assigning the object’s parent like this:

doorway.transform.parent = transform

rather than using the SetParent method:

doorway.transform.SetParent(transform, false);