From 8d0dec19ad5b8904e2268964215ab2263e52fe3c Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Sat, 16 Mar 2019 16:51:21 +0900 Subject: [PATCH] fix #42; The masked images all disappear when game view is resized --- .../UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs index 908e9ce..644fec7 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs @@ -155,6 +155,7 @@ namespace Coffee.UIExtensions { _softMaskBuffer = RenderTexture.GetTemporary(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default); hasChanged = true; + _hasStencilStateChanged = true; } return _softMaskBuffer; @@ -289,6 +290,7 @@ namespace Coffee.UIExtensions graphic.SetVerticesDirty(); base.OnEnable(); + _hasStencilStateChanged = false; } /// @@ -324,6 +326,7 @@ namespace Coffee.UIExtensions ReleaseRT(ref _softMaskBuffer); base.OnDisable(); + _hasStencilStateChanged = false; } /// @@ -360,6 +363,7 @@ namespace Coffee.UIExtensions graphic.SetMaterialDirty(); OnTransformParentChanged(); base.OnValidate(); + _hasStencilStateChanged = false; } #endif @@ -383,6 +387,8 @@ namespace Coffee.UIExtensions SoftMask _parent; List _children = new List(); bool _hasChanged = false; + bool _hasStencilStateChanged = false; + Material material { get { return _material ? _material : _material = new Material(s_SoftMaskShader ? s_SoftMaskShader : s_SoftMaskShader = Resources.Load("SoftMask")){ hideFlags = HideFlags.HideAndDontSave }; } } @@ -421,6 +427,11 @@ namespace Coffee.UIExtensions if (!sm._parent) { sm.UpdateMaskTexture(); + if (sm._hasStencilStateChanged) + { + sm._hasStencilStateChanged = false; + MaskUtilities.NotifyStencilStateChanged (sm); + } } } }