中EN

C++ and Blueprints (LightSwitchBoth example)

  • C++ classes can be extended with Blueprints ... programmers set up new gameplay classes in code that can be built upon and changed with Blueprints by level designers.
  • Without specifiers, components, variables and functions in the C++ class would not be accessible to Blueprint graphs.
  • Blueprintable UCLASS specifier is inherited (AActor is Blueprintable).
  • Components UPROPERTY(VisibleAnywhere, BlueprintReadOnly); DesiredIntensity UPROPERTY(EditAnywhere, BlueprintReadWrite); OnOverlapBegin UFUNCTION(BlueprintNativeEvent) with OnOverlapBegin_Implementation. If the Blueprint event does not exist, the C++ implementation executes instead.
  • In the constructor: CreateDefaultSubobject<UPointLightComponent>(...), Sphere1->OnComponentBeginOverlap.AddDynamic(this, &ALightSwitchBoth::OnOverlapBegin);
  • Native components show dark blue icons in the Blueprint Components tab; Blueprint-added ones light blue.
  • Construction Script executes when the Actor is moved within the level and when exposed variables change; the C++ constructor alone would not.
  • EditAnywhere means each instance can have its own value.
  • First code class in blank project: close editor, compile in IDE, reopen; build configuration must match editor executable. Existing projects: Hot Reload.

引用这一章的笔记

输入关键词开始搜索

滚轮或双指缩放 · 拖动平移 · 双击放大 / 还原