TSubclassOf的一些说明
TSubclassOf<AActor> TS = LoadClass<AActor>(NULL, TEXT("Blueprint'/Game/bp/Map/TMapActorBP.TMapActorBP_C'"));
GetWorld()->SpawnActor<AActor>(TS);
TS就是个类类型
template< class T >
T* SpawnActor( UClass* Class, const FActorSpawnParameters& SpawnParameters = FActorSpawnParameters() )
{
return CastChecked<T>(SpawnActor(Class, NULL, NULL, SpawnParameters),ECastCheckedType::NullAllowed);
}
- https://answers.unrealengine.com/questions/462096/why-use-tsubclassof-and-not-just-the-class-itself.html
- UDamageType* dmgType;
- vs
- UClass* DamageType;
- vs
- TSubclassOf<UDamageType> DamageType;
the first one is a blue pin object reference, which is not a class reference at all, its a reference to an object that is already created, or it is null. the second one is a purple pin Class reference, used to create new objects from, but in the details panel
it would create a drop down menu that allows you to select any class.
the third one is TSubclassOf, which is like the second one, where it is a purple pin Class variable used to create new objects from, but the editor's details panel will list only classes derived from UDamageType as choices for the property, instead of listing
every class in the engine as an available replacement for that pointer.
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/TSubclassOf/index.html
so the first one is an object pointer, and the last 2 are class pointers, and the final one is a specific type of class pointer than narrows down the list of available class choices.
class pointers are different from object pointers, because UClass pointers reference class assets available in the editor, while object pointers can only be valid at runtime, because they can only reference objects that are already created or spawned into ram
during gameplay.
so if you were making a weapon pickup item, where you wanted the designer to be able to choose the damage type for that weapon from the details panel, you would use
- TSubclassOf<UDamageType> DamageTypeClass;
then on begin play, you can use
- UDamageType* dmgType = NewObject<UDamageType>(DamageTypeClass);
that will give you a pointer to a created object of a type decided in the editor by a designer.
TSubclassOf的一些说明的更多相关文章
- UE4 TSubclassOf VS Native Pointer
最近看到了TSubclassOf ,所以想要弄清楚跟一般指针的区别~ NativePointer VS UClass* VS TSubclassOf AActor* p ...
- UE4新手之编程指南
虚幻引擎4为程序员提供了两套工具集,可共同使用来加速开发的工作流程. 新的游戏类.Slate和Canvas用户接口元素以及编辑器功能可以使用C++语言来编写,并且在使用Visual Studio 或 ...
- 《Note --- Unreal 4 --- Sample analyze --- StrategyGame(continue...)》
---------------------------------------------------------------------------------------------------- ...
- 《InsideUE4》-9-GamePlay架构(八)Player
你们对力量一无所知 引言 回顾上文,我们谈完了World和Level级别的逻辑操纵控制,如同分离组合的AController一样,UE在World的层次上也采用了一个分离的AGameMode来抽离了游 ...
- 《InsideUE4》-6-GamePlay架构(五)Controller
<InsideUE4>-6-GamePlay架构(五)Controller Tags: InsideUE4 GamePlay 那一天 Pawn又回想起了 被Controller所支配的恐惧 ...
- UE4 中Struct Emum 类型的定义方式 笔记
UE4 基础,但是不经常用总是忘记,做个笔记加深记忆: 图方便就随便贴一个项目中的STRUCT和 Enum 的.h 文件 Note:虽然USTRUCT可以定义函数,但是不能加UFUNCTION 标签喔 ...
- ue4框架C++语法汇总文章
1.Run external .exe file TCHAR* url = TEXT("C:\\windows\\system32\\calc.exe"); FPlatformPr ...
- Ue4中的框选函数
void AHUD::GetActorsInSelectionRectangle(TSubclassOf<class AActor> ClassFilter, const FVector2 ...
- Ue4 BatteryCollector 教程笔记
H UFUNCTION(BlueprintNativeEvent) void EventName(); virtual void EventName_Implementation(); EventNa ...
随机推荐
- Error: Failed to fetch plugin E:_My_File______workMyCodemyCodecordova-workspaceplugman-testMyMath via registry. Probably this is either a connection problem, or plugin spec is incorrect.
$ cordova plugin add E:\_My_File_____\_work\MyCode\myCode\cordova-workspace\plugman-test\MyMath --sa ...
- ABAP-创建客户
CALL METHOD CMD_EI_API=>MAINTAIN_BAPI FUNCTION Z_CS_RFC_OA002 . *"------------------------ ...
- kinect/xiton 的环境搭建 + rgb图像和深度图的标定
~ 软件下载地址 openni https://structure.io/openni https://github.com/OpenNI/OpenNI2 其他软件建议直接下载或通过某宝购买配套的 ~ ...
- 微信小程序开发:学习笔记[7]——理解小程序的宿主环境
微信小程序开发:学习笔记[7]——理解小程序的宿主环境 渲染层与逻辑层 小程序的运行环境分成渲染层和逻辑层. 程序构造器
- 原生Base64编码/解码(OC与Swift)
Objective-C NSString *plainString = @"foo"; Encoding NSData *plainData = [plainString data ...
- 2 《锋利的jQuery》jQuery选择器
tip1:jquery检查某个元素是否存在:if($("#tt").length>0){}或者if($("#tt")[0]){} 先说css选择器有: 标 ...
- HTML5实现中国象棋游戏(无人能敌)
1. [代码][JavaScript]代码 var AI = AI||{}; AI.historyTable = {}; //历史表 //人工智能初始化AI.init = func ...
- BZOJ 1614 [Usaco2007 Jan]Telephone Lines架设电话线:spfa + 二分【路径中最大边长最小】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1614 题意: 给你一个无向图,n个点,m条边. 你需要找出一条从1到n的路径,使得这条路径 ...
- 主备角色switch
理论知识:Switchover 切换允许primary 和一个备库进行切换,并且这种切换没有数据丢失. 前提条件: 1) 主备库相关参数 fal_client.fal_server .standby_ ...
- 向nexus远程仓库里面添加JAR
向nexus远程仓库里面添加JAR 远程仓库:http://10.1.252.21:8081/nexus/index.html admin/admin123 方法一:手动 在左侧选择:Reposito ...