Skip to content

Instantly share code, notes, and snippets.

@gegagome
Created December 11, 2017 19:49
Show Gist options
  • Select an option

  • Save gegagome/1ea4ef8f8a4681b69b80503435c6965a to your computer and use it in GitHub Desktop.

Select an option

Save gegagome/1ea4ef8f8a4681b69b80503435c6965a to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;
using UnityEngine.EventSystems;
public class SettingsPanel : MonoBehaviour {
RectTransform _aRect;
bool _isHidden = true;
float _panelHeight;
Sequence _hidePanel;
void Awake ()
{
_aRect = GetComponent<RectTransform>();
_panelHeight = GetComponentInParent<Canvas>().rectTransform().sizeDelta.y;
}
void Start ()
{
_aRect.sizeDelta = new Vector2(450.0f, _panelHeight);
_aRect.anchoredPosition = new Vector2(_aRect.anchoredPosition.x, -_panelHeight);
_hidePanel = DOTween.Sequence().SetAutoKill(false).Pause();
_hidePanel.Append(_aRect.DOAnchorPos(new Vector2(_aRect.anchoredPosition.x, 0f), 1.0f).SetEase(Ease.InOutBack));
}
public void PanelExposer ()
{
if (_isHidden)
{
_hidePanel.PlayForward();
} else {
_hidePanel.PlayBackwards();
}
SoundManager.PlaySoundForSettingsWindow();
_isHidden = !_isHidden;
}
public bool IsPanelHidden () {
return _isHidden;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment