代码笔记

xiaoxiao2021-02-27  527

  1.虚幻中的类前缀你会见到U,A,F,以下就是很好的罗列其中的意义

 U: UObject继承过来的,例如UTexture   A: AActor继承过来的,例如AGameMode   F: 其他的类和结构,例如FName, FVector   T:模板,例如TArray,TMap,TQueue   I: 接口类,ITransaction   E:枚举, ESelectionMode B: Boolean, bEnabled

  2.区分大小写!

  用宏定义来包裹C++代码

  UCLASS 来包裹类

  USTRUCT 包裹结构

  UFUNCTION 包裹功能

  UPROPERTY 包裹属性

一般的结构数据类型有

FBox,FColor,FGuid,FVariant,FVector,TBigInt,TRange

打印数据到屏幕上

#include "Engine.h"

GEngine->AddOnScreenDebugMessage(0, 5.f, FColor::Yellow, FString::FromInt(Number));

GEngine->AddOnScreenDebugMessage(0, 5.f, FColor::Yellow, FString("Hello World!!!") );

容器

TArray,TSparseArray-动态数组

TLinkedList,TDoubleLinkedList

TMap-键值对哈希表

TQueue-队列

TSet-非有序集

4.15以上版本添加一个摄像机的方法:

MyCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("MyCamera")); MyCamera->SetupAttachment(RootComponent); 鼠标操作: InputComponent->BindAxis("Turn", this, &AMyGiant::AddControllerYawInput); InputComponent->BindAxis("LookUp", this, &AMyGiant::AddControllerPitchInput); 不能上下转动时,在角色蓝图里pawn里Use Controller Rotation Pitch打勾。 使用函数的蓝图 UFUNCTION(BlueprintCallable, Category = "Power") Void A() 蓝图的self在代码里用this FVector a =GetMesh()->GetComponentLocation(); FRotator 碰撞事件的方法Hit: FComponentHitSignature(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) FComponentBeginOverlapSignature(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); FComponentEndOverlapSignature(UPrimitiveComponent*, OverlappedComponent, AActor*, OtherActor, UPrimitiveComponent*, OtherComp, int32, OtherBodyIndex);
转载请注明原文地址: https://www.6miu.com/read-186.html

最新回复(0)