Created
December 11, 2017 19:49
-
-
Save gegagome/1ea4ef8f8a4681b69b80503435c6965a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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