From 2bcec9dffe6bfc89b28a94ca9cd4d21032082776 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Mon, 11 Mar 2019 20:30:43 +0900 Subject: [PATCH] fix #36; if canvas camera is not set in world space mode, masked contents are not displayed --- Scripts/SoftMask.cs | 5 +++-- Scripts/SoftMaskable.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Scripts/SoftMask.cs b/Scripts/SoftMask.cs index 3cfd2fd..f67c37c 100644 --- a/Scripts/SoftMask.cs +++ b/Scripts/SoftMask.cs @@ -464,9 +464,10 @@ namespace Coffee.UIExtensions // Set view and projection matrices. var c = graphic.canvas.rootCanvas; - if (c && c.renderMode != RenderMode.ScreenSpaceOverlay && c.worldCamera) + var cam = c.worldCamera ?? Camera.main; + if (c && c.renderMode != RenderMode.ScreenSpaceOverlay && cam) { - _cb.SetViewProjectionMatrices(c.worldCamera.worldToCameraMatrix, c.worldCamera.projectionMatrix); + _cb.SetViewProjectionMatrices(cam.worldToCameraMatrix, cam.projectionMatrix); } else { diff --git a/Scripts/SoftMaskable.cs b/Scripts/SoftMaskable.cs index 645b187..d709b1e 100644 --- a/Scripts/SoftMaskable.cs +++ b/Scripts/SoftMaskable.cs @@ -206,9 +206,9 @@ namespace Coffee.UIExtensions Material mat = sm._maskMaterial; var c = sm.graphic.canvas.rootCanvas; - if (c.renderMode != RenderMode.ScreenSpaceOverlay && c.worldCamera) + var wcam = c.worldCamera ?? Camera.main; + if (c.renderMode != RenderMode.ScreenSpaceOverlay && wcam) { - var wcam = c.worldCamera; var pv = GL.GetGPUProjectionMatrix (wcam.projectionMatrix, false) * wcam.worldToCameraMatrix; mat.SetMatrix(s_GameVPId, pv); mat.SetMatrix(s_GameTVPId, pv);