#define CASTCLASS_UTextProperty DECLARE_UINT64(0x0000000040000000) #define CASTCLASS_UInt16Property DECLARE_UINT64(0x0000000080000000) #define CASTCLASS_UDoubleProperty DECLARE_UINT64(0x0000000100000000) #define CASTCLASS_UAssetClassProperty DECLARE_UINT64(0x0000000200000000) #define CASTCLASS_UPackage DECLAR...
template <typename From, typename To > struct TGetCastType<From, To, false, false, CASTCLASS_None> { static const ECastType Value = ECastType::UObjectToUObject; }; template <typename From, typename To > struct TGetCastType<From, To, false, true , CASTCLASS_None> { static const ECa...
具体使用方式如下,这是Unreal内实现的多线程安全的计数器,在这里就是通过FPlatformAtomics中各类方法来保证其原子操作的。 classFThreadSafeCounter{public:FThreadSafeCounter(){Counter=0;}int32Increment(){returnFPlatformAtomics::InterlockedIncrement(&Counter);}int32Add(int32Amount){returnFPlatformAtomics::Interlock...
typeid:能够让用户知道是什么类型,并提供一些基本对比和name方法,相当于是编译器提供的一个唯一类型ID。 Dyanmic_Cast:用于将一个指向派生类的基类指针或引用转换为派生类指针或引用,转换引用失败会抛出bad_cast异常,转换指针失败会返回null,只能应用于带有虚函数的类。 C++的RTTI相当薄弱,所以只能采用各自的方式实现反...
TCastImpl有多个模板实例: // 通用模板实例template<typename From,typename To,ECastType CastType=TGetCastType<From,To>::Value>structTCastImpl{// This is the cast flags implementationFORCEINLINEstaticTo*DoCast(UObject*Src){returnSrc&&Src->GetClass()->HasAnyCastFlag(TCastFlags<To>::Value)?(To...
typedef struct _OVERLAPPED OVERLAPPED;UENUM(BlueprintType, Category = "UE4Duino")enum class ELineEnd : uint8 { rnUMETA(DisplayName = "\r\n"),nUMETA(DisplayName = "\n"),rUMETA(DisplayName = "\r"),nrUMETA(DisplayName = "\n\r")};UCLASS(BlueprintType, Category = "UE4Duino",...
类似上面的一种写法,,直接帮我们省掉了“Cast”转为对象的过程:TSoftObjectPtr<UStaticMesh> StaticMeshPtr = TSoftObjectPtr<UStaticMesh>(meshFilePath); UStaticMesh* pStaticMesh = StaticMeshPtr.Get(); if (pStaticMesh) { UE_LOG(LogTemp, Error, TEXT("UStaicMesh name is %s"), *pStaticMesh...
不加UPROPERTY的如果想持久的保存指针的话,需要重写UObject的AddReferencedObjects接口为UObject对象添加引用。例如AActor类中为非UPROPERTY的成员变量OwnedComponents添加reference:void AActor::AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector){AActor* This = CastChecked<AActor>(InThis);Collector...
Struct FtestStruct { GENERATED USTRUCT BODY() Int32 ss; } 五: Aactor、Component、Uobject Aactor、Component:汽车与轮子的关系 Uobject:四大功能:反射、垃圾回收(GC)、序列化、COD(class object default) 六:基本类型转换 {//FString To FNameFString Str = TEXT("TestString"); ...