public override void StartClosePopup() { SetAlphaValue(1); Vector3 targetPos = Vector3.zero; switch (_outDirection) { case Direction.Left: targetPos = originPosition - new Vector3(_movingAmount, 0, 0); break; case Direction.Top: targetPos = originPosition + new Vector3(0, _movingAmount, 0); break; case Direction.Right: targetPos = originPosition + new Vector3(_movingAmount, 0, 0); break; case Direction.Bottom: targetPos = originPosition - new Vector3(0, _movingAmount, 0); break; } JTween.MoveTo(this.gameObject, targetPos, _transitionTime, 0, _openTransitionStyle); JTween.ValueTo(this.gameObject, 1, 0, _transitionTime, 0, SetAlphaValue, OnCompleteTransition, _openTransitionStyle); }
public void Activate(bool flag, bool isForced = false) { //if cur state is same with next state, didnt do anything. //if isForced is true, didnt end this function. if (IsActivated == flag && !isForced) { return; } IsActivated = flag; _image.sprite = ResourcesManager.Instance.GetSprite(flag ? _spriteOn : _spriteOff); //if is forced is true, set size directly. if (isForced) { _rectTransform.sizeDelta = flag ? _sizeOn : _sizeOff; return; } Vector2 sizeDelta = this.GetComponent <RectTransform> ().sizeDelta; if (flag) { JTween.ValueTo(this.gameObject, sizeDelta.x, _sizeOn.x, GetTransitionTime(), 0, UpdatedWidth, null, _buttonStyle); JTween.ValueTo(this.gameObject, sizeDelta.y, _sizeOn.y, GetTransitionTime(), 0, UpdatedHeight, null, _buttonStyle); } else { JTween.ValueTo(this.gameObject, sizeDelta.x, _sizeOff.x, GetTransitionTime(), 0, UpdatedWidth, null, _buttonStyle); JTween.ValueTo(this.gameObject, sizeDelta.y, _sizeOff.y, GetTransitionTime(), 0, UpdatedHeight, null, _buttonStyle); } }
public override void StartOpenPopup() { //Init originPosition of panel. if (originPosition == Vector3.back) { originPosition = this.transform.localPosition; } //Init SetAlphaValue(0); //Start move and change alpha value. switch (_inDirection) { case Direction.Left: this.transform.localPosition = originPosition + new Vector3(_movingAmount, 0, 0); break; case Direction.Top: this.transform.localPosition = originPosition - new Vector3(0, _movingAmount, 0); break; case Direction.Right: this.transform.localPosition = originPosition - new Vector3(_movingAmount, 0, 0); break; case Direction.Bottom: this.transform.localPosition = originPosition + new Vector3(0, _movingAmount, 0); break; } JTween.MoveTo(this.gameObject, originPosition, _transitionTime, 0, _openTransitionStyle); JTween.ValueTo(this.gameObject, 0, 1, _transitionTime, 0, SetAlphaValue, null, _openTransitionStyle); }
public void Activate(bool flag) { interactable = flag; Vector2 sizeDelta = this.GetComponent <RectTransform> ().sizeDelta; if (flag) { _image.sprite = SpriteResources.Instance.GetSprite(_spriteOn); JTween.ValueTo(this.gameObject, JTween.Hash("from", sizeDelta.x, "to", _sizeOn.x, "time", GetTransitionTime(), "easeType", _buttonStyle, "onupdate", "UpdatedWidth")); JTween.ValueTo(this.gameObject, JTween.Hash("from", sizeDelta.y, "to", _sizeOn.y, "time", GetTransitionTime(), "easeType", _buttonStyle, "onupdate", "UpdatedHeight")); } else { _image.sprite = SpriteResources.Instance.GetSprite(_spriteOff); JTween.ValueTo(this.gameObject, JTween.Hash("from", sizeDelta.x, "to", _sizeOff.x, "time", GetTransitionTime(), "easeType", _buttonStyle, "onupdate", "UpdatedWidth")); JTween.ValueTo(this.gameObject, JTween.Hash("from", sizeDelta.y, "to", _sizeOff.y, "time", GetTransitionTime(), "easeType", _buttonStyle, "onupdate", "UpdatedHeight")); } }