UGameplayStatics::OpenLevel(GetWorld(), TEXT("Map1"));
//退出关卡
UGameplayStatics::GetPlayerController(GWorld, 0)->ConsoleCommand("quit");
- for (TActorIterator
ActorIter(GetWorld()); ActorIter; ++ActorIter) - {
- UKismetSystemLibrary::PrintString(GetWorld(), FString::Printf(TEXT("%s"), *ActorIter->GetName()));
- }
- TArray
OutActors; - UGameplayStatics::GetAllActorsOfClass(GetWorld(), AStaticMeshActor::StaticClass(), OutActors);
- for (AActor* actor : OutActors)
- {
- UKismetSystemLibrary::PrintString(GetWorld(), actor->GetName());
- }
UPROPERTY(VisibleAnywhere,Category = UI)
TSubclassOf
- //静态加载模型资源
- MeshObj = CreateDefaultSubobject
(TEXT("Mesh1")); - static ConstructorHelpers::FObjectFinder
TmpMesh(TEXT("StaticMesh'/Game/StarterContent/Shapes/Shape_NarrowCapsule.Shape_NarrowCapsule'")); - MeshObj->SetStaticMesh(TmpMesh.Object);
-
- 静态加载类
- static ConstructorHelpers::FClassFinder
MyActor2(TEXT("BBlueprint'/Game/Blueprints/BP_LoadTest.BP_LoadTest_C'")); - MyActor = MyActor2.Class;
- //动态加载资源类
- UMaterial *mt = LoadObject<UMaterial>(nullptr, TEXT("/Game/Map/Materials/grass.grass"));
- UMaterial *mt = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), nullptr, TEXT("/Game/Map/Materials/grass.grass")));
-
- //动态加载类
- Class = LoadClass<AActor>(nullptr,TEXT("Blueprint'/Game/BluePrint/BP_Test.BP_Test_C'"))
- Class = Cast<UClass>(StaticLoadObject(UClass::StaticClass(), nullptr, TEXT("Blueprint'/Game/BluePrint/BP_Test.BP_Test_C'")));
AXuHuanVSGameModeBase *MyGameMode = Cast<AXuHuanVSGameModeBase>(GetWorld()->GetAuthGameMode());
AMyPawn *MyPawn = Cast<AMyPawn>(GetWorld()->GetFirstPlayerController()->GetPawn());
AGameState *MyState = Cast<AGameState>(GetWorld()->GetGameState());
AMyPlayerController *MyPlayerController = Cast<AMyPlayerController>(GetWorld()->GetFirstPlayerController());
- DefaultPawnClass = AMyPawn::StaticClass();
- HUDClass = AMyHUD::StaticClass();
- PlayerControllerClass = AMyPlayerController::StaticClass();
- GameStateClass = AMyGameState::StaticClass();
- PlayerStateClass = AMyPlayerState::StaticClass();
(FMath::RInterpTo(GetControlRotation(), DesireRotation, GetWorld()->GetRealTimeSeconds(), 10);
- UENUM()
- namespace MyEnum
- {
- enum MyTpe
- {
- Type1,
- Type2,
- Type3,
- }
- }
-
- //声明变量
- UPROPERTY(EditDefaultsOnly, Category = KWorld)
- TEnumAsByte
CustomA;
- USTRUCT()
- struct FGameCharacterDataAttribute
- {
- GENERATED_USTRUCT_BODY()
- //角色名称
- UPROPERTY()
- FName Character;
- //角色ID
- UPROPERTY()
- int32 CharacterID;
- public:
- FGameCharacterDataAttribute();
- }
-
- //声明变量
-
- UPROPERTY()
- FGameCharacterDataAttribute CharacterDataBase;