무료에셋 중에
Platinio Tween라는 앱이 있는데 상당히 사용하기 쉽고 좋다
간단하게 2가지 사용할만한게 있는데
Platinio.Popup은 Ui에 바로 붙여서 효과를 적용할수있다
간단하게 커스텀한 코드
using UnityEngine;
using Platinio.TweenEngine;
using Platinio.UI;
namespace Platinio
{
public class Popup : MonoBehaviour
{
[SerializeField] private Vector2 startPosition = Vector2.zero;
[SerializeField] private Vector2 desirePosition = Vector2.zero;
[SerializeField] private RectTransform canvas = null;
[SerializeField] private float time = 0.5f;
[SerializeField] private Ease enterEase = Ease.EaseInOutExpo;
[SerializeField] private Ease exitEase = Ease.EaseInOutExpo;
private bool isVisible = false;
private bool isBusy = false;
private RectTransform thisRect = null;
private void Start()
{
thisRect = GetComponent<RectTransform>();
thisRect.anchoredPosition = thisRect.FromAbsolutePositionToAnchoredPosition(startPosition , canvas);
}
public void Show()
{
thisRect.MoveUI( desirePosition, canvas, time).SetEase(enterEase).SetOnComplete(delegate
{
isBusy = false;
isVisible = true;
});
}
///좌우로 움직이게 만들기위해 커스텀한 코드
public void MoveSide(Vector2 targetPosition)
{
thisRect.MoveUI(targetPosition, canvas, time).SetEase(enterEase).SetOnComplete(delegate
{
isBusy = false;
isVisible = true;
});
}
///좌우로 움직이게 만들기위해 커스텀한 코드
public void Hide()
{
thisRect.MoveUI( startPosition, canvas, time).SetEase(exitEase).SetOnComplete(delegate
{
isBusy = false;
isVisible = false;
});
}
public void Toggle()
{
if (isBusy)
return;
isBusy = true;
if (isVisible)
Hide();
else
Show();
}
}
}
PopUp이 달린 객체들을 왼쪽 오른쪽으로 움직여주는 함수
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using Platinio.UI;
using Platinio;
public class SceneChange : MonoBehaviour
{
public Popup[] Popups;
public Vector2 CenterPos;
public Vector2 LeftPos;
public Vector2 RightPos;
public int currentIdx;
public int max;
// Start is called before the first frame update
void Start()
{
max = Popups.Length;
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown("1"))
{
Next();
}
if (Input.GetKeyDown("2"))
{
Prev();
}
}
public void Next()
{
if (currentIdx+1 > max)
return;
Popups[currentIdx].MoveSide(LeftPos);
Popups[++currentIdx].MoveSide(CenterPos);
}
public void Prev()
{
if (currentIdx - 1 < 0)
return;
Popups[currentIdx].MoveSide(RightPos);
Popups[--currentIdx].MoveSide(CenterPos);
}
}
댓글 없음:
댓글 쓰기