From 08f4c8540e027fff6504e1489345f6eb03ebc60a Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Thu, 7 Feb 2019 12:20:43 +0900 Subject: [PATCH 1/4] fix #14; UnmaskRaycastFilter is not reliable --- .../Scripts/UnmaskRaycastFilter.cs | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/UnmaskRaycastFilter.cs b/Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/UnmaskRaycastFilter.cs index 5618ab7..3163acf 100644 --- a/Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/UnmaskRaycastFilter.cs +++ b/Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/UnmaskRaycastFilter.cs @@ -13,12 +13,6 @@ namespace Coffee.UIExtensions [AddComponentMenu("UI/Unmask/UnmaskRaycastFilter", 2)] public class UnmaskRaycastFilter : MonoBehaviour, ICanvasRaycastFilter { - //################################ - // Constant or Static Members. - //################################ - Vector3[] s_WorldCorners = new Vector3[4]; - - //################################ // Serialize Members. //################################ @@ -48,25 +42,8 @@ public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera) return true; } - // Get world corners for the target. - (m_TargetUnmask.transform as RectTransform).GetWorldCorners(s_WorldCorners); - - // Convert to screen positions. - var cam = eventCamera ?? Camera.main; - var p = cam.WorldToScreenPoint(sp); - var a = cam.WorldToScreenPoint(s_WorldCorners[0]); - var b = cam.WorldToScreenPoint(s_WorldCorners[1]); - var c = cam.WorldToScreenPoint(s_WorldCorners[2]); - var d = cam.WorldToScreenPoint(s_WorldCorners[3]); - - // check left/right side - var ab = Cross(p - a, b - a) < 0.0; - var bc = Cross(p - b, c - b) < 0.0; - var cd = Cross(p - c, d - c) < 0.0; - var da = Cross(p - d, a - d) < 0.0; - // check inside - return ab ^ bc ||bc ^ cd ||cd ^ da; + return !RectTransformUtility.RectangleContainsScreenPoint ((m_TargetUnmask.transform as RectTransform), sp); } @@ -80,13 +57,5 @@ public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera) void OnEnable() { } - - /// - /// Cross for Vector2. - /// - float Cross(Vector2 a, Vector2 b) - { - return a.x * b.y - a.y * b.x; - } } } \ No newline at end of file From 1e2e910909f03f64b96d7c84fb80d37c354f6982 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Thu, 7 Feb 2019 20:08:44 +0900 Subject: [PATCH 2/4] Delete documents --- CHANGELOG.md | 1 - LICENSE.md | 1 - README.md | 1 - package.json | 1 - 4 files changed, 4 deletions(-) delete mode 120000 CHANGELOG.md delete mode 120000 LICENSE.md delete mode 120000 README.md delete mode 120000 package.json diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 120000 index 4821703..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -Assets/Coffee/UIExtensions/UnmaskForUGUI/CHANGELOG.md \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md deleted file mode 120000 index 5a39af7..0000000 --- a/LICENSE.md +++ /dev/null @@ -1 +0,0 @@ -Assets/Coffee/UIExtensions/UnmaskForUGUI/LICENSE.md \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 120000 index 3ef13cb..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -Assets/Coffee/UIExtensions/UnmaskForUGUI/README.md \ No newline at end of file diff --git a/package.json b/package.json deleted file mode 120000 index 8a50b80..0000000 --- a/package.json +++ /dev/null @@ -1 +0,0 @@ -Assets/Coffee/UIExtensions/UnmaskForUGUI/package.json \ No newline at end of file From a2bf28e2324d13f9d93ef170be3988fddc556773 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Thu, 7 Feb 2019 20:10:22 +0900 Subject: [PATCH 3/4] Add documents for UnityList --- CHANGELOG.md | 54 ++++++++++++++++++++++ LICENSE.md | 7 +++ README.md | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 18 ++++++++ 4 files changed, 203 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 package.json diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d1703d3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,54 @@ +# Changelog + +## [1.1.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/1.1.0) (2019-01-25) + +[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/v1.0.0...1.1.0) + +**Install UnmaskForUGUI with Unity Package Manager!** + +Find the manifest.json file in the Packages folder of your project and edit it to look like this: +```js +{ + "dependencies": { + "com.coffee.unmask": "https://github.com/mob-sakai/UnmaskForUGUI.git#1.1.0", + ... + }, +} +``` +To update the package, change `#1.1.0` to the target version. + +**Implemented enhancements:** + +- Unmask only for children option [\#11](https://github.com/mob-sakai/UnmaskForUGUI/issues/11) + +## [v1.0.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/v1.0.0) (2018-10-18) + +[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/v0.2.0...v1.0.0) + +**Implemented enhancements:** + +- Add `Fit On LateUpdate` option [\#10](https://github.com/mob-sakai/UnmaskForUGUI/issues/10) + +## [v0.2.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/v0.2.0) (2018-10-16) + +[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/v0.1.0...v0.2.0) + +**Implemented enhancements:** + +- Update demo & readme [\#9](https://github.com/mob-sakai/UnmaskForUGUI/issues/9) + +## [v0.1.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/v0.1.0) (2018-10-14) + +[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/987e437b26b83a78d6f54d6cc6778c3181e8e5dc...v0.1.0) + +**Implemented enhancements:** + +- Add demo [\#5](https://github.com/mob-sakai/UnmaskForUGUI/issues/5) +- Support nesting [\#4](https://github.com/mob-sakai/UnmaskForUGUI/issues/4) +- Following another object [\#3](https://github.com/mob-sakai/UnmaskForUGUI/issues/3) +- Ray through the unmasked rectangle [\#2](https://github.com/mob-sakai/UnmaskForUGUI/issues/2) +- Reverse mask [\#1](https://github.com/mob-sakai/UnmaskForUGUI/issues/1) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..6c53273 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2018 mob-sakai + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6c6865e --- /dev/null +++ b/README.md @@ -0,0 +1,124 @@ +UnmaskForUGUI +=== + +Reverse mask for uGUI element in Unity. + +![](https://user-images.githubusercontent.com/12690315/51747120-e1d8dc80-20eb-11e9-952e-a67915af1294.png) + +[![](https://img.shields.io/github/release/mob-sakai/UnmaskForUGUI.svg?label=latest%20version)](https://github.com/mob-sakai/UnmaskForUGUI/releases) +[![](https://img.shields.io/github/release-date/mob-sakai/UnmaskForUGUI.svg)](https://github.com/mob-sakai/UnmaskForUGUI/releases) +![](https://img.shields.io/badge/unity-5.5%2B-green.svg) +[![](https://img.shields.io/github/license/mob-sakai/UnmaskForUGUI.svg)](https://github.com/mob-sakai/UnmaskForUGUI/blob/upm/LICENSE.txt) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange.svg)](http://makeapullrequest.com) + +<< [Description](#Description) | [WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/UnmaskForUGUI/releases) | [Install](#install) | [Usage](#usage) >> + +### What's new? [See changelog ![](https://img.shields.io/github/release-date/mob-sakai/UnmaskForUGUI.svg?label=last%20updated)](https://github.com/mob-sakai/UnmaskForUGUI/blob/upm/CHANGELOG.md) +### Do you want to receive notifications for new releases? [Watch this repo ![](https://img.shields.io/github/watchers/mob-sakai/UnmaskForUGUI.svg?style=social&label=Watch)](https://github.com/mob-sakai/UnmaskForUGUI/subscription) + + + +



