From 226d2eda42d3a3df1415dab21ead55fd98cea310 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Mon, 15 Oct 2018 15:37:20 +0900 Subject: [PATCH 1/3] close #8; Add `Fit On LateUpdate` option --- .../UnmaskForUGUI/Demo/Unmask_Demo.cs | 2 +- .../UnmaskForUGUI/Scripts/Unmask.cs | 36 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.cs b/Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.cs index f6abbc6..8a5ef22 100644 --- a/Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.cs +++ b/Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.cs @@ -16,7 +16,7 @@ public class Unmask_Demo : MonoBehaviour public void AutoFitToButton(bool flag) { - unmask.autoFitTarget = flag ? (target.transform as RectTransform) : null; + unmask.fitOnLateUpdate = flag; } public void SetTransitionColor(bool flag) diff --git a/Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/Unmask.cs b/Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/Unmask.cs index 6d4f53a..2809e1c 100644 --- a/Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/Unmask.cs +++ b/Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/Unmask.cs @@ -23,8 +23,10 @@ public class Unmask : MonoBehaviour, IMaterialModifier //################################ // Serialize Members. //################################ - [Tooltip("Fit graphic's transform to target transform on LateUpdate.")] - [SerializeField] RectTransform m_AutoFitTarget; + [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("Show the graphic that is associated with the unmask render area.")] [SerializeField] bool m_ShowUnmaskGraphic = false; @@ -38,9 +40,22 @@ public class Unmask : MonoBehaviour, IMaterialModifier public Graphic graphic{ get { return _graphic ?? (_graphic = GetComponent()); } } /// - /// Fit graphic's transform to target transform on LateUpdate. + /// Fit graphic's transform to target transform. /// - public RectTransform autoFitTarget{ get { return m_AutoFitTarget; } set { m_AutoFitTarget = value; } } + public RectTransform fitTarget + { + get { return m_FitTarget; } + set + { + m_FitTarget = value; + FitTo(m_FitTarget); + } + } + + /// + /// Fit graphic's transform to target transform on LateUpdate every frame. + /// + public bool fitOnLateUpdate{ get { return m_FitOnLateUpdate; } set { m_FitOnLateUpdate = value; } } /// /// Show the graphic that is associated with the unmask render area. @@ -72,7 +87,6 @@ public Material GetModifiedMaterial(Material baseMaterial) StencilMaterial.Remove(_unmaskMaterial); _unmaskMaterial = StencilMaterial.Add(baseMaterial, (1 << stencilDepth) - 1, StencilOp.Zero, CompareFunction.Always, m_ShowUnmaskGraphic ? ColorWriteMask.All : (ColorWriteMask)0, 0, (1 << stencilDepth) - 1); - //StencilMaterial.Remove (baseMaterial); return _unmaskMaterial; } @@ -107,9 +121,9 @@ public void FitTo(RectTransform target) /// void OnEnable() { - if (m_AutoFitTarget) + if (m_FitTarget) { - FitTo(m_AutoFitTarget); + FitTo(m_FitTarget); } SetDirty(); } @@ -129,9 +143,13 @@ void OnDisable() /// void LateUpdate() { - if (m_AutoFitTarget) + #if UNITY_EDITOR + if (m_FitTarget && (m_FitOnLateUpdate || !Application.isPlaying)) + #else + if (m_FitTarget && m_FitOnLateUpdate) + #endif { - FitTo(m_AutoFitTarget); + FitTo(m_FitTarget); } } From 78aa6fdb59714a5bc4ccf2a66e4104dec1bf74b4 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Tue, 16 Oct 2018 22:22:31 +0900 Subject: [PATCH 2/3] Update demo --- .../UnmaskForUGUI/Demo/Unmask_Demo.unity | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.unity b/Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.unity index 41bbd53..e9595b6 100644 --- a/Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.unity +++ b/Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.unity @@ -675,7 +675,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f752d3a51152f4e44a3ebe45ae24abcc, type: 3} m_Name: m_EditorClassIdentifier: - m_AutoFitTarget: {fileID: 0} + m_FitTarget: {fileID: 0} + m_FitOnLateUpdate: 0 m_ShowUnmaskGraphic: 0 --- !u!114 &323196831 MonoBehaviour: @@ -995,7 +996,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f752d3a51152f4e44a3ebe45ae24abcc, type: 3} m_Name: m_EditorClassIdentifier: - m_AutoFitTarget: {fileID: 0} + m_FitTarget: {fileID: 0} + m_FitOnLateUpdate: 0 m_ShowUnmaskGraphic: 0 --- !u!114 &427535255 MonoBehaviour: @@ -1316,7 +1318,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f752d3a51152f4e44a3ebe45ae24abcc, type: 3} m_Name: m_EditorClassIdentifier: - m_AutoFitTarget: {fileID: 0} + m_FitTarget: {fileID: 0} + m_FitOnLateUpdate: 0 m_ShowUnmaskGraphic: 1 --- !u!114 &474546653 MonoBehaviour: @@ -1541,7 +1544,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f752d3a51152f4e44a3ebe45ae24abcc, type: 3} m_Name: m_EditorClassIdentifier: - m_AutoFitTarget: {fileID: 0} + m_FitTarget: {fileID: 0} + m_FitOnLateUpdate: 0 m_ShowUnmaskGraphic: 0 --- !u!114 &653262226 MonoBehaviour: @@ -4051,7 +4055,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f752d3a51152f4e44a3ebe45ae24abcc, type: 3} m_Name: m_EditorClassIdentifier: - m_AutoFitTarget: {fileID: 2026878700} + m_FitTarget: {fileID: 2026878700} + m_FitOnLateUpdate: 1 m_ShowUnmaskGraphic: 0 --- !u!114 &1934621014 MonoBehaviour: From 308dd3b198f3ce233a1c134aced46d57eda4b0ba Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 19 Oct 2018 07:26:45 +0900 Subject: [PATCH 3/3] update change log --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6928f08..5eff3e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [v1.0.0](https://github.com/mob-sakai/UnmaskForUGUI/tree/v1.0.0) (2018-10-19) + +[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) diff --git a/package.json b/package.json index d862b67..094ecdd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "UnmaskForUGUI", - "version": "0.2.0", + "version": "1.0.0", "repository": { "type": "git", "url": "git+https://github.com/mob-sakai/UnmaskForUGUI.git"