2022년 6월 8일 수요일

Unity UpDown Plusing

 



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UpDownMove : MonoBehaviour
{

    Transform TargetObject;
    float plusSize = 0.015f;
    float tempo = 0.025f;

    private bool coroutineAllowed;
    // Start is called before the first frame update

    private void Start()
    {
        TargetObject = transform;
        coroutineAllowed = true;
    }
    // Update is called once per frame
    void Update()
    {
        if (coroutineAllowed)
        {
            StartCoroutine(StartPlusing());
        }
    }

    private IEnumerator StartPlusing()
    {
        coroutineAllowed = false;


        for (float i = 0f; i < 1f; i += 0.1f)
        {
            transform.localScale = new Vector3(
                (Mathf.Lerp(TargetObject.localScale.x, TargetObject.localScale.x , Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.y, TargetObject.localScale.y + plusSize, Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.z, TargetObject.localScale.z + plusSize * 0.1f, Mathf.SmoothStep(0f, 1f, i)))

                );
            yield return new WaitForSeconds(tempo);
        }


        for (float i = 0f; i < 1f; i += 0.1f)
        {
            transform.localScale = new Vector3(
                (Mathf.Lerp(TargetObject.localScale.x, TargetObject.localScale.x , Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.y, TargetObject.localScale.y - plusSize, Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.z, TargetObject.localScale.z - plusSize*0.1f, Mathf.SmoothStep(0f, 1f, i)))
                );
            yield return new WaitForSeconds(tempo);
        }

        coroutineAllowed = true;
    }
}






댓글 없음:

댓글 쓰기

git rejected error(feat. cherry-pick)

 문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...