Skip to content

Fix SoftMaskScript not updating when nested under a Unity Mask - #542

Closed
Labu1 wants to merge 38 commits into
Unity-UI-Extensions:releasefrom
Labu1:repodestek/issue-212
Closed

Labu1 wants to merge 38 commits into
Unity-UI-Extensions:releasefrom
Labu1:repodestek/issue-212

Conversation

@Labu1

@Labu1 Labu1 commented Nov 23, 2026

Copy link
Copy Markdown

Unity UI Extensions - Pull Request

Overview

The SoftMaskScript stopped working when its graphic was a child of a Unity Mask, such as the viewport of a ScrollView. The masked image disappeared on play, or the mask stayed fixed in place while the content scrolled.

The cause: a maskable graphic under a Mask does not render with the material that SoftMaskScript assigns. MaskableGraphic.GetModifiedMaterial swaps in a stencil copy of that material from Unity's StencilMaterial cache. SetMask() only ever updated the original material, so the copy that was actually drawn kept old _AlphaMask offset/scale and cutoff values. This also explains the workarounds in the issue thread: unticking Maskable, or toggling the component to rebuild the stencil material.

Changes

  • SetMask() now also applies the soft mask properties to the material that is actually drawn (canvasRenderer.GetMaterial()), but only when that material is not the base material and uses the same shader.

  • The property setting moved into a small ApplyMaskProperties(Material) helper, and the graphic (Image or TMP text) is cached in Start().

  • Fixes: Soft Mask Script not working when it is a child of another Mask #212

Breaking Changes

  • None. Graphics that are not under a Mask render with the base material, so they behave exactly as before.

Related Submodule Changes

  • N/A

Testing status

  • No tests have been added.

No automated test command was detected, so tests were not run.

Manual testing status

Not tested in the Unity editor yet. Suggested check: put Images that use SoftMaskScript inside the Content of a ScrollView whose viewport has a Unity Mask. Enter play mode and confirm the images are soft-masked and that the mask moves with them while scrolling. Also check that a SoftMaskScript outside any Mask still works as before.


This PR was prepared with AI assistance (Claude) and reviewed by me before submitting.

action and others added 30 commits November 26, 2023 18:29
Optimize Gradient2 when 'ModifyMesh' called
…radient2-fix-radial-triangle

Enhance/gradient2 fix radial triangle
* Update CardPopup2D.cs

add support for Unity 6 api

* Gradient2.ModifyMesh