+## Description + +Unmask provides the following features: +1. Reverse mask +2. Ray through the unmasked rectangle +3. Following another object +4. Support nesting + +| Component | Features | Screenshot | +|-|-|-| +|**Unmask**|Reverse masking for parent Mask component.

**Fit Target / Fit On Late Update:** Fit graphic's transform to target transform on LateUpdate.
**Only For Children:** Unmask affects only for children.
**Show Unmask Graphic:** Show the graphic that is associated with the unmask render area.|| +|**UnmaskRaycastFilter**|The ray Passes through the unmasked rectangle.
You can click on the unmasked button on the back side.|| + + + +



+## Demo + +[WebGL Demo](http://mob-sakai.github.io/UnmaskForUGUI) + +![demo](https://user-images.githubusercontent.com/12690315/46986251-4e296480-d129-11e8-8e3a-2bb0e5fbe533.gif) + + + +



+## Install + +#### Using UnityPackageManager (for Unity 2018.3+) + +Find the manifest.json file in the Packages folder of your project and edit it to look like this: +```js +{ + "dependencies": { + "com.coffee.unmask": "https://github.com/mob-sakai/UnmaskForUGUI.git#1.1.1", + ... + }, +} +``` +To update the package, change `#{version}` to the target version. +Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension). + +#### Using .unitypackage file (for Unity 5.5+) + +Download `*.unitypackage` from [Releases](https://github.com/mob-sakai/UnmaskForUGUI/releases) and import the package into your Unity project. +Select `Assets > Import Package > Custom Package` from the menu. +![](https://user-images.githubusercontent.com/12690315/46570979-edbb5a00-c9a7-11e8-845d-c5ee279effec.png) + + + +



