Coding

BlueprintCallable, BlueprintImplementableEvent, BlueprintNativeEvent

UFUNCTION에 블루프린트와 관련한 세가지 옵션 - BlueprintCallable, BlueprintImplementableEvent, BlueprintNativeEvent -을 줄 수 있다. BlueprintCallable은 처음 보면 아 이걸 넣으면 블루프린트에 노드로 쓸 수 있는거구나 싶은데, BlueprintImplementableEvent, BlueprintNativeEvent은 단어만 보고는 바로 그 뜻을 알기가 쉽지 않다. 하지만 그 구분은 생각보다 명확한 차이가 있다.

언리얼 문서에서의 표현을 좀더 풀어서보면 다음과 같다.

  1. BlueprintCallable일종의 블랙박스를 만드는 것이다. 즉, BlueprintCallable이라는 말마따나 블루프린트 수준에서는 부를 수만 있고 작동 방식을 수정할 수 없다. 이는 협업 상황에서 함수의 작동방식을 블루프린트에서는 바꿀 수 없도록 강제한다. 예를 들어, 수학 관련 함수가 있다.
  2. BlueprintImplementableEventBlueprintCallable과 완전히 반대 지점에 있다. 즉, BlueprintImplementableEvent가 붙은 함수는 C++ 수준에서 구현할 수 없다. 즉, 함수 이름이 헤더에 선언돼 있을 뿐이고 구체적인 구현은 전부 블루프린트에서 이뤄져야 한다. 이는 대충 이런 함수가 있어야할 것 같은데, 각 사용자마다 다르게 구현해야 하는 상황일 때 쓰인다.
  3. BlueprintNativeEvent는 대충 BlueprintCallableBlueprintImplementableEvent를 섞은 것이다. C++로 일부 작동방식을 구현할 수 있고 이 부분은 블루프린트에는 블랙박스로 표현된다. 하지만 추가적인 작동방식을 블루프린트 수준에서 덧붙일 수 있다. 이는 마치 BlueprintCallable를 상속한 BlueprintImplementableEvent 느낌이다. 이 링크의 질문에 답변 코드를 보면 더 잘 이해할 수 있을 것이다.

[참고]

Unreal Docs
How to properly use Blueprint Native Event?

'Coding' 카테고리의 다른 글

Animation Blueprints  (0) 2022.02.02