Modify Mesh should respond to gradient key updates in inspector and runtime
In Unity-UI-Extensions#480 the check for a change in length of transforms in a Line Connector was changed, resulting in the UILineRenderer not being updated when new points were added to the UILineConnector. This PR restores that check.
…to support Unity UI (Unity-UI-Extensions#497)

* Initial check-in for Unity 6 update - thank you Unity for continuing to support Unity UI
* Update workflows from base update
* Unity 6 script clean-up (remove legacy dependencies)
* Update package definition for Unity 6 focus
* Update examples checkout
* Updated Picker control and samples to latest
* Update UIVertical Scroller to be more efficient for U6 and update example
* Clear out old text controls, no longer valid. Update combobox scripts
* Reverted Curly Text back to old Text component as it is not compatible with TextMeshPro - will investigate alternatives
* All scenes tested, 2 issues remain, re-orderable list and selection box
* Pausing Linux testing until Unity sort their stuff out
…-Extensions#490)

* Pivot can now be used as reference point when drawing lines

* Removed cap points as they caused lod and jagged-texture issues

---------

Co-authored-by: Pontus Andersson <pontus.andersson1@live.se>
* Initial check-in for Unity 6 update - thank you Unity for continuing to support Unity UI
* Update workflows from base update
* Unity 6 script clean-up (remove legacy dependencies)
* Update package definition for Unity 6 focus
* Update examples checkout
* Updated Picker control and samples to latest
* Update UIVertical Scroller to be more efficient for U6 and update example
* Clear out old text controls, no longer valid. Update combobox scripts
* Reverted Curly Text back to old Text component as it is not compatible with TextMeshPro - will investigate alternatives
* All scenes tested, 2 issues remain, re-orderable list and selection box
* Added GridRawImage & UI_Knob2
* UISegmentedCIrcle control
* Added UI Graphic Selector
* Renamed Segment to SegmentedControlSegment:
* Addressed NRE in Reorderable List
* Patch debug option to allow both Text and TMPro
* Update layout groups to rebuild on disable/enable - Resolves: Unity-UI-Extensions#468
* Resolved stacking issue with the Reorderable list when moving the elements "slightly" - Resolves Unity-UI-Extensions#470
* Added a close line option which finished the line off with a "closer" to fill any gaps at the end - Resolves: Unity-UI-Extensions#449
* Resolved race condition issue in regards to the ScrollSnap control which could raise a NaN error when lerping - Resolves: Unity-UI-Extensions#452 / Unity-UI-Extensions#508
* Patch the HSS/VSS against a potential divide by zero error is the scroll snap has a single page
* Update GetCurrentPage to be more resilient - Fixes Unity-UI-Extensions#254
* Resolve out of bounds issues with the Infinite scroll control - Fixes Unity-UI-Extensions#237
* Updated UI Particle system to address Unity-UI-Extensions#486/Unity-UI-Extensions#487 requiring a new "CullingMode" option that when enabled alters the control to resolve unscaleddeltatime - Fixes Unity-UI-Extensions#486, Unity-UI-Extensions#487
* Patch for Unity-UI-Extensions#477 plus some general housekeeping for maintaining TMPro/Text compatibility
* Update SegmentedCircle controls with new meta files and update examples checkout
* Update scrollsnap to be more resilient to rescaling and patch full screen scroll snap RIF - Fixes Unity-UI-Extensions#257, Unity-UI-Extensions#260
* Address layout issues with the flow layout group - Fixes Unity-UI-Extensions#456
* Remove unused variable in UITextureLineRenderer
* Patch GridRawImage for editor and update automation steps
* Patch workflow to FIX the release due to obsolete errors in 6000.5
that extra space prevents ToString("F") from evaluating properly
SimonDarksideJ and others added 7 commits July 20, 2026 21:23
* Push testing to validate 5,6,7
* 6.5 patch
* Patch Unity6.6/7
* Patch docs and version
added _baseVertexColor field to fetch original vertex color from base Graphic
)

with conditional compilation to preserve back compability.
* Release V3 - take 3 :D (Unity-UI-Extensions#525)

* Add hardening to workflows

* Auto increment pre-release version to 3.0.0 [skip ci]

* Refresh README for V3.0.0 branding [skip ci]

* Add SmartFlowLayoutGroup component

Enhanced version of FlowLayoutGroup that adds several sizing modes. Supports uniform grid cells, aspect ratio preservation for icons, stretch rows for list items, and reverse wrap direction for panels that stack from the bottom. Also fixes the issue where nested LayoutGroups weren't rebuilding properly after layout changes.

It's a new component placed alongside the existing FlowLayoutGroup, so nothing breaks for current users. Tested in Unity 2021.3 with ContentSizeFitter and dynamic children.

---------

Co-authored-by: Simon (Darkside) Jackson <darkside@zenithmoon.com>
Co-authored-by: action <action@users.noreply.github.com>
* Fix CUIGraphic compile error on Unity 6.7

* Use compound condition for the Obsolete attribute

* Exclude ModifyMesh(Mesh) override entirely on Unity 6.6+

---------

Co-authored-by: armadavalor <we@westudio.com.tr>
Co-authored-by: Simon (Darkside) Jackson <darkside@zenithmoon.com>
…UI-Extensions#540)

Co-authored-by: le888 <11625590+le888@users.noreply.github.com>
@SimonDarksideJ

Copy link
Copy Markdown
Contributor

All future work needs to target the development branch, can you retarget and refresh from development please @Labu1

* Patch automation

* Patch workflow to be more conservative with expensive runners

* Enhance error handling for Unity jobs in CI workflow

* Implement retry logic for Unity license activation in CI workflow
@Labu1
Labu1 force-pushed the repodestek/issue-212 branch from b966249 to 8110e00 Compare December 3, 2026 06:53
@Labu1

Labu1 commented Dec 3, 2026

Copy link
Copy Markdown
Author

@SimonDarksideJ Thanks. While moving this onto development I found that #540 (merged on 1 December) already fixes the same problem in SoftMaskScript.cs with essentially the same approach: it also applies the mask settings to the stencil copy of the material that a parent Mask hands to the renderer. So there's nothing left for this PR to add, and I'm closing it in favour of #540. #212 can probably be closed as well.

@Labu1 Labu1 closed this Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Soft Mask Script not working when it is a child of another Mask