+## Usage + +1. Add Unmask component to the UI element (Image, RawImage, Text, etc...) under Mask, from `Add Component` in inspector or `Component > UI > Unmask > Unmask` menu. +2. If you want to unmask the area of the button, follow the steps below: + * Set the button to `Fit Target` in Unmask component. + * If the button moves with animation etc., enable `Fit On LateUpdate` in Unmask component. + * Add a UnmaskRaycastFilter component to UI element blocking ray. + * Set the Unmask to `Unmask` in UnmaskRaycastFilter component. + * Disable `RaycastTarget` of the UI elements, as necessary. +![](https://user-images.githubusercontent.com/12690315/46986095-8a0ffa00-d128-11e8-83ac-9151e2d8635d.gif) +3. Enjoy! + + +##### Requirement + +* Unity 5.5+ *(included Unity 2018.x)* +* No other SDK are required + + + +



+## Example of using + +| Case | Description |Screenshot | +|-|-|-| +|Unmasked text|Black screen is cut out with unmasked text.|![](https://user-images.githubusercontent.com/12690315/46914021-c6c9dd00-cfd2-11e8-9698-6332bac8fef5.png)| +|Hole|Black screen is cut out with unmasked Image.|![](https://user-images.githubusercontent.com/12690315/46985696-9b580700-d126-11e8-9b4a-3d66180c9562.png)| +|Tutorial button|In tutorial, only specific button can be pressed.|![](https://user-images.githubusercontent.com/12690315/46983810-30560280-d11d-11e8-86d5-b25117740df4.png)| +|Transition|Transition effect with silhouette.|![](https://user-images.githubusercontent.com/12690315/46983811-30560280-d11d-11e8-8d81-b38679cf9970.gif)| + + + +



