【UE4】 C++调用蓝图

こ雲淡風輕ζ 提交于 2020-03-09 14:29:35

BP_Actor.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyMccActor.generated.h"

UCLASS()
class MYCPPPROJECT_API AMyMccActor : public AActor
{
    GENERATED_BODY()
    
public: 
    // Sets default values for this actor's properties
    AMyMccActor();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

    UFUNCTION(BlueprintImplementableEvent, Category = "SplineMesh")
    void PrintMessage(const FString &Message);


};

Othre.cpp

void XXX::BeginPlay()
{
  TArray<AActor*> _TempArryActors;
  UGameplayStatics::GetAllActorsOfClass(GetWorld(), AActor::GetClass(), _TempArryActors);
  for (int32 i = 0; i < _TempArryActors.Num(); i++)
  {
    if (_TempArryActors[i]->GetName() == FString("AMyMccActor"))
  {
   Cast<AMySplineMeshActor>(_TempArryActors[i])->PrintMessage(TEXT("找到Actor&调用PringMessage函数"));
  }
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!