Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Softmask elements stop drawing on resolution change sometimes #208

Closed
NibbleByte opened this issue Nov 2, 2024 · 13 comments
Closed

Softmask elements stop drawing on resolution change sometimes #208

NibbleByte opened this issue Nov 2, 2024 · 13 comments
Assignees
Labels
bug Something isn't working released

Comments

@NibbleByte
Copy link

Describe the bug
Sometimes (for example when I just started the sample project), when tweaking the Power value while the game is running, everything in the soft mask stops drawing. Maximizing the game view (i.e. changing the resolution?) fixes it.
SoftMaskNotDrawing

Similar thing happens on my original project, often when switching between fullscreen and window and clicking/drag the scrollview? - softmask stops drawing. To go fullscreen I use the Fullscreen Editor plugin (included in the project), but I don't think it's related. (in the gif, I switch to fullscreen via hotkey, so the whole image changes suddenly multiple time). Showing the pause menu overlay also fixes the drawing (enabling game objects?)
SoftMaskNotDrawing2

I have updated my project to include the stripped down of my original game setup with all the code. Look for "PaperMap.unity" scene for the game version and "PaperMap-Old.unity" for the previous sample project with the "Power" feature. But generally, both scenes experience the issue, most often on resolution change.

Updated project link: https://drive.google.com/file/d/1rsZ8mC24-38FF9fYEvkh7QYmd80dxJ83/view?usp=sharing