+## License + +* MIT +* © UTJ/UCL + + + +## Author + +[mob-sakai](https://github.com/mob-sakai) + + + +## See Also + +* GitHub page : https://github.com/mob-sakai/UnmaskForUGUI +* Releases : https://github.com/mob-sakai/UnmaskForUGUI/releases +* Issue tracker : https://github.com/mob-sakai/UnmaskForUGUI/issues +* Current project : https://github.com/mob-sakai/UnmaskForUGUI/projects/1 +* Change log : https://github.com/mob-sakai/UnmaskForUGUI/blob/upm/CHANGELOG.md diff --git a/package.json b/package.json new file mode 100644 index 0000000..5707607 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "com.coffee.unmask", + "displayName": "Unmask for uGUI", + "description": "Reverse mask for uGUI element in Unity.", + "version": "1.1.0", + "unity": "5.5", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/mob-sakai/UnmaskForUGUI.git" + }, + "src": "Assets/Coffee/UIExtensions/UnmaskForUGUI", + "author": "mob-sakai (https://github.com/mob-sakai)", + "editorOnly": false, + "upmSupport": true, + "dependencies": { + } +} From 0b3cbb365e592e213863dcce5cfcea4205808e26 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Thu, 7 Feb 2019 20:19:52 +0900 Subject: [PATCH 4/4] update documents for v1.1.1 --- .../Coffee/UIExtensions/UnmaskForUGUI/CHANGELOG.md | 12 ++++++++++-- Assets/Coffee/UIExtensions/UnmaskForUGUI/README.md | 4 ++-- .../Coffee/UIExtensions/UnmaskForUGUI/package.json | 2 +- CHANGELOG.md | 12 ++++++++++-- package.json | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Assets/Coffee/UIExtensions/UnmaskForUGUI/CHANGELOG.md b/Assets/Coffee/UIExtensions/UnmaskForUGUI/CHANGELOG.md index d1703d3..fddf2d3 100644 --- a/Assets/Coffee/UIExtensions/UnmaskForUGUI/CHANGELOG.md +++ b/Assets/Coffee/UIExtensions/UnmaskForUGUI/CHANGELOG.md @@ -1,8 +1,16 @@ # Changelog -## [1.1.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/1.1.0) (2019-01-25) +## [v1.1.1](https://github.com/mob-sakai/UnmaskForUGUI/tree/v1.1.1) (2019-02-07) -[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/v1.0.0...1.1.0) +[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/v1.1.0...v1.1.1) + +**Fixed bugs:** + +- UnmaskRaycastFilter is not reliable [\#14](https://github.com/mob-sakai/UnmaskForUGUI/issues/14) + +## [v1.1.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/v1.1.0) (2019-01-25) + +[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.1.0...v1.1.0) **Install UnmaskForUGUI with Unity Package Manager!** diff --git a/Assets/Coffee/UIExtensions/UnmaskForUGUI/README.md b/Assets/Coffee/UIExtensions/UnmaskForUGUI/README.md index 4203ee5..6c6865e 100644 --- a/Assets/Coffee/UIExtensions/UnmaskForUGUI/README.md +++ b/Assets/Coffee/UIExtensions/UnmaskForUGUI/README.md @@ -52,12 +52,12 @@ Find the manifest.json file in the Packages folder of your project and edit it t ```js { "dependencies": { - "com.coffee.unmask": "https://github.com/mob-sakai/UnmaskForUGUI.git#1.1.0", + "com.coffee.unmask": "https://github.com/mob-sakai/UnmaskForUGUI.git#1.1.1", ... }, } ``` -To update the package, change `#1.1.0` to the target version. +To update the package, change `#{version}` to the target version. Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension). #### Using .unitypackage file (for Unity 5.5+) diff --git a/Assets/Coffee/UIExtensions/UnmaskForUGUI/package.json b/Assets/Coffee/UIExtensions/UnmaskForUGUI/package.json index 5707607..ce50ece 100644 --- a/Assets/Coffee/UIExtensions/UnmaskForUGUI/package.json +++ b/Assets/Coffee/UIExtensions/UnmaskForUGUI/package.json @@ -2,7 +2,7 @@ "name": "com.coffee.unmask", "displayName": "Unmask for uGUI", "description": "Reverse mask for uGUI element in Unity.", - "version": "1.1.0", + "version": "1.1.1", "unity": "5.5", "license": "MIT", "repository": { diff --git a/CHANGELOG.md b/CHANGELOG.md index d1703d3..fddf2d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,16 @@ # Changelog -## [1.1.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/1.1.0) (2019-01-25) +## [v1.1.1](https://github.com/mob-sakai/UnmaskForUGUI/tree/v1.1.1) (2019-02-07) -[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/v1.0.0...1.1.0) +[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/v1.1.0...v1.1.1) + +**Fixed bugs:** + +- UnmaskRaycastFilter is not reliable [\#14](https://github.com/mob-sakai/UnmaskForUGUI/issues/14) + +## [v1.1.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/v1.1.0) (2019-01-25) + +[Full Changelog](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.1.0...v1.1.0) **Install UnmaskForUGUI with Unity Package Manager!** diff --git a/package.json b/package.json index 5707607..ce50ece 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.coffee.unmask", "displayName": "Unmask for uGUI", "description": "Reverse mask for uGUI element in Unity.", - "version": "1.1.0", + "version": "1.1.1", "unity": "5.5", "license": "MIT", "repository": {