From 33e5195ef2763d03ef344797ed0bc4ea59e490fb Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Thu, 20 Dec 2018 20:17:27 +0900 Subject: [PATCH] close #20; Doesn't work with overlay canvas on 2018.3 --- Scripts/SoftMask.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Scripts/SoftMask.cs b/Scripts/SoftMask.cs index cf97a14..1ca4840 100644 --- a/Scripts/SoftMask.cs +++ b/Scripts/SoftMask.cs @@ -429,14 +429,17 @@ namespace Coffee.UIExtensions _cb.ClearRenderTarget(false, true, s_ClearColors[_stencilDepth]); // Set view and projection matrices. - var c = graphic.canvas; + var c = graphic.canvas.rootCanvas; if (c && c.renderMode != RenderMode.ScreenSpaceOverlay && c.worldCamera) { _cb.SetViewProjectionMatrices(c.worldCamera.worldToCameraMatrix, c.worldCamera.projectionMatrix); } else { - _cb.SetViewMatrix(Matrix4x4.TRS(new Vector3(-1, -1, 0), Quaternion.identity, new Vector3(2f / Screen.width, 2f / Screen.height, 1f))); + var pos = c.transform.localPosition; + var vm = Matrix4x4.TRS (-pos, 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 / 1000f)); + _cb.SetViewProjectionMatrices (vm, pm); } // Draw soft masks.