Closed SvenRH closed 1 week ago
The issue seems to be that the RenderTexture is recreated on resize, but the new Texture isn't applied to the SoftMaskable.
A possible fix would be to add the softMaskBuffer to the _effectMaterialHash calculation, but it seems like it would be a better idea to just set the Texture outside of MaterialCache (seems like overkill to recreate the material just for that).
Is there any update on this? The fix mentioned sounds nice but I'm not sure how to apply it.
I made a script that disables and re-enables SoftMasks to refresh them. It worked for me. Just place this script to every GameObject with SoftMask.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Coffee.UISoftMask;
public class SoftMaskFixer : MonoBehaviour
{
private SoftMask softMask;
private List<GameObject> childs = new List<GameObject>();
private void OnRectTransformDimensionsChange()
{
if(softMask == null)
{
softMask = GetComponent<SoftMask>();
foreach(Transform child in transform)
{
childs.Add(child.gameObject);
}
}
if(gameObject.activeInHierarchy)
{
StartCoroutine(Fix());
}
}
private IEnumerator Fix()
{
foreach(GameObject child in childs)
{
child.SetActive(false);
}
softMask.enabled = false;
yield return new WaitForSeconds(0.01f);
softMask.enabled = true;
foreach (GameObject child in childs)
{
child.SetActive(true);
}
}
}
I'm able to reproduce this issue on 2.2.0 with Unity version 2022.3.16f. There are some instances where the image flickers before disappearing when the canvas is actively being resized.
Thank you for your reporting!
Does it occur only in the editor?
Yes and regardless of if playmode is enabled.
Can I attach videos or gifs?
https://github.com/user-attachments/assets/3f733bc2-a361-45b2-a737-8adeb9a0eeb5
Thank you for your quick support!
@mushakushi I created a new issue: #184
Describe the bug Softmaskable images disappear when game is resized when there are are images using the unity mask in the scene.
To Reproduce Steps to reproduce the behavior:
If the images using the 'normal' Unity mask are removed, everything seems to be fine.
Expected behavior SoftMask should work when there are Unity Masks used in the scene.
Screenshots
Environment (please complete the following information):