애니메이션(Animation) 탭에서 애니메이션 이벤트를 임포트된 애니메이션 클립에 연결할 수 있습니다.
이벤트를 사용하면 애니메이션에 맞춰 특정 액션이 언제 발생할지 결정하는 추가 정보를 임포트된 클립에 추가할 수 있습니다. 예를 들어 애니메이션화된 캐릭터의 경우 걷기 또는 달리기 주기에 이벤트를 추가하여 발자국 소리가 언제 재생될지 설정할 수 있습니다.
임포트된 애니메이션에 이벤트를 추가하려면 이벤트 섹션을 확장하여 임포트된 애니메이션 클립의 이벤트 타임라인을 표시합니다.
재생 헤드를 타임라인의 다른 위치로 이동하려면, 미리보기 창에 있는 타임라인을 사용합니다.
재생 헤드를 이벤트를 추가할 위치로 이동한 후 이벤트 추가(Add Event) 를 클릭합니다. 타임라인에 작은 흰색 마커로 표시된 새 이벤트가 나타납니다. 함수(Function) 프로퍼티에 이벤트가 발생하면 호출할 함수의 이름을 입력합니다.
해당 애니메이터에서 이 애니메이션을 사용하는 모든 게임 오브젝트에 해당하는 이벤트 이름과 이름이 같은 함수를 포함하는 스크립트가 있는지 확인합니다.
아래의 예제는 플레이어 게임 오브젝트의 스크립트에 존재하는 Swipe
함수를 호출하는 이벤트를 설정하는 방법을 보여줍니다. 이렇게 하면 AudioSource와 같이 사용되어 애니메이션과 동기화된 베는 소리를 재생할 수 있습니다.
이벤트에 의해 호출되는 함수로 보낼 파라미터를 지정할 수도 있습니다. 파라미터 타입에는 플로트(Float), 정수(Int), 문자열(String), 오브젝트(Object) 가 있습니다.
이들 영역 중 하나에 값을 입력하고, 함수에 해당 파라미터를 사용하도록 구현하면 이벤트에 특정된 값을 스크립트 안에 함수로 전달할 수 있습니다.
예를 들어 서로 다른 동작에 대해 사운드 효과의 음량을 지정하기 위해 float 값을 전달할 수 있습니다. 걷는 구간에서는 조용한 발자국 소리 이벤트를, 달리는 구간에서는 큰 발자국 소리 이벤트를 설정할 수 있습니다. 또한 효과 프리팹의 레퍼런스 값을 넘겨 애니메이션의 특정 지점에서 다양한 효과를 스크립트에서 인스턴스화할 수 있습니다.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.