Toggle between windowed mode and fullscreen via "Fullscreen" menu at the top, or F10 hotkey (for me it's ALT+F2).
The scrollview has some components that tweak the behaviour, which may be important?
Note that in my projects, I've turned off assembly and scene reloads (if it makes any difference).

To Reproduce
Steps to reproduce the behavior:

  1. Open the "PaperMap.unity" scene. Restart the editor.
  2. Check if level icons are visible after opening the editor in the scene. Sometimes they're not. If they're not, toggle fullscreen (not in play mode yet).
  3. Play the scene. Code replaces the level icon slots with the "real" instances (deactivates the old, instantiates the new prefabs).
  4. Press "Unlock" button at the bottom left corner to show all the levels.
  5. Try toggling between fullscreen/maximized/windowed mode, scroll by dragging the content area or the scrollbar, click anywhere. Do these things in different sequence.
  6. Note that sometimes masked objects disappear and reappear inconsistently.
  7. If objects disappear, press ESC to show the paused menu - objects appear again in the background.

Environment (please complete the following information):

  • Version 2.4.0
  • Platform: Windows Editor
  • Unity version: 2023.2.9f1
@NibbleByte NibbleByte added the bug Something isn't working label Nov 2, 2024
@mob-sakai
Copy link
Owner

Thank you for your reporting!

@oktayturkdagli
Copy link

I think you are in the same situation as I was in before. I thought this was solved, but the problem still persists in some spots. Especially when you want to do a masking in scroolview, UISoftMask cannot keep up with the scrolling speed. Especially when done in wordcanvas + scrollview, it really exhibits inconsistencies. I didn't have a chance to download and test your project, but I suggest you try the following temporary solutions.

  • Try setting transform sensitivity high in the UISoftMask asset in Assets/ProjectSettings.
  • Or try using the anti alising feature instead of the soft mask feature from the soft mask component as a temporary solution.

@mob-sakai
Copy link
Owner

mob-sakai commented Nov 14, 2024

The issue is reproduced on my environment.
The soft mask buffer is not being updated correctly, or the dirty flag is not set.

@mob-sakai
Copy link
Owner

Fortunately, the issue did not reproduce in the build.

@mob-sakai
Copy link
Owner

The fix was released in v2.4.2. 👍

@NibbleByte
Copy link
Author

NibbleByte commented Nov 15, 2024

I've tested it and it works. But I found one issue, not sure if it is related: when I start Unity and it opens this scene initially (on first load) it throws this exception:

InvalidOperationException: Accessing game object transform hiearchy before loading of scene has completed. This is not allowed.
UnityEngine.GameObject.GetComponentsInternal (System.Type type, System.Boolean useSearchTypeAsArrayReturnType, System.Boolean recursive, System.Boolean includeInactive, System.Boolean reverse, System.Object resultList) (at <6b66e7caaeb045048a0fbc11f111e6fa>:0)
UnityEngine.GameObject.GetComponentsInChildren[T] (System.Boolean includeInactive, System.Collections.Generic.List`1[T] results) (at <6b66e7caaeb045048a0fbc11f111e6fa>:0)
UnityEngine.Component.GetComponentsInChildren[T] (System.Boolean includeInactive, System.Collections.Generic.List`1[T] result) (at <6b66e7caaeb045048a0fbc11f111e6fa>:0)
Coffee.UISoftMask.UISoftMaskProjectSettings.ResetAllSoftMasks () (at ./Library/PackageCache/[email protected]/Runtime/ProjectSettings/UISoftMaskProjectSettings.cs:143)
Coffee.UISoftMask.UISoftMaskProjectSettings.OnValidate () (at ./Library/PackageCache/[email protected]/Runtime/ProjectSettings/UISoftMaskProjectSettings.cs:154)
UnityEditor.PlayerSettings:GetPreloadedAssets()
Coffee.UISoftMaskInternal.PreloadedProjectSettings:GetPreloadedSettings(Type) (at ./Library/PackageCache/[email protected]/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs:68)
Coffee.UISoftMaskInternal.PreloadedProjectSettings:GetDefaultSettings(Type) (at ./Library/PackageCache/[email protected]/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs:75)
Coffee.UISoftMaskInternal.PreloadedProjectSettings`1:get_instance() (at ./Library/PackageCache/[email protected]/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs:142)
Coffee.UISoftMask.UISoftMaskProjectSettings:get_softMaskEnabled() (at ./Library/PackageCache/[email protected]/Runtime/ProjectSettings/UISoftMaskProjectSettings.cs:73)
Coffee.UISoftMask.SoftMask:GetActualMaskingMode() (at ./Library/PackageCache/[email protected]/Runtime/SoftMask.cs:705)
Coffee.UISoftMask.SoftMask:SoftMaskingEnabled() (at ./Library/PackageCache/[email protected]/Runtime/SoftMask.cs:695)
Coffee.UISoftMask.SoftMask:UnityEngine.UI.IMaskable.RecalculateMasking() (at ./Library/PackageCache/[email protected]/Runtime/SoftMask.cs:482)
Coffee.UISoftMask.SoftMask:OnValidate() (at ./Library/PackageCache/[email protected]/Runtime/SoftMask.cs:472)
UnityEditor.EditorApplication:Internal_RestoreLastOpenedScenes()

If I reload the scene, start, stop play mode, I don't get this exception. Only on Unity startup if this is the first scene.

When this happen, if I press play and click on screen, the softmask stops drawing again. Restarting play mode fixes it - clicking doesn't stop softmask drawing.

EDIT: ok, similar exception happens if you start Unity on different scene, then switch to my scene. And softmask drawing is broken.
image

@mob-sakai mob-sakai reopened this Nov 15, 2024
@mob-sakai
Copy link
Owner

For now, I reverted the fix. (v2.4.3)

@mob-sakai
Copy link
Owner

@NibbleByte

I've tested it and it works. But I found one issue, not sure if it is related: when I start Unity and it opens this scene initially (on first load) it throws this exception:

Umm, it is not reproduced on my environment.

  • Mac Editor
  • Unity 2023.2.20f1
  • SoftMaskForUGUI v2.4.2

@NibbleByte
Copy link
Author

NibbleByte commented Nov 16, 2024

I have migrated to Unity 6.0.27f1 and it still happens, same callstack.
Could be a Windows thing.
Happens on another Windows PC I tested with.

@NibbleByte
Copy link
Author

NibbleByte commented Nov 16, 2024

I happen to have a MacBook Pro with Sonoma installed. I copied the Unity 6.0.27f1 windows project version (including the Library & UserSettings folders) on it, after platform switch and restart it happened - the same exception. PaperMap scene opened.

@mob-sakai
Copy link
Owner

mob-sakai commented Nov 16, 2024

Thank you.
The issue is reproduced on Windows PC (Standalone Editor, Unity 6000.0.27f1).

mob-sakai added a commit that referenced this issue Nov 16, 2024
github-actions bot pushed a commit that referenced this issue Nov 16, 2024
## [2.4.4](v2.4.3...v2.4.4) (2024-11-16)

### Bug Fixes

* accessing game object transform hierarchy before loading of scene has completed ([9dfacbf](9dfacbf)), closes [#208](#208)
* softmask elements stop drawing on resolution change sometimes in editor ([f67d025](f67d025)), closes [#208](#208)
Copy link

🎉 This issue has been resolved in version 2.4.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this issue Nov 16, 2024
github-actions bot pushed a commit that referenced this issue Nov 16, 2024
## [2.4.4](v2.4.3...v2.4.4) (2024-11-16)

### Bug Fixes

* accessing game object transform hierarchy before loading of scene has completed ([9dfacbf](9dfacbf)), closes [#208](#208)
* softmask elements stop drawing on resolution change sometimes in editor ([f67d025](f67d025)), closes [#208](#208)
@NibbleByte
Copy link
Author

It's fixed. Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

3 participants