Compare commits

..

10 Commits

Author SHA1 Message Date
semantic-release-bot 33356da2c4 chore(release): 1.4.2 [skip ci]
## [1.4.2](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.4.1...1.4.2) (2023-10-25)

### Bug Fixes

* UnmaskRaycastFilter not working anymore ([14ab505](14ab505fbf)), closes [#29](https://github.com/mob-sakai/UnmaskForUGUI/issues/29)
2023-10-25 17:37:26 +00:00
mob-sakai dc15f45cbd test: update workflows 2023-10-26 02:36:38 +09:00
mob-sakai 14ab505fbf fix: UnmaskRaycastFilter not working anymore
close #29
2023-10-26 02:35:16 +09:00
semantic-release-bot a276ef6e7e chore(release): 1.4.1 [skip ci]
## [1.4.1](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.4.0...1.4.1) (2023-03-14)

### Bug Fixes

* Fixed error when executing menu item ([9f0afa1](9f0afa19a4)), closes [#27](https://github.com/mob-sakai/UnmaskForUGUI/issues/27)
2023-03-14 07:54:35 +00:00
mob-sakai 911200a1b1 chore: update workflow 2023-03-14 16:54:00 +09:00
Haruki Yano 9f0afa19a4 fix: Fixed error when executing menu item
Close #27
2023-03-14 16:49:30 +09:00
semantic-release-bot 0a70db88bf chore(release): 1.4.0 [skip ci]
# [1.4.0](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.3.0...1.4.0) (2022-02-17)

### Features

* add edge smoothing option ([c5317de](c5317deafe))
2022-02-17 19:15:35 +00:00
mob-sakai 0f1af578ca demo: update demo 2022-02-18 04:13:16 +09:00
mob-sakai c5317deafe feat: add edge smoothing option 2022-02-18 04:02:23 +09:00
mob-sakai 56dfb3c96e style: code format 2022-02-18 03:53:31 +09:00
9 changed files with 701 additions and 291 deletions

View File

@ -13,9 +13,9 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: cycjimmy/semantic-release-action@v2
- uses: cycjimmy/semantic-release-action@v3
with:
extra_plugins: |
@semantic-release/changelog

View File

@ -32,7 +32,7 @@ jobs:
steps:
# Checkout sandbox project
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: sandbox
submodules: true
@ -43,7 +43,7 @@ jobs:
working-directory: Packages/dev
run: git checkout ${{ github.sha }}
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: Library
key: Library-${{ matrix.unityVersion }}-${{ github.sha }}
@ -59,7 +59,7 @@ jobs:
# Run tests
- name: "Run tests"
uses: game-ci/unity-test-runner@main
uses: game-ci/unity-test-runner@v3
with:
unityVersion: ${{ matrix.unityVersion }}
customParameters: -nographics

View File

@ -1,3 +1,24 @@
## [1.4.2](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.4.1...1.4.2) (2023-10-25)
### Bug Fixes
* UnmaskRaycastFilter not working anymore ([14ab505](https://github.com/mob-sakai/UnmaskForUGUI/commit/14ab505fbfaf1103bbb1869d0e42817bf8830ced)), closes [#29](https://github.com/mob-sakai/UnmaskForUGUI/issues/29)
## [1.4.1](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.4.0...1.4.1) (2023-03-14)
### Bug Fixes
* Fixed error when executing menu item ([9f0afa1](https://github.com/mob-sakai/UnmaskForUGUI/commit/9f0afa19a46bc7b718a80142b02e33ade67fa3b4)), closes [#27](https://github.com/mob-sakai/UnmaskForUGUI/issues/27)
# [1.4.0](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.3.0...1.4.0) (2022-02-17)
### Features
* add edge smoothing option ([c5317de](https://github.com/mob-sakai/UnmaskForUGUI/commit/c5317deafeba575161db8b168dae845d68347236))
# [1.3.0](https://github.com/mob-sakai/UnmaskForUGUI/compare/1.2.0...1.3.0) (2021-06-29)

View File

@ -1,35 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
namespace Coffee.UIExtensions.Demos
{
public class Unmask_Demo : MonoBehaviour
{
[SerializeField] Button target;
[SerializeField] Unmask unmask;
[SerializeField] Graphic transition;
[SerializeField] Image transitionImage;
[SerializeField] Sprite unity_chan;
[SerializeField] Sprite unity_frame;
public class Unmask_Demo : MonoBehaviour
{
[SerializeField] Unmask unmask = null;
[SerializeField] Unmask[] smoothingUnmasks = new Unmask[0];
[SerializeField] Graphic transition = null;
[SerializeField] Image transitionImage = null;
[SerializeField] Sprite unity_chan = null;
[SerializeField] Sprite unity_frame = null;
public void AutoFitToButton(bool flag)
{
unmask.fitOnLateUpdate = flag;
}
public void AutoFitToButton(bool flag)
{
unmask.fitOnLateUpdate = flag;
}
public void SetTransitionColor(bool flag)
{
transition.color = flag ? Color.white : Color.black;
}
public void SetTransitionColor(bool flag)
{
transition.color = flag ? Color.white : Color.black;
}
public void SetTransitionImage(bool flag)
{
transitionImage.sprite = flag ? unity_chan : unity_frame;
transitionImage.SetNativeSize();
var size = transitionImage.rectTransform.rect.size;
transitionImage.rectTransform.sizeDelta = new Vector2(150, size.y / size.x * 150);
}
}
public void SetTransitionImage(bool flag)
{
transitionImage.sprite = flag ? unity_chan : unity_frame;
transitionImage.SetNativeSize();
var size = transitionImage.rectTransform.rect.size;
transitionImage.rectTransform.sizeDelta = new Vector2(150, size.y / size.x * 150);
}
public void EnableSmoothing(bool flag)
{
foreach (var unmask in smoothingUnmasks)
{
unmask.edgeSmoothing = flag ? 1 : 0;
}
}
}
}

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1}
m_IndirectSpecularColor: {r: 0.44657838, g: 0.49641234, b: 0.57481676, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -526,8 +526,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ab46b16b64e214e0d91583c53ac12da4, type: 3}
m_Name:
m_EditorClassIdentifier:
target: {fileID: 2026878701}
unmask: {fileID: 1934621013}
smoothingUnmasks:
- {fileID: 474546652}
- {fileID: 323196830}
- {fileID: 1934621013}
- {fileID: 427535254}
transition: {fileID: 1826727338}
transitionImage: {fileID: 653262226}
unity_chan: {fileID: 21300000, guid: 0cd154e72107340939b1731297ff8632, type: 3}
@ -611,6 +615,101 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 158225045}
m_CullTransparentMesh: 0
--- !u!1 &183422925
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 183422926}
- component: {fileID: 183422927}
m_Layer: 5
m_Name: Toggle - Edge Smoothing
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &183422926
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 183422925}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 797299950}
- {fileID: 758245432}
m_Father: {fileID: 1526965849}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 92.421875, y: -99}
m_SizeDelta: {x: 184.84375, y: 22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &183422927
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 183422925}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 797299951}
toggleTransition: 1
graphic: {fileID: 1335416432}
m_Group: {fileID: 0}
onValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 133894763}
m_MethodName: EnableSmoothing
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 1
m_TypeName: UnityEngine.UI.Toggle+ToggleEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
m_IsOn: 1
--- !u!1 &209121757
GameObject:
m_ObjectHideFlags: 0
@ -739,6 +838,7 @@ MonoBehaviour:
m_FitOnLateUpdate: 0
m_OnlyForChildren: 0
m_ShowUnmaskGraphic: 0
m_EdgeSmoothing: 1
--- !u!114 &323196831
MonoBehaviour:
m_ObjectHideFlags: 0
@ -1084,6 +1184,7 @@ MonoBehaviour:
m_FitOnLateUpdate: 0
m_OnlyForChildren: 0
m_ShowUnmaskGraphic: 0
m_EdgeSmoothing: 1
--- !u!114 &427535255
MonoBehaviour:
m_ObjectHideFlags: 0
@ -1165,8 +1266,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 99.331215, y: -33}
m_SizeDelta: {x: 198.66243, y: 22}
m_AnchoredPosition: {x: 97.378136, y: -33}
m_SizeDelta: {x: 194.75627, y: 22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &432299462
MonoBehaviour:
@ -1424,6 +1525,7 @@ MonoBehaviour:
m_FitOnLateUpdate: 0
m_OnlyForChildren: 0
m_ShowUnmaskGraphic: 1
m_EdgeSmoothing: 1
--- !u!114 &474546653
MonoBehaviour:
m_ObjectHideFlags: 0
@ -1797,6 +1899,7 @@ MonoBehaviour:
m_FitOnLateUpdate: 0
m_OnlyForChildren: 0
m_ShowUnmaskGraphic: 0
m_EdgeSmoothing: 0
--- !u!114 &653262226
MonoBehaviour:
m_ObjectHideFlags: 0
@ -1913,6 +2016,160 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 749509811}
m_CullTransparentMesh: 0
--- !u!1 &758245431
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 758245432}
- component: {fileID: 758245434}
- component: {fileID: 758245433}
m_Layer: 5
m_Name: Label
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &758245432
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 758245431}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 183422926}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 11.5, y: 0.0000076293945}
m_SizeDelta: {x: -23, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &758245433
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 758245431}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 3
m_AlignByGeometry: 0
m_RichText: 0
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Edge smoothing
--- !u!222 &758245434
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 758245431}
m_CullTransparentMesh: 0
--- !u!1 &797299949
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 797299950}
- component: {fileID: 797299952}
- component: {fileID: 797299951}
m_Layer: 5
m_Name: Background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &797299950
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 797299949}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1335416431}
m_Father: {fileID: 183422926}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 10, y: 0}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &797299951
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 797299949}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!222 &797299952
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 797299949}
m_CullTransparentMesh: 0
--- !u!1 &798697676
GameObject:
m_ObjectHideFlags: 0
@ -3049,8 +3306,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 90.46879, y: -11}
m_SizeDelta: {x: 180.93758, y: 22}
m_AnchoredPosition: {x: 92.421875, y: -11}
m_SizeDelta: {x: 184.84375, y: 22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1158411646
MonoBehaviour:
@ -3129,8 +3386,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 90.46879, y: -77}
m_SizeDelta: {x: 180.93758, y: 22}
m_AnchoredPosition: {x: 92.421875, y: -77}
m_SizeDelta: {x: 184.84375, y: 22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1253616863
MonoBehaviour:
@ -3318,6 +3575,80 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1275261700}
m_CullTransparentMesh: 0
--- !u!1 &1335416430
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1335416431}
- component: {fileID: 1335416433}
- component: {fileID: 1335416432}
m_Layer: 5
m_Name: Checkmark
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1335416431
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335416430}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 797299950}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1335416432
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335416430}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!222 &1335416433
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335416430}
m_CullTransparentMesh: 0
--- !u!1 &1341563783
GameObject:
m_ObjectHideFlags: 0
@ -3555,8 +3886,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 99.331215, y: -11}
m_SizeDelta: {x: 198.66243, y: 22}
m_AnchoredPosition: {x: 97.378136, y: -11}
m_SizeDelta: {x: 194.75627, y: 22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1415840031
MonoBehaviour:
@ -3706,13 +4037,14 @@ RectTransform:
- {fileID: 1742342034}
- {fileID: 1787531622}
- {fileID: 1253616862}
- {fileID: 183422926}
m_Father: {fileID: 798697677}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 289.13123, y: -50}
m_SizeDelta: {x: 180.93758, y: 100}
m_AnchoredPosition: {x: 287.17816, y: -55}
m_SizeDelta: {x: 184.84375, y: 110}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1526965850
MonoBehaviour:
@ -4079,8 +4411,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 90.46879, y: -33}
m_SizeDelta: {x: 180.93758, y: 22}
m_AnchoredPosition: {x: 92.421875, y: -33}
m_SizeDelta: {x: 184.84375, y: 22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1742342035
MonoBehaviour:
@ -4249,8 +4581,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 90.46879, y: -55}
m_SizeDelta: {x: 180.93758, y: 22}
m_AnchoredPosition: {x: 92.421875, y: -55}
m_SizeDelta: {x: 184.84375, y: 22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1787531623
MonoBehaviour:
@ -4414,8 +4746,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 99.331215, y: -50}
m_SizeDelta: {x: 198.66243, y: 100}
m_AnchoredPosition: {x: 97.378136, y: -50}
m_SizeDelta: {x: 194.75627, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1815324079
MonoBehaviour:
@ -4743,6 +5075,7 @@ MonoBehaviour:
m_FitOnLateUpdate: 1
m_OnlyForChildren: 0
m_ShowUnmaskGraphic: 0
m_EdgeSmoothing: 1
--- !u!114 &1934621014
MonoBehaviour:
m_ObjectHideFlags: 0
@ -4796,7 +5129,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -150.6, y: -142.8312}
m_AnchoredPosition: {x: -150.60013, y: -125.75426}
m_SizeDelta: {x: 83.7, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1971058987
@ -5167,8 +5500,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 99.331215, y: -55}
m_SizeDelta: {x: 198.66243, y: 22}
m_AnchoredPosition: {x: 97.378136, y: -55}
m_SizeDelta: {x: 194.75627, y: 22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2122063194
MonoBehaviour:

View File

@ -9,7 +9,12 @@ namespace Coffee.UIExtensions.Editors
[MenuItem("GameObject/UI/Unmask/Tutorial Button")]
private static void CreateTutorialButton2(MenuCommand menuCommand)
{
EditorApplication.ExecuteMenuItem("GameObject/UI/Button");
#if UNITY_2021_2_OR_NEWER
const string menuItemName = "GameObject/UI/Legacy/Button";
#else
const string menuItemName = "GameObject/UI/Button";
#endif
EditorApplication.ExecuteMenuItem(menuItemName);
var button = Selection.activeGameObject.GetComponent<Button>();
button.name = "Tutorial Button";
@ -18,9 +23,6 @@ namespace Coffee.UIExtensions.Editors
unmask.fitTarget = button.transform as RectTransform;
unmask.fitOnLateUpdate = true;
var screen = unmaskedPanel.transform.Find("Screen").GetComponent<Image>();
screen.gameObject.AddComponent<UnmaskRaycastFilter>().targetUnmask = unmask;
Selection.activeGameObject = button.gameObject;
}
@ -32,6 +34,12 @@ namespace Coffee.UIExtensions.Editors
Selection.activeGameObject = unmaskedPanel;
}
[MenuItem("GameObject/UI/Unmask/Unmasked Panel")]
private static GameObject CreateUnmaskedPanel(MenuCommand menuCommand)
{
return CreateUnmaskedPanel(AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/UISprite.psd"), Image.Type.Sliced);
}
private static GameObject CreateUnmaskedPanel(Sprite unmaskSprite, Image.Type spriteType)
{
EditorApplication.ExecuteMenuItem("GameObject/UI/Panel");
@ -46,6 +54,8 @@ namespace Coffee.UIExtensions.Editors
unmask.transform.SetParent(mask.transform);
unmask.GetComponent<Image>().sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/UISprite.psd");
mask.gameObject.AddComponent<UnmaskRaycastFilter>().targetUnmask = unmask;
var image = unmask.GetComponent<Image>();
image.sprite = unmaskSprite;
image.type = spriteType;
@ -60,4 +70,4 @@ namespace Coffee.UIExtensions.Editors
return mask.gameObject;
}
}
}
}

