TIL (Today I Learned)/Unity

[Unity, MacOS] LeanTween

loki d 2021. 9. 17. 23:55
728x90

LeanTween

  • ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋„๊ตฌ์ด๋‹ค.
  • Unity์—์„œ ๋ถ€๋“œ๋Ÿฌ์šด ํšจ๊ณผ๋ฅผ ์œ„ํ•ด์„œ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋„ฃ์–ด ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ํ•˜์ง€๋งŒ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋„ฃ์„ ๊ฒฝ์šฐ Idleํ•œ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ฆ๊ฐ€ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋น„ํšจ์œจ์ ์ด๋‹ค.
  • LeanTween์„ import ํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœ

LeanTween import

์Šคํฌ๋ฆฐ์ƒท 2021-09-17 ์˜คํ›„ 11 38 21

Script CS

using System;
using System.Collections;
using System.Collections.Generic;
using DilmerGames.Core.Singletons;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;

public class AlertMessageController : MonoBehaviour
{   
    [SerializeField]
    public GameObject AlertPanel;
    [SerializeField]
    public Text AlertText;

    [SerializeField]
    public GameObject StartPoint;

    [SerializeField]
    public GameObject EndPoint;

    public void popUpMessage(string msg)
    {
        AlertText.text = msg;
        LeanTween.move(AlertPanel, StartPoint.transform.position , 0.2f).setOnComplete(Destroy);
    }
    void Destroy()
    {

        LeanTween.move(AlertPanel, EndPoint.transform.position, 1f).setDelay(1f);
    }
}

ํ•ด๋‹น object์˜ Inspector

์Šคํฌ๋ฆฐ์ƒท 2021-09-17 ์˜คํ›„ 11 39 32

start point

์Šคํฌ๋ฆฐ์ƒท 2021-09-17 ์˜คํ›„ 11 40 22

end point

์Šคํฌ๋ฆฐ์ƒท 2021-09-17 ์˜คํ›„ 11 40 37

๊ฒฐ๊ณผํ™”๋ฉด

RPReplay_Final1631890051.mov
7.4 MB