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 ...
随机推荐
- case_for_if 各种嵌套相结合
注明:本文是参考其他相关文章 整理,完全尊重原著作 #!/bin/bash usage() { cat << EOF EOF } main() { echo "猜分数赢大奖(0- ...
- ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
mysql 删除表时提示有外键 mysql> drop tables auth_group;ERROR 1217 (23000): Cannot delete or update a paren ...
- discuz论坛搬家
很多站长第一次做网站的时候,无奈选择了速度不是很稳定的空间,慢慢会发现有很多物美价廉速度相当快的空间 这个时候,站长在网站搬家的过程中就会遇到很多困难,今天老袋鼠给大家详细讲解一下discuz论坛搬家 ...
- SecureCRT连接VMWare中Linux
SecureCRT连接vmvare虚拟机ubuntu的前提条件1. 使用主机可以ping通虚拟机,或虚拟机可以ping通主机2. 虚拟机已经开启ssh服务,可以使用sudo apt-get i ...
- socketserver源码解读
在看源码之前我们先来看看有关继承的知识(看源码就是在找继承关系----个人理解) 继承 : 我们先看上面的代码,这是一个简单的类继承,我们可以看到父类Base和子类Son,它们中各有一个Test ...
- HTML5/CSS3超酷环形动画菜单
在线演示 本地下载
- 如何使用安信可 ESP 系列一体化开发环境【转】
本文转载自:http://wiki.ai-thinker.com/ai_ide_use 关于 Problems 报错 注意:Eclipse 只是一个代码编写工具,它并不能读取 makefile 里面的 ...
- 打造vim成类source insight
一.Ubuntu14.04下配置 1.配置vimrc文件 输入:version课查看vimrc文件及位置: system vimrc file: "$VIM/vimrc" user ...
- Java企业微信开发_10_未验证域名归属,JS-SDK功能受限
1.现象: 在企业微信后台填写可信域名后,提示:未验证域名归属,JS-SDK功能受限,如下图: 点击“申请域名校验”后, 注意:域名根目录 当时一直不清楚这个域名根目录在哪里,最后让我给试出来了 2. ...
- c++类之间的关系
我们知道,表达方式分为很多种,对于同一种事物,比如爱情,画家用图画和色彩表达爱恋:音乐家用音符和节奏表达喜爱之情,作家用文字表现爱慕. 而程序员怎么办? 程序员构建类,用类来表达单身之苦.因此,类就是 ...