View File

@ -1,221 +1,265 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;
namespace Coffee.UIExtensions
{
/// <summary>
/// Reverse masking for parent Mask component.
/// </summary>
[ExecuteInEditMode]
[AddComponentMenu("UI/Unmask/Unmask", 1)]
public class Unmask : MonoBehaviour, IMaterialModifier
{
//################################
// Constant or Static Members.
//################################
static readonly Vector2 s_Center = new Vector2(0.5f, 0.5f);
/// <summary>
/// Reverse masking for parent Mask component.
/// </summary>
[ExecuteInEditMode]
[AddComponentMenu("UI/Unmask/Unmask", 1)]
public class Unmask : MonoBehaviour, IMaterialModifier
{
//################################
// Constant or Static Members.
//################################
private static readonly Vector2 s_Center = new Vector2(0.5f, 0.5f);
//################################
// Serialize Members.
//################################
[Tooltip("Fit graphic's transform to target transform.")]
[SerializeField] RectTransform m_FitTarget;
[Tooltip("Fit graphic's transform to target transform on LateUpdate every frame.")]
[SerializeField] bool m_FitOnLateUpdate;
[Tooltip ("Unmask affects only for children.")]
[SerializeField] bool m_OnlyForChildren = false;
[Tooltip("Show the graphic that is associated with the unmask render area.")]
[SerializeField] bool m_ShowUnmaskGraphic = false;
//################################
// Serialize Members.
//################################
[Tooltip("Fit graphic's transform to target transform.")]
[SerializeField] private RectTransform m_FitTarget;
[Tooltip("Fit graphic's transform to target transform on LateUpdate every frame.")]
[SerializeField] private bool m_FitOnLateUpdate;
[Tooltip("Unmask affects only for children.")]
[SerializeField] private bool m_OnlyForChildren = false;
[Tooltip("Show the graphic that is associated with the unmask render area.")]
[SerializeField] private bool m_ShowUnmaskGraphic = false;
[Tooltip("Edge smoothing.")]
[Range(0f, 1f)]
[SerializeField] private float m_EdgeSmoothing = 0f;
//################################
// Public Members.
//################################
/// <summary>
/// The graphic associated with the unmask.
/// </summary>
public Graphic graphic{ get { return _graphic ?? (_graphic = GetComponent<Graphic>()); } }
/// <summary>
/// Fit graphic's transform to target transform.
/// </summary>
public RectTransform fitTarget
{
get { return m_FitTarget; }
set
{
m_FitTarget = value;
FitTo(m_FitTarget);
}
}
//################################
// Public Members.
//################################
/// <summary>
/// The graphic associated with the unmask.
/// </summary>
public MaskableGraphic graphic { get { return _graphic ?? (_graphic = GetComponent<MaskableGraphic>()); } }
/// <summary>
/// Fit graphic's transform to target transform on LateUpdate every frame.
/// </summary>
public bool fitOnLateUpdate{ get { return m_FitOnLateUpdate; } set { m_FitOnLateUpdate = value; } }
/// <summary>
/// Fit graphic's transform to target transform.
/// </summary>
public RectTransform fitTarget
{
get { return m_FitTarget; }
set
{
m_FitTarget = value;
FitTo(m_FitTarget);
}
}
/// <summary>
/// Show the graphic that is associated with the unmask render area.
/// </summary>
public bool showUnmaskGraphic
{
get { return m_ShowUnmaskGraphic; }
set
{
m_ShowUnmaskGraphic = value;
SetDirty();
}
}
/// <summary>
/// Fit graphic's transform to target transform on LateUpdate every frame.
/// </summary>
public bool fitOnLateUpdate { get { return m_FitOnLateUpdate; } set { m_FitOnLateUpdate = value; } }
/// <summary>
/// Unmask affects only for children.
/// </summary>
public bool onlyForChildren
{
get { return m_OnlyForChildren; }
set
{
m_OnlyForChildren = value;
SetDirty ();
}
}
/// <summary>
/// Show the graphic that is associated with the unmask render area.
/// </summary>
public bool showUnmaskGraphic
{
get { return m_ShowUnmaskGraphic; }
set
{
m_ShowUnmaskGraphic = value;
SetDirty();
}
}
/// <summary>
/// Perform material modification in this function.
/// </summary>
/// <returns>Modified material.</returns>
/// <param name="baseMaterial">Configured Material.</param>
public Material GetModifiedMaterial(Material baseMaterial)
{
if (!isActiveAndEnabled)
{
return baseMaterial;
}
/// <summary>
/// Unmask affects only for children.
/// </summary>
public bool onlyForChildren
{
get { return m_OnlyForChildren; }
set
{
m_OnlyForChildren = value;
SetDirty();
}
}
Transform stopAfter = MaskUtilities.FindRootSortOverrideCanvas(transform);
var stencilDepth = MaskUtilities.GetStencilDepth(transform, stopAfter);
var desiredStencilBit = 1 << stencilDepth;
/// <summary>
/// Edge smooting.
/// </summary>
public float edgeSmoothing
{
get { return m_EdgeSmoothing; }
set { m_EdgeSmoothing = value; }
}
StencilMaterial.Remove(_unmaskMaterial);
_unmaskMaterial = StencilMaterial.Add(baseMaterial, desiredStencilBit - 1, StencilOp.Invert, CompareFunction.Equal, m_ShowUnmaskGraphic ? ColorWriteMask.All : (ColorWriteMask)0, desiredStencilBit - 1, (1 << 8) - 1);
/// <summary>
/// Perform material modification in this function.
/// </summary>
/// <returns>Modified material.</returns>
/// <param name="baseMaterial">Configured Material.</param>
public Material GetModifiedMaterial(Material baseMaterial)
{
if (!isActiveAndEnabled)
{
return baseMaterial;
}
// Unmask affects only for children.
var canvasRenderer = graphic.canvasRenderer;
if (m_OnlyForChildren)
{
StencilMaterial.Remove (_revertUnmaskMaterial);
_revertUnmaskMaterial = StencilMaterial.Add(baseMaterial, (1 << 7), StencilOp.Invert, CompareFunction.Equal, (ColorWriteMask)0, (1 << 7), (1 << 8) - 1);
canvasRenderer.hasPopInstruction = true;
canvasRenderer.popMaterialCount = 1;
canvasRenderer.SetPopMaterial (_revertUnmaskMaterial, 0);
}
else
{
canvasRenderer.hasPopInstruction = false;
canvasRenderer.popMaterialCount = 0;
}
Transform stopAfter = MaskUtilities.FindRootSortOverrideCanvas(transform);
var stencilDepth = MaskUtilities.GetStencilDepth(transform, stopAfter);
var desiredStencilBit = 1 << stencilDepth;
return _unmaskMaterial;
}
StencilMaterial.Remove(_unmaskMaterial);
_unmaskMaterial = StencilMaterial.Add(baseMaterial, desiredStencilBit - 1, StencilOp.Invert, CompareFunction.Equal, m_ShowUnmaskGraphic ? ColorWriteMask.All : (ColorWriteMask)0, desiredStencilBit - 1, (1 << 8) - 1);
/// <summary>
/// Fit to target transform.
/// </summary>
/// <param name="target">Target transform.</param>
public void FitTo(RectTransform target)
{
var rt = transform as RectTransform;
// Unmask affects only for children.
var canvasRenderer = graphic.canvasRenderer;
if (m_OnlyForChildren)
{
StencilMaterial.Remove(_revertUnmaskMaterial);
_revertUnmaskMaterial = StencilMaterial.Add(baseMaterial, (1 << 7), StencilOp.Invert, CompareFunction.Equal, (ColorWriteMask)0, (1 << 7), (1 << 8) - 1);
canvasRenderer.hasPopInstruction = true;
canvasRenderer.popMaterialCount = 1;
canvasRenderer.SetPopMaterial(_revertUnmaskMaterial, 0);
}
else
{
canvasRenderer.hasPopInstruction = false;
canvasRenderer.popMaterialCount = 0;
}
rt.pivot = target.pivot;
rt.position = target.position;
rt.rotation = target.rotation;
return _unmaskMaterial;
}
var s1 = target.lossyScale;
var s2 = rt.parent.lossyScale;
rt.localScale = new Vector3(s1.x / s2.x, s1.y / s2.y, s1.z / s2.z);
rt.sizeDelta = target.rect.size;
rt.anchorMax = rt.anchorMin = s_Center;
}
/// <summary>
/// Fit to target transform.
/// </summary>
/// <param name="target">Target transform.</param>
public void FitTo(RectTransform target)
{
var rt = transform as RectTransform;
rt.pivot = target.pivot;
rt.position = target.position;
rt.rotation = target.rotation;
var s1 = target.lossyScale;
var s2 = rt.parent.lossyScale;
rt.localScale = new Vector3(s1.x / s2.x, s1.y / s2.y, s1.z / s2.z);
rt.sizeDelta = target.rect.size;
rt.anchorMax = rt.anchorMin = s_Center;
}
//################################
// Private Members.
//################################
Material _unmaskMaterial;
Material _revertUnmaskMaterial;
Graphic _graphic;
//################################
// Private Members.
//################################
private Material _unmaskMaterial;
private Material _revertUnmaskMaterial;
private MaskableGraphic _graphic;
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
void OnEnable()
{
if (m_FitTarget)
{
FitTo(m_FitTarget);
}
SetDirty();
}
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
private void OnEnable()
{
if (m_FitTarget)
{
FitTo(m_FitTarget);
}
SetDirty();
}
/// <summary>
/// This function is called when the behaviour becomes disabled () or inactive.
/// </summary>
void OnDisable()
{
StencilMaterial.Remove (_unmaskMaterial);
StencilMaterial.Remove (_revertUnmaskMaterial);
_unmaskMaterial = null;
_revertUnmaskMaterial = null;
/// <summary>
/// This function is called when the behaviour becomes disabled () or inactive.
/// </summary>
private void OnDisable()
{
StencilMaterial.Remove(_unmaskMaterial);
StencilMaterial.Remove(_revertUnmaskMaterial);
_unmaskMaterial = null;
_revertUnmaskMaterial = null;
if (graphic)
{
var canvasRenderer = graphic.canvasRenderer;
canvasRenderer.hasPopInstruction = false;
canvasRenderer.popMaterialCount = 0;
graphic.SetMaterialDirty();
}
SetDirty ();
}
if (graphic)
{
var canvasRenderer = graphic.canvasRenderer;
canvasRenderer.hasPopInstruction = false;
canvasRenderer.popMaterialCount = 0;
graphic.SetMaterialDirty();
}
SetDirty();
}
/// <summary>
/// LateUpdate is called every frame, if the Behaviour is enabled.
/// </summary>
void LateUpdate()
{
/// <summary>
/// LateUpdate is called every frame, if the Behaviour is enabled.
/// </summary>
private void LateUpdate()
{
#if UNITY_EDITOR
if (m_FitTarget && (m_FitOnLateUpdate || !Application.isPlaying))
if (m_FitTarget && (m_FitOnLateUpdate || !Application.isPlaying))
#else
if (m_FitTarget && m_FitOnLateUpdate)
#endif
{
FitTo(m_FitTarget);
}
}
{
FitTo(m_FitTarget);
}
Smoothing(graphic, m_EdgeSmoothing);
}
#if UNITY_EDITOR
/// <summary>
/// This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only).
/// </summary>
void OnValidate()
{
SetDirty();
}
/// <summary>
/// This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only).
/// </summary>
private void OnValidate()
{
SetDirty();
}
#endif
/// <summary>
/// Mark the graphic as dirty.
/// </summary>
void SetDirty()
{
if (graphic)
{
graphic.SetMaterialDirty();
}
}
}
/// <summary>
/// Mark the graphic as dirty.
/// </summary>
void SetDirty()
{
if (graphic)
{
graphic.SetMaterialDirty();
}
}
private static void Smoothing(MaskableGraphic graphic, float smooth)
{
if (!graphic) return;
Profiler.BeginSample("[Unmask] Smoothing");
var canvasRenderer = graphic.canvasRenderer;
var currentColor = canvasRenderer.GetColor();
var targetAlpha = 1f;
if (graphic.maskable && 0 < smooth)
{
var currentAlpha = graphic.color.a * canvasRenderer.GetInheritedAlpha();
if (0 < currentAlpha)
{
targetAlpha = Mathf.Lerp(0.01f, 0.002f, smooth) / currentAlpha;
}
}
if (!Mathf.Approximately(currentColor.a, targetAlpha))
{
currentColor.a = Mathf.Clamp01(targetAlpha);
canvasRenderer.SetColor(currentColor);
}
Profiler.EndSample();
}
}
}

View File

@ -1,46 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine;
namespace Coffee.UIExtensions
{
/// <summary>
/// Unmask Raycast Filter.
/// The ray passes through the unmasked rectangle.
/// </summary>
[AddComponentMenu("UI/Unmask/UnmaskRaycastFilter", 2)]
public class UnmaskRaycastFilter : MonoBehaviour, ICanvasRaycastFilter
{
//################################
// Serialize Members.
//################################
[Tooltip("Target unmask component. The ray passes through the unmasked rectangle.")]
[SerializeField] Unmask m_TargetUnmask;
/// <summary>
/// Unmask Raycast Filter.
/// The ray passes through the unmasked rectangle.
/// </summary>
[AddComponentMenu("UI/Unmask/UnmaskRaycastFilter", 2)]
public class UnmaskRaycastFilter : MonoBehaviour, ICanvasRaycastFilter
{
//################################
// Serialize Members.
//################################
[Tooltip("Target unmask component. The ray passes through the unmasked rectangle.")]
[SerializeField] private Unmask m_TargetUnmask;
//################################
// Public Members.
//################################
/// <summary>
/// Target unmask component. Ray through the unmasked rectangle.
/// </summary>
public Unmask targetUnmask{ get { return m_TargetUnmask; } set { m_TargetUnmask = value; } }
//################################
// Public Members.
//################################
/// <summary>
/// Target unmask component. Ray through the unmasked rectangle.
/// </summary>
public Unmask targetUnmask { get { return m_TargetUnmask; } set { m_TargetUnmask = value; } }
/// <summary>
/// Given a point and a camera is the raycast valid.
/// </summary>
/// <returns>Valid.</returns>
/// <param name="sp">Screen position.</param>
/// <param name="eventCamera">Raycast camera.</param>
public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
{
// Skip if deactived.
if (!isActiveAndEnabled || !m_TargetUnmask || !m_TargetUnmask.isActiveAndEnabled)
{
return true;
}
/// <summary>
/// Given a point and a camera is the raycast valid.
/// </summary>
/// <returns>Valid.</returns>
/// <param name="sp">Screen position.</param>
/// <param name="eventCamera">Raycast camera.</param>
public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
{
// Skip if deactived.
if (!isActiveAndEnabled || !m_TargetUnmask || !m_TargetUnmask.isActiveAndEnabled)
{
return true;
}
// check inside
if (eventCamera)
@ -51,18 +47,18 @@ namespace Coffee.UIExtensions
{
return !RectTransformUtility.RectangleContainsScreenPoint((m_TargetUnmask.transform as RectTransform), sp);
}
}
}
//################################
// Private Members.
//################################
//################################
// Private Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
void OnEnable()
{
}
}
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
void OnEnable()
{
}
}
}

View File

@ -2,7 +2,7 @@
"name": "com.coffee.unmask",
"displayName": "UI Unmask",
"description": "Reverse mask for uGUI element in Unity.",
"version": "1.3.0",
"version": "1.4.2",
"unity": "2017.1",
"license": "MIT",
"repository": {