参见 https://www.unrealengine.com/blog/unreal-property-system-reflection

//
// Base class for mobile units (soldiers)
#include "StrategyTypes.h"
#include "StrategyChar.generated.h"UCLASS(Abstract)
class AStrategyChar : public ACharacter, public IStrategyTeamInterface
{
GENERATED_UCLASS_BODY()/** How many resources this pawn is worth when it dies. */
UPROPERTY(EditAnywhere, Category=Pawn)
int32 ResourcesToGather;/** set attachment for weapon slot */
UFUNCTION(BlueprintCallable, Category=Attachment)
void SetWeaponAttachment(class UStrategyAttachment* Weapon);UFUNCTION(BlueprintCallable, Category=Attachment)
bool IsWeaponAttached();protected:
/** melee anim */
UPROPERTY(EditDefaultsOnly, Category=Pawn)
UAnimMontage* MeleeAnim;/** Armor attachment slot */
UPROPERTY()
UStrategyAttachment* ArmorSlot;/** team number */
uint8 MyTeamNum;
[more code omitted]
};

USING REFLECTION DATA

UField
UStruct
UClass (C++ class)
UScriptStruct (C++ struct)
UFunction (C++ function)
UEnum (C++ enumeration)
UProperty (C++ member variable or function parameter)
(Many subclasses for different types)

To iterate over all members of a UStruct, use a TFieldIterator:

 for (TFieldIterator<UProperty> PropIt(GetClass()); PropIt; ++PropIt){UProperty* Property = *PropIt;UE_LOG(YourLog, Warning, TEXT("get property:%s"), *(PropIt->GetFName()).ToString());// Do something with the property}

Object iterators are a very useful tool to iterate over all instances of a particular UObject type and its subclasses.

for (TObjectIterator<UObject> It; It; ++It){UObject* CurrentObject = *It;UE_LOG(YourLog, Log, TEXT("Found UObject named: %s"), *CurrentObject->GetName());}

ActorIterator

APlayerController* MyPC = GetMyPlayerControllerFromSomewhere();
UWorld* World = MyPC->GetWorld();// Like object iterators, you can provide a specific class to get only objects that are
// or derive from that class
for (TActorIterator<AEnemy> It(World); It; ++It)
{// ...
}

  

转载于:https://www.cnblogs.com/pengyingh/articles/5489295.html

UNREAL4 PROPERTY SYSTEM相关推荐

  1. Android平台上使用属性系统(property system)

    在使用Android的属性系统(property system)时遇到了一些问题,结合此次经历,对属性系统的使用做以简单介绍. 一.Property系统简介 属性系统是android的一个重要特性.它 ...

  2. The Property System

    感谢MaxValue,hennychen 对本文的翻译,同时非常感谢Cxt_programmer在百忙中抽出时间对翻译初稿的认真校验.才使本文与读者尽快见面.由于书稿内容多,我们的知识有限,尽管我们进 ...

  3. Unreal Property System (Reflection) 虚幻属性系统(反射)

    Unreal Property System (Reflection) https://www.unrealengine.com/en-US/blog/unreal-property-system-r ...

  4. C#中怎样获取System.Drawing.Color的所有颜色对象并存到数组中

    场景 需要在生成一组多条曲线时,随机从一颜色数组中取颜色,至少一百种颜色以上. 而System.Drawing.Color自带140多种颜色 那么怎样将其自带的颜色对象取出并存在数组中. 注: 博客主 ...

  5. select html value属性,HtmlSelect.DataValueField 属性 (System.Web.UI.HtmlControls) | Microsoft Docs...

    获取或设置数据源中要绑定到 Value 控件中各项的 HtmlSelect 属性的字段.Gets or sets the field from the data source to bind to t ...

  6. 6、Qt Meta Object system 学习

    原文地址:http://blog.csdn.net/ilvu999/article/details/8049908 使用 meta object system 继承自 QOject 类定义中添加 Q_ ...

  7. 面试干货 | Java 能否自定义一个类叫 java.lang.System?

    本文由读者 apdoer 投稿,apdoer 是一个极具钻研精神的 Java 猿,技术牛X头发茂盛! 博客地址:https://blog.csdn.net/m0_43452671 缘起:一个面试题 最 ...

  8. Java中的系统类–属性,System.out.println()

    System class in java is one of the core classes and I have never seen any java developer who doesn't ...

  9. 十九 Java的语言基础(System类 Date类)

    System类 1 System.exit(0);//0是正常推出,非0强制退出:System.gc();//运行垃圾回收器2.获取当前的毫秒值:1s=1000ms:Long start = Syst ...

最新文章

  1. android toolbar 开发总结
  2. 以太网速率怎么手动设置_OPENWRT-KOOLSHARE软路由,一级/单臂/二级/旁软路由设置单臂路由联网教程...
  3. EC2上的ElasticSearch不到60秒
  4. 我给Apache顶级项目提了个Bug
  5. 2 WM配置-企业结构-分配-给工厂和库存地点分配仓库号
  6. JS-数据类型转换-运算符
  7. sqlite3存储与读写
  8. android引导用户打开位置权限_想升级 App?先要个权限吧!!!
  9. Android移植之自定义ProgressBar
  10. java 包装类缺点_Java 自动拆箱和自动装箱学习笔记
  11. html输入框2位小数,input输入框数字限制(2位小数,含0的正整数)
  12. Spring3.0_调试错误集
  13. factory工厂模式之工厂方法FactoryMethod
  14. ImportError: No module named MySQLdb
  15. linux查询语言,Linux结构化查询语言SQL——SQL的分类和DDL使用
  16. 六、CSS3的美化字体与段落
  17. 神经网络梯度消失和梯度爆炸原因推导及其解决方案
  18. word怎么将文档分成三节_分节排版,就是将Word 2010的文档分节,使文档在不同的节中具有不同的______。(2.0分)_学小易找答案...
  19. js Number计算精确度
  20. 如愿斩获阿里巴巴定级P7的offer,不知四面其艰难,为此筹备半年

热门文章

  1. html css雪碧图,css常见小技巧(雪碧图)
  2. Pycharm提示方法Method xxx may be 'static'
  3. 一个计算机有几个cpu,为什么电脑都只有一个CPU
  4. 【学习笔记】商业数据分析
  5. 一文看懂大功率(PD3.1 240W)线缆的过温保护解决方案
  6. 让自己学会有效管理时间
  7. 多线程之CompletableFuture全方面解析
  8. 国产下的netcore
  9. 基于K8S的DevOps应用方案
  10. 线性代数(9): 空间与维度