Responsiveness
This commit is contained in:
@@ -19,6 +19,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
private CanvasGroup _canvasGroup;
|
||||
private Vector2 _shownAnchoredPos;
|
||||
private Sequence _activeSequence;
|
||||
private bool _initialized;
|
||||
public event Action OnArtbookClicked;
|
||||
|
||||
public RectTransform SpawnRoot => spawnRoot;
|
||||
@@ -26,10 +27,17 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
EnsureInitialized();
|
||||
}
|
||||
|
||||
private void EnsureInitialized()
|
||||
{
|
||||
if (_initialized) return;
|
||||
_canvasGroup = GetComponent<CanvasGroup>();
|
||||
if (animatedRoot == null) animatedRoot = (RectTransform)transform;
|
||||
_shownAnchoredPos = animatedRoot.anchoredPosition;
|
||||
artbookButton.onClick.AddListener(HandleArtbookClicked);
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
private void HandleArtbookClicked()
|
||||
@@ -39,6 +47,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
|
||||
public Sequence Show()
|
||||
{
|
||||
EnsureInitialized();
|
||||
KillActive();
|
||||
gameObject.SetActive(true);
|
||||
_canvasGroup.interactable = true;
|
||||
@@ -52,6 +61,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
|
||||
public Sequence Hide()
|
||||
{
|
||||
EnsureInitialized();
|
||||
KillActive();
|
||||
_canvasGroup.interactable = false;
|
||||
_canvasGroup.blocksRaycasts = false;
|
||||
@@ -66,6 +76,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
|
||||
public void HideInstant()
|
||||
{
|
||||
EnsureInitialized();
|
||||
KillActive();
|
||||
animatedRoot.anchoredPosition = _shownAnchoredPos + hiddenOffset;
|
||||
_canvasGroup.alpha = 0f;
|
||||
|
||||
Reference in New Issue
Block a user