Skip to content

Commit

Permalink
release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Oct 18, 2018
2 parents f3f27bd + 308dd3b commit b70c066
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions Assets/Coffee/UIExtensions/UnmaskForUGUI/Demo/Unmask_Demo.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
36 changes: 27 additions & 9 deletions Assets/Coffee/UIExtensions/UnmaskForUGUI/Scripts/Unmask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -38,9 +40,22 @@ public class Unmask : MonoBehaviour, IMaterialModifier
public Graphic graphic{ get { return _graphic ?? (_graphic = GetComponent<Graphic>()); } }

/// <summary>
/// Fit graphic's transform to target transform on LateUpdate.
/// Fit graphic's transform to target transform.
/// </summary>
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);
}
}

/// <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>
/// Show the graphic that is associated with the unmask render area.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -107,9 +121,9 @@ public void FitTo(RectTransform target)
/// </summary>
void OnEnable()
{
if (m_AutoFitTarget)
if (m_FitTarget)
{
FitTo(m_AutoFitTarget);
FitTo(m_FitTarget);
}
SetDirty();
}
Expand All @@ -129,9 +143,13 @@ void OnDisable()
/// </summary>
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);
}
}

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit b70c066

Please sign in to comment.