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 ...
随机推荐
- BTC、BCH和BSV三者到底有什么区别?
比特币发展到今天已经有10个年头了,在这十年的发展中,比特币一共经历了两次重要的分裂,现在变成了三种货币,第一种是目前继承了比特币绝大多数遗产的BTC:第二种是BCH:第三种是BSV.那这三种货币到底 ...
- Vue:实践学习笔记(6)——使用SLOT分发内容
Vue:实践学习笔记(6)——使用SLOT分发内容 Slot Slot是什么 Slot是父子组件的通讯方式,可以将父组件的内容显示到子组件之中. 使用SLOT前 比如我在定义组件的时候,在里面输入了X ...
- 微信小程序开发:学习笔记[1]——Hello World
微信小程序开发:学习笔记[1]——Hello World 快速开始 1.前往微信公众平台下载微信开发者工具. 地址:https://mp.weixin.qq.com/debug/wxadoc/dev/ ...
- css 样式(checkbox开关、css按钮)
checkbox开关 css .iosCheck { /* Blue edition */ } .iosCheck input { display: none; } .iosCheck i { dis ...
- Java对象 的创建与构造方法
一.创建对象的四种方法: a. new语句: b. 利用反射,调用描述类的Class对象的newInstance()实例方法: c. 调用对象的clone(): d. 反序列化: 其中new 和 ne ...
- appium不支持Android7.0系统设备解决办法
1. 找到appium的安装目录下的adb.js文件. 2. 打开adb.js,手动修改该文件下的内容: Adb.prototype.getPIDsByName=function(name,cb){ ...
- zabbix 报表
摘自: https://www.w3cschool.cn/zabbix_manager/zabbix_manager-z45f1zie.html
- matlab unique()函数
a = [30, 3,6; 19, 20, 20; 30,3, 6;] b=unique(a,'rows') 返回结果是: b = [19, 20 ,20; 30, 3, 6] b=uniqu ...
- CentOS7 网络管理工具nmcli
今天帮别人调试虚拟机的网络问题(CentOS 7系统),习惯性直接改/etc/sysconfig/network-scripts/ifcfg-xxx配置文件,但是不知道为什么重启network后静态i ...
- 写个sleep玩玩
static void sig_when_weakup(int no){ printf("weakup weakup\n"); longjmp(buf, ); } void wea ...