// ICanvasRaycastFilter public bool IsRaycastLocationValid(Vector2 sp, Camera cam) { Vector2 localPos; if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(maskTransform, sp, cam, out localPos)) { return(false); } if (!Mathr.Inside(localPos, LocalMaskRect(Vector4.zero))) { return(false); } if (!_parameters.texture) { return(true); } if (_raycastThreshold <= 0.0f) { return(true); } float mask; if (!_parameters.SampleMask(localPos, out mask)) { Debug.LogError("raycastThreshold greater than 0 can't be used on SoftMask whose texture cannot be read.", this); return(true); } return(mask >= _raycastThreshold); }
// ICanvasRaycastFilter public bool IsRaycastLocationValid(Vector2 sp, Camera cam) { Vector2 localPos; if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(maskTransform, sp, cam, out localPos)) { return(false); } if (!Mathr.Inside(localPos, LocalMaskRect(Vector4.zero))) { return(false); } if (!_parameters.texture) { return(true); } if (!isUsingRaycastFiltering) { return(true); } float mask; if (!_parameters.SampleMask(localPos, out mask)) { Debug.LogErrorFormat(this, "Raycast Threshold greater than 0 can't be used on Soft Mask with texture '{0}' because " + "it's not readable. You can make the texture readable in the Texture Import Settings.", _parameters.activeTexture.name); return(true); } return(mask >= _raycastThreshold); }