天水市秦州区建设局网站,ps切片工具做网站,网站建设要学哪些软件有哪些内容,湖南建设集团网站目录 游戏类
三种时间函数类型函数和提示类型
FName、FString、FText类型相互转化
数组容器
键值容器
集合容器
基本类型打印
UPROPERTY宏
函数
枚举
法1 法2 结构体
其他
蓝图生成时暴露 游戏类
1.创建所需项的类 2.创建游戏模式类#xff0c;在该类上实现所需…目录 游戏类
三种时间函数类型函数和提示类型
FName、FString、FText类型相互转化
数组容器
键值容器
集合容器
基本类型打印
UPROPERTY宏
函数
枚举
法1 法2 结构体
其他
蓝图生成时暴露 游戏类
1.创建所需项的类 2.创建游戏模式类在该类上实现所需项引入头文件和构造函数时实例化 三种时间函数类型函数和提示类型 FName、FString、FText类型相互转化 FName用FName FString用ToString FText用FTextFromString、FromName //转化
FString MyString TEXT(I am String);
FName MyName FName(I am Name);
FString x TEXT(I am a FString);
FText MyText FText::FromString(x);//FString-》FName
FName fName FName(*MyString);//将string解引用为字符数组
//FText-FName
fName FName(*(MyText.ToString()));//FName-FString
FString fString fName.ToString();
//FText-Fstring
fString MyText.ToString();//FString-》FText
FText fText FText::FromString(MyString);
//FName-FText
fText FText::FromName(MyName); 数组容器 TArrayintarr;
//增arr.Add(10);arr.Add(25);arr.Add(40);arr.Add(60);arr.AddUnique(35);arr.AddUnique(40);printArr();//删arr.Remove(10);//移除10元素arr.RemoveSingle(40);//移除第一个40arr.RemoveAt(1);//移除第一个arr.Empty();//移除所有元素arr.Reset();//全部为0printArr();//改arr.Insert(80, 0);//在index处插入原元素后移int b arr[0];b 24;printArr();//查arr.Contains(10);//是否包含arr.Find(24);//是否包含是返回index不是返回-1arr.FindLast(24);
void ASGameMode::printArr() {for (auto It arr.CreateConstIterator();It;It){UE_LOG(LogTemp,Warning,TEXT(%d),*It);GEngine-AddOnScreenDebugMessage(-1, 5.F, FColor::Blue, FString::Printf (TEXT(%d),*It));}
} 键值容器
TMapint, intmap; map.Emplace(0, 1);map.Emplace(1, 3);map.Emplace(2, 5);//删map.Remove(1);//按Key删除map.Empty();//查找map.Contains(2);//按key查找int* isFind map.Find(5);//找5返回指针const int*isFindKey map.FindKey(2);//值找键//获取查找TArrayintarrkey;TArrayintarrayVal;map.GenerateKeyArray(arrkey);map.GenerateValueArray(arrayVal);
void ASGameMode::printmap()
{for (auto TestMap:map) {GEngine-AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT(key:%d,Value:%d), TestMap.Key,TestMap.Value));UE_LOG(LogTemp,Display,TEXT(key:%d,Value:%d), TestMap.Key, TestMap.Value);}
} 集合容器
TSetFStringFruitSet;
//增
FruitSet.Add(TEXT(Apple));
FruitSet.Add(TEXT(Orange));
FruitSet.Add(TEXT(Banana));
FruitSet.Emplace(Purple);//比add好在插入集合时避免创建临时文件
PrintFruit();
TSetFString TestSet2;
TestSet2.Emplace(TEXT(aaa));
TestSet2.Emplace(TEXT(bbb));
TestSet2.Emplace(TEXT(ccc));
FruitSet.Append(TestSet2);
PrintFruit();
FruitSet.Remove(TEXT(aaa));
FruitSet.Reset();
FruitSet.Empty();
PrintFruit();
int32 lenFruitSet.Num();
bool isFindFruitSet.Contains(TEXT(bbb));
FString* isFind2FruitSet.Find(TEXT(ccc));TArrayFString FruitArr FruitSet.Array();TSetFStringTS2 { TEXT(a),TEXT(aa) ,TEXT(aaa) ,TEXT(aaaa) };
//长度排序
TS2.Sort([](FString A, FString B){return A.Len() B.Len(); });
void ASGameMode::PrintFruit()
{for (auto TestSet : FruitSet) {GEngine-AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT(%s),* TestSet));UE_LOG(LogTemp, Display, TEXT(%s), *TestSet);}
} TSetFStringMySet;
MySet.Add(TEXT(abc));
FSetElementId index MySet.Add(TEXT(bbc));
MySet[index] TEXT(abd);//预留内存
TSetFString NewSet2;
NewSet2.Reserve(10);for (int32 i0;i10;i)
{NewSet2.Add(FString::Printf(TEXT(No:%d), i));
}
for (int32 i0;i10;i2)
{NewSet2.Remove(FSetElementId::FromInteger(i));
}
NewSet2.Shrink();//删除末端空白元素
NewSet2.Compact();//删除空白元素 基本类型打印 int32 myInt 10;float myFloat 5.f;bool myBool true;char myChar c;FString myString TEXT(xxx);FVector myVector FVector(1,1,1);UE_LOG(LogTemp,Display,TEXT(%d,%f,%d,%c,%s,%s), myInt, myFloat, myBool, myChar, *myString, *myVector.ToString());
UPROPERTY宏 //在哪些地方可见
UPROPERTY(VisibleAnywhere)int32 Int32_VisibleAnywhere;
UPROPERTY(VisibleDefaultsOnly)int32 Int32_VisibleDefaultsOnly;
UPROPERTY(VisibleInstanceOnly)int32 Int32_VisibleInstanceOnly;//在哪些地方可编辑
UPROPERTY(EditDefaultsOnly)FVector V3_EditDefaultsOnly;
UPROPERTY(EditAnywhere)FVector V3_EditAnywhere;
UPROPERTY(EditInstanceOnly)FVector V3_EditInstanceOnly;//在蓝图中可get和getset
UPROPERTY(EditAnywhere,BlueprintReadOnly)int32 int32_EditAnywhere_BlueprintReadOnly;
UPROPERTY(EditAnywhere,BlueprintReadWrite)int32 int32_EditAnywhere_BlueprintReadWrite;//目录
UPROPERTY(EditAnywhere,BlueprintReadWrite,CategoryMyIntValue)int32 valueB1;//子目录
UPROPERTY(EditAnywhere,BlueprintReadWrite,CategoryMyIntValue|MySubIntValue)int32 ValueB2;//起别名
UPROPERTY(EditAnywhere,BlueprintReadWrite,meta(DisplayNamedisplayName))int32 ValueB3;//条件控制编辑上者影响下者是否能修改
UPROPERTY(EditAnywhere,BlueprintReadWrite,meta(DisplayNameController))bool isController;
UPROPERTY(EditAnywhere,BlueprintReadOnly,meta(EditConditionisController))float ValueB4;//变量提示
UPROPERTY(EditAnywhere,BlueprintReadOnly,meta(ToolTipisControllerTrue))
bool isTrue;
函数
//暴露在蓝图可调用
UFUNCTION(BlueprintCallable,categoryMyFunction)
void PrintF1();
//纯虚函数仅返回值
UFUNCTION(BlueprintCallable,BlueprintPure,categoryMyFunction)
bool PrintF2();//不能定义(CPP不实现)只能重载
//无返回值的是事件、有返回值的是函数
UFUNCTION(BlueprintImplementableEvent)
void Test1();
UFUNCTION(BlueprintImplementableEvent)
int Test2();
UFUNCTION(BlueprintImplementableEvent)
void Test3(const FString MyString);
UFUNCTION(BlueprintImplementableEvent)
int Test4(const FString MyString);//在C中声明蓝图重载或不重载
//有连线-用连线的方法重载否则用CPP写好的方法不重载
UFUNCTION(BlueprintNativeEvent)void TestA();
UFUNCTION(BlueprintNativeEvent)int TestB();
UFUNCTION(BlueprintNativeEvent)void TestC(const FString MyString);
UFUNCTION(BlueprintNativeEvent)
int TestD(const FString MyString);//起别名
UFUNCTION(BlueprintCallable,CategoryMyFunction,meta(DisplayMyPrintTest))void Printtest(); 重载不重载那个要加_implementation void AMyPawn::TestA_Implementation()
{
}void AMyPawn::TestB_Implementation()
{
}void AMyPawn::TestC_Implementation(const FString MyString)
{UE_LOG(LogTemp, Display, TEXT(%s), *MyString);
}void AMyPawn::TestD_Implementation(const FString MyString)
{
}
枚举
位置同UCLASS
法1
UENUM(BlueprintType)
namespace MyEnumType
{enum MyCustomEnum {type1,type2,type3};
} UPROPERTY(EditAnywhere,BlueprintReadWrite,CategoryMyEnum)TEnumAsByteMyEnumType::MyCustomEnum MyCustomEnumInst; 法2 UENUM(BlueprintType)
enum class MyCustomEnum2 :uint8
{a UMETA(DisplayNametype1),b UMETA(DisplayNametype2),c UMETA(DisplayNametype3)
}; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category MyCustomStruct)MyCustomEnum2 myCustomStruct; 结构体
//命名必须以F开头
USTRUCT(BlueprintType)//作为蓝图类型可被蓝图调用
struct FMyStruct
{GENERATED_USTRUCT_BODY()UPROPERTY(EditAnywhere,BlueprintReadWrite,CategoryMyTestStruct)int32 Health;UPROPERTY(EditAnywhere,BlueprintReadWrite,CategoryMyTestStruct)FString MyName;
}; //结构体UPROPERTY(EditAnywhere,BlueprintReadWrite,CategoryMyCustomStruct)FMyStruct myCustomStruct; 其他
蓝图生成时暴露 //蓝图生成时暴露UPROPERTY(EditAnywhere,BlueprintReadWrite,CategoryMyExposeOnSpawn,meta(ExposeOnSpawnExposeOnSpawnValue))float Health;