style: code format

main
mob-sakai 2022-02-18 03:48:23 +09:00
parent 1b5588f418
commit 56dfb3c96e
3 changed files with 254 additions and 259 deletions

View File

@ -1,18 +1,15 @@
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;
[SerializeField] Unmask unmask = null;
[SerializeField] Graphic transition = null;
[SerializeField] Image transitionImage = null;
[SerializeField] Sprite unity_chan = null;
[SerializeField] Sprite unity_frame = null;
public void AutoFitToButton(bool flag)
{

View File

@ -1,6 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;
@ -17,20 +16,23 @@ namespace Coffee.UIExtensions
//################################
// Constant or Static Members.
//################################
static readonly Vector2 s_Center = new Vector2(0.5f, 0.5f);
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;
[SerializeField] private 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;
[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] bool m_ShowUnmaskGraphic = false;
[SerializeField] private bool m_ShowUnmaskGraphic = false;
//################################
@ -39,7 +41,7 @@ namespace Coffee.UIExtensions
/// <summary>
/// The graphic associated with the unmask.
/// </summary>
public Graphic graphic{ get { return _graphic ?? (_graphic = GetComponent<Graphic>()); } }
public MaskableGraphic graphic { get { return _graphic ?? (_graphic = GetComponent<MaskableGraphic>()); } }
/// <summary>
/// Fit graphic's transform to target transform.
@ -57,7 +59,7 @@ namespace Coffee.UIExtensions
/// <summary>
/// Fit graphic's transform to target transform on LateUpdate every frame.
/// </summary>
public bool fitOnLateUpdate{ get { return m_FitOnLateUpdate; } set { m_FitOnLateUpdate = value; } }
public bool fitOnLateUpdate { get { return m_FitOnLateUpdate; } set { m_FitOnLateUpdate = value; } }
/// <summary>
/// Show the graphic that is associated with the unmask render area.
@ -81,7 +83,7 @@ namespace Coffee.UIExtensions
set
{
m_OnlyForChildren = value;
SetDirty ();
SetDirty();
}
}
@ -108,11 +110,11 @@ namespace Coffee.UIExtensions
var canvasRenderer = graphic.canvasRenderer;
if (m_OnlyForChildren)
{
StencilMaterial.Remove (_revertUnmaskMaterial);
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);
canvasRenderer.SetPopMaterial(_revertUnmaskMaterial, 0);
}
else
{
@ -146,14 +148,14 @@ namespace Coffee.UIExtensions
//################################
// Private Members.
//################################
Material _unmaskMaterial;
Material _revertUnmaskMaterial;
Graphic _graphic;
private Material _unmaskMaterial;
private Material _revertUnmaskMaterial;
private MaskableGraphic _graphic;
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
void OnEnable()
private void OnEnable()
{
if (m_FitTarget)
{
@ -165,10 +167,10 @@ namespace Coffee.UIExtensions
/// <summary>
/// This function is called when the behaviour becomes disabled () or inactive.
/// </summary>
void OnDisable()
private void OnDisable()
{
StencilMaterial.Remove (_unmaskMaterial);
StencilMaterial.Remove (_revertUnmaskMaterial);
StencilMaterial.Remove(_unmaskMaterial);
StencilMaterial.Remove(_revertUnmaskMaterial);
_unmaskMaterial = null;
_revertUnmaskMaterial = null;
@ -179,13 +181,13 @@ namespace Coffee.UIExtensions
canvasRenderer.popMaterialCount = 0;
graphic.SetMaterialDirty();
}
SetDirty ();
SetDirty();
}
/// <summary>
/// LateUpdate is called every frame, if the Behaviour is enabled.
/// </summary>
void LateUpdate()
private void LateUpdate()
{
#if UNITY_EDITOR
if (m_FitTarget && (m_FitOnLateUpdate || !Application.isPlaying))
@ -201,7 +203,7 @@ namespace Coffee.UIExtensions
/// <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()
private void OnValidate()
{
SetDirty();
}

View File

@ -1,8 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine;
namespace Coffee.UIExtensions
{
@ -17,7 +13,7 @@ namespace Coffee.UIExtensions
// Serialize Members.
//################################
[Tooltip("Target unmask component. The ray passes through the unmasked rectangle.")]
[SerializeField] Unmask m_TargetUnmask;
[SerializeField] private Unmask m_TargetUnmask;
//################################
@ -26,7 +22,7 @@ namespace Coffee.UIExtensions
/// <summary>
/// Target unmask component. Ray through the unmasked rectangle.
/// </summary>
public Unmask targetUnmask{ get { return m_TargetUnmask; } set { m_TargetUnmask = value; } }
public Unmask targetUnmask { get { return m_TargetUnmask; } set { m_TargetUnmask = value; } }
/// <summary>
/// Given a point and a camera is the raycast valid.