ui基类添加显影
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Deconstruction.Runtime;
|
||||||
#if ODIN_INSPECTOR
|
#if ODIN_INSPECTOR
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
#endif
|
#endif
|
||||||
@@ -36,11 +37,9 @@ namespace XericUI.Core.Base
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_canvas == null)
|
if (!_canvas) _canvas = GetComponentInParent<Canvas>();
|
||||||
_canvas = GetComponentInParent<Canvas>();
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (_canvas == null)
|
if (!_canvas) Debug.LogError($"{name} 无法找到布局组件,接下来的流程可能会引发错误", this);
|
||||||
Debug.LogError($"{name} 无法找到布局组件,接下来的流程可能会引发错误", this);
|
|
||||||
#endif
|
#endif
|
||||||
return _canvas;
|
return _canvas;
|
||||||
}
|
}
|
||||||
@@ -53,11 +52,9 @@ namespace XericUI.Core.Base
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_canvasScaler == null)
|
if (!_canvasScaler) _canvasScaler = GetComponentInParent<CanvasScaler>();
|
||||||
_canvasScaler = GetComponentInParent<CanvasScaler>();
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (_canvas == null)
|
if (_canvas == null) Debug.LogError($"{name} 无法找到布局缩放组件,接下来的流程可能会引发错误", this);
|
||||||
Debug.LogError($"{name} 无法找到布局缩放组件,接下来的流程可能会引发错误", this);
|
|
||||||
#endif
|
#endif
|
||||||
return _canvasScaler;
|
return _canvasScaler;
|
||||||
}
|
}
|
||||||
@@ -70,11 +67,9 @@ namespace XericUI.Core.Base
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_graphicRaycaster == null)
|
if (!_graphicRaycaster) _graphicRaycaster = GetComponentInParent<GraphicRaycaster>();
|
||||||
_graphicRaycaster = GetComponentInParent<GraphicRaycaster>();
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (_canvas == null)
|
if (_canvas == null) Debug.LogError($"{name} 无法找到布局射线检测,接下来的流程可能会引发错误", this);
|
||||||
Debug.LogError($"{name} 无法找到布局射线检测,接下来的流程可能会引发错误", this);
|
|
||||||
#endif
|
#endif
|
||||||
return _graphicRaycaster;
|
return _graphicRaycaster;
|
||||||
}
|
}
|
||||||
@@ -87,8 +82,7 @@ namespace XericUI.Core.Base
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_rect == null)
|
if (!_rect) _rect = GetComponent<RectTransform>();
|
||||||
_rect = GetComponent<RectTransform>();
|
|
||||||
return _rect;
|
return _rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,6 +129,7 @@ namespace XericUI.Core.Base
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetHierarchyDirty()
|
public void SetHierarchyDirty()
|
||||||
{
|
{
|
||||||
|
rectTransform.SetLayoutDirty();
|
||||||
_canvas = null;
|
_canvas = null;
|
||||||
_canvasScaler = null;
|
_canvasScaler = null;
|
||||||
_graphicRaycaster = null;
|
_graphicRaycaster = null;
|
||||||
@@ -147,6 +142,29 @@ namespace XericUI.Core.Base
|
|||||||
public void ResetHierarchyDirty()
|
public void ResetHierarchyDirty()
|
||||||
{
|
{
|
||||||
_hierarchyDirty = false;
|
_hierarchyDirty = false;
|
||||||
|
rectTransform.SetLayoutDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 显影
|
||||||
|
|
||||||
|
public virtual void Show()
|
||||||
|
{
|
||||||
|
gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Show(bool isShow)
|
||||||
|
{
|
||||||
|
if (isShow)
|
||||||
|
Show();
|
||||||
|
else
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Hide()
|
||||||
|
{
|
||||||
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user