diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md index 8fff011..1003f91 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [v0.8.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.8.0) (2019-05-01) + +[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.7.2...v0.8.0) + +Camera movement affects the mask rendering when on a World Space Canvas. +![](https://user-images.githubusercontent.com/12690315/57015752-68540b80-6c51-11e9-8511-2d4534dd9d58.gif) + +**Fixed bugs:** + +- In overlay mode, mask will be incorrect if the root canvas's parent position are not zero [\#47](https://github.com/mob-sakai/SoftMaskForUGUI/issues/47) + ## [v0.7.2](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.7.2) (2019-03-16) [Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.7.1...v0.7.2) diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md index 6e6aa81..fbbaf8b 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md @@ -57,8 +57,10 @@ By using SoftMask instead of default Mask, rounded edges of UI elements can be e ![](https://user-images.githubusercontent.com/12690315/50284151-7459e080-049b-11e9-9cd3-24fb476766dc.png) * Support TextMeshPro. ![](https://user-images.githubusercontent.com/12690315/50284145-71f78680-049b-11e9-8be1-ac0ccbdf0144.png) -* Make multiple holes on one background by 'Parts of parent' option +* Make multiple holes on one background by 'Parts of parent' option. ![](https://user-images.githubusercontent.com/12690315/54102470-f5c26e80-440b-11e9-89d1-899aa4dca00d.png) +* Camera movement affects the mask rendering when on a World Space Canvas. +![](https://user-images.githubusercontent.com/12690315/57015752-68540b80-6c51-11e9-8511-2d4534dd9d58.gif) #### Components @@ -86,7 +88,7 @@ Find the manifest.json file in the Packages folder of your project and edit it t ```js { "dependencies": { - "com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git#0.7.0", + "com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git#0.8.0", ... }, } diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs old mode 100644 new mode 100755 index 4ece7d1..7a817a8 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs @@ -388,7 +388,10 @@ namespace Coffee.UIExtensions List _children = new List(); bool _hasChanged = false; bool _hasStencilStateChanged = false; - +#if !UNITY_2018_1_OR_NEWER + static readonly Dictionary s_previousViewProjectionMatrices = new Dictionary (); + static readonly Dictionary s_nowViewProjectionMatrices = new Dictionary (); +#endif Material material { get { return _material ? _material : _material = new Material(s_SoftMaskShader ? s_SoftMaskShader : s_SoftMaskShader = Resources.Load("SoftMask")){ hideFlags = HideFlags.HideAndDontSave }; } } @@ -404,6 +407,27 @@ namespace Coffee.UIExtensions if (!sm || sm._hasChanged) continue; + var canvas = sm.graphic.canvas; + if (canvas.renderMode == RenderMode.WorldSpace) + { + var cam = canvas.worldCamera; + Matrix4x4 nowsVP = cam.projectionMatrix * cam.worldToCameraMatrix; + +#if UNITY_2018_1_OR_NEWER + Matrix4x4 previousVP = cam.reviousViewProjectionMatrix; +#else + Matrix4x4 previousVP = default(Matrix4x4); + int id = cam.GetInstanceID (); + s_previousViewProjectionMatrices.TryGetValue (id, out previousVP); + s_nowViewProjectionMatrices[id] = nowsVP; +#endif + + if (previousVP != nowsVP) + { + sm.hasChanged = true; + } + } + var rt = sm.rectTransform; if (rt.hasChanged) { @@ -434,6 +458,16 @@ namespace Coffee.UIExtensions } } } + + +#if !UNITY_2018_1_OR_NEWER + s_previousViewProjectionMatrices.Clear (); + foreach (int id in s_previousViewProjectionMatrices.Keys) + { + s_previousViewProjectionMatrices [id] = s_nowViewProjectionMatrices [id]; + } + s_nowViewProjectionMatrices.Clear (); +#endif } /// @@ -482,7 +516,7 @@ namespace Coffee.UIExtensions } else { - var pos = c.transform.localPosition; + var pos = c.transform.position; var vm = Matrix4x4.TRS(new Vector3(-pos.x, -pos.y, -1000), Quaternion.identity, new Vector3(1, 1, -1f)); var pm = Matrix4x4.TRS(new Vector3(0, 0, -1), Quaternion.identity, new Vector3(1 / pos.x, 1 / pos.y, -2 / 10000f)); _cb.SetViewProjectionMatrices(vm, pm); diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs old mode 100644 new mode 100755 index 7c5d1b7..2210763 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs @@ -208,7 +208,7 @@ namespace Coffee.UIExtensions { var scale = c.transform.localScale.x; var size = (c.transform as RectTransform).sizeDelta; - var pos = c.transform.localPosition; + var pos = c.transform.position; mat.SetMatrix(s_GameVPId, Matrix4x4.TRS(new Vector3(0, 0, 0.5f), Quaternion.identity, new Vector3(2 / size.x, 2 / size.y, 0.0005f * scale))); mat.SetMatrix(s_GameTVPId, Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(1 / pos.x, 1 / pos.y, -2/2000f)) * Matrix4x4.Translate(-pos)); } diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json index bc2dbd4..451eaf9 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json @@ -2,7 +2,7 @@ "name": "com.coffee.softmask-for-ugui", "displayName": "Soft Mask For uGUI", "description": "SoftMask is a smooth masking component for uGUI elements in Unity.\nBy using SoftMask instead of default Mask, rounded edges of UI elements can be expressed beautifully.", - "version": "0.7.2", + "version": "0.8.0", "unity": "2017.1", "license": "MIT", "repository": { diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fff011..1003f91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [v0.8.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.8.0) (2019-05-01) + +[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.7.2...v0.8.0) + +Camera movement affects the mask rendering when on a World Space Canvas. +![](https://user-images.githubusercontent.com/12690315/57015752-68540b80-6c51-11e9-8511-2d4534dd9d58.gif) + +**Fixed bugs:** + +- In overlay mode, mask will be incorrect if the root canvas's parent position are not zero [\#47](https://github.com/mob-sakai/SoftMaskForUGUI/issues/47) + ## [v0.7.2](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.7.2) (2019-03-16) [Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.7.1...v0.7.2) diff --git a/README.md b/README.md index 6e6aa81..fbbaf8b 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,10 @@ By using SoftMask instead of default Mask, rounded edges of UI elements can be e ![](https://user-images.githubusercontent.com/12690315/50284151-7459e080-049b-11e9-9cd3-24fb476766dc.png) * Support TextMeshPro. ![](https://user-images.githubusercontent.com/12690315/50284145-71f78680-049b-11e9-8be1-ac0ccbdf0144.png) -* Make multiple holes on one background by 'Parts of parent' option +* Make multiple holes on one background by 'Parts of parent' option. ![](https://user-images.githubusercontent.com/12690315/54102470-f5c26e80-440b-11e9-89d1-899aa4dca00d.png) +* Camera movement affects the mask rendering when on a World Space Canvas. +![](https://user-images.githubusercontent.com/12690315/57015752-68540b80-6c51-11e9-8511-2d4534dd9d58.gif) #### Components @@ -86,7 +88,7 @@ Find the manifest.json file in the Packages folder of your project and edit it t ```js { "dependencies": { - "com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git#0.7.0", + "com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git#0.8.0", ... }, } diff --git a/package.json b/package.json index bc2dbd4..451eaf9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.coffee.softmask-for-ugui", "displayName": "Soft Mask For uGUI", "description": "SoftMask is a smooth masking component for uGUI elements in Unity.\nBy using SoftMask instead of default Mask, rounded edges of UI elements can be expressed beautifully.", - "version": "0.7.2", + "version": "0.8.0", "unity": "2017.1", "license": "MIT", "repository": {