ue4标签测试与总结(UPROPERTY)
学习UE4框架中的标签,本篇是总结成员变量标签UPROPERTY。
引擎版本:4.12.5
前期准备:
1.新建项目,C++空模板,新建C++类,继承AActor,名称MyActor。
使用TestActor变量进行测试。
// MyActor.h #pragma once #include "GameFramework/Actor.h" #include "MyActor.generated.h" UCLASS() class MYSTEAMONLINEC_API AMyActor : public AActor { GENERATED_BODY() public: AActor* TestActor; public: // Sets default values for this actor's properties AMyActor(); // Called when the game starts or when spawned virtual void BeginPlay() override; // Called every frame virtual void Tick( float DeltaSeconds ) override; };
// MyActor.cpp #include "MySteamOnlineC.h" #include "MyActor.h" // Sets default values AMyActor::AMyActor() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; } // Called when the game starts or when spawned void AMyActor::BeginPlay() { Super::BeginPlay(); } // Called every frame void AMyActor::Tick( float DeltaTime ) { Super::Tick( DeltaTime ); }
2.在ue4编辑器中新建蓝图BP_MyActor,继承MyActor。
UPROPERTY:
EditAnywhere
Indicates that this property can be edited by property windows, on archetypes and instances.(指出该属性可以在属性窗口,蓝图类编辑器,实例中进行修改)
UPROPERTY(EditAnywhere) AActor* TestActor;
level中可以修改
原型中的属性窗口可以修改
EditDefaultsOnly
Indicates that this property can be edited by property windows, but only on archetypes. This operator is incompatible with the Visible* specifiers. (指出该变量只能出现在原型的属性窗口。这个操作与其他可视特性相冲突)
//与EditAnywhere冲突
UPROPERTY(EditDefaultsOnly) AActor* TestActor;
原型中的属性窗口可以修改
EditFixedSize
Only useful for dynamic arrays. This will prevent the user from changing the length of an array via the Unreal Editor property window.(只有在动态数组中有用,该标签将防止用户通过虚幻编辑器属性窗口改变数组长度)
普通数组
UPROPERTY(EditAnywhere) TArray<int32> TestArray;
增加“EditFixedSize”标签后
UPROPERTY(EditAnywhere,EditFixedSize) TArray<int32> TestArray;
EditInline
这个标签在4.12.5中已经没有了
EditInstanceOnly
Indicates that this property can be edited by property windows, but only on instances, not on archetypes. This operator is incompatible with the Visible* specifiers.(只能在场景中的实例的属性窗口修改,该操作与其他可视标签冲突)
UPROPERTY(EditInstanceOnly) AActor* TestActor;
在场景中的实例属性窗口,可以做修改
在原型中已经没有该变量了
VisibleAnywhere
Indicates that this property is visible in property windows, but cannot be edited at all. This operator is incompatible with the Edit* specifiers.(可以在原型与场景中的实例的属性窗口中看到,但是不能修改,与其他修改类标签冲突)
UPROPERTY(EditInstanceOnly) AActor* TestActor;
VisibleDefaultsOnly
Indicates that this property is only visible in property windows for archetypes, and cannot be edited. This operator is incompatible with the Edit* specifiers.(只能在原型的属性窗口中看到,但是不能修改,与其他修改类标签冲突)
UPROPERTY(VisibleDefaultsOnly) AActor* TestActor;
在场景中的实例看不到属性了,在原型中可以看到(就不截图了)
VisibleInstanceOnly
Indicates that this property is only visible in property windows for instances, not for archetypes, and cannot be edited. This operator is incompatible with the Edit* specifiers.(只能在场景中的实例的属性窗口中看到,不能在原型中看到,不能修改,与其他修改类标签冲突)
UPROPERTY(VisibleInstanceOnly) AActor* TestActor;
在原型的属性窗口已经看不到啦
场景实例可以看到
AdvancedDisplay
Properties are in the advanced dropdown in a Details panel.(属性在高级下拉列表中显示)
UPROPERTY(EditAnywhere,AdvancedDisplay) AActor* TestActor;
用三角箭头进行收缩和展开
AssetRegistrySearchable
The AssetRegistrySearchable keyword indicates that this property and its value will be automatically added to the asset registry for any asset class instances containing this as a member variable. It is not legal to use on struct properties or parameters.
(指出这个属性和属性的值,为了包含到所有资源类型实例中,将自动的作为成员变量,添加到资源注册列表。在结构体属性或者参数中使用是非法的。)
不懂啊。。。
其他:
ObjectBase.h中,namespace UP,是标签的源码。
UFUNCTION
Reliable
The function is replicated over the network, and is guaranteed to arrive regardless of bandwidth or network errors. Only valid when used in conjunction with Client or Server.
UFUNCTION(Reliable, Client, Category = "Default") void RespawnCharacter();
Server
The function is only executed on the server. Provide a body named [FunctionName]_Implementation instead of [FunctionName]; the autogenerated code will include a thunk that calls the implementation method when necessary.
ps:在参数传递时,不能使用引用,
必须使用void,不能有返回值
//.h file UFUNCTION(Reliable,Server, WithValidation, Category = "Default") void RespawnCharacterOnServer(); //.cpp file void ABasePlayerController::RespawnCharacterOnServer_Implementation() { } bool ABasePlayerController::RespawnCharacterOnServer_Validate() { return true; }
Client
The function is only executed on the client that owns the Object the function belongs to. Provide a body named [FunctionName]_Implementation instead of [FunctionName]; the autogenerated code will include a thunk that calls the implementation method when necessary.
//.h file UFUNCTION(Reliable, Client, Category = "Default") void RespawnCharacter(); //.cpp file void ABasePlayerController::RespawnCharacter_Implementation() { UBaseGameInstance *tempGameInstanceRef = static_cast<UBaseGameInstance*>(GetGameInstance()); tempGameInstanceRef->IsClient(); }
ue4标签测试与总结(UPROPERTY)的更多相关文章
- Postman的Tests标签测试
接口测试最重要的就是返回数据的检查,一个简单的接口,我们可以肉眼检查返回数据,但接口一旦多起来且复杂,每次的检查都会很费劲,此时我们就需要postman 的tests模块来代替 postman面板: ...
- UE4联网测试的快捷方法
工程中测试 创建bat文件,格式如下: UE4Editor.exe路径 工程文件名 [地图名及参数] -game [其他自定义参数] UE4Editor.exe路径表示虚幻编辑器相应版本的UE4Edi ...
- ue4 碰撞检测测试
记录几条物理相关 测试条件,1使用setActorLocation移动,3使用控制器的移动 1 moveCube 2 targetCube 3 Character 两个Cube的碰撞事件 1和2的 ...
- java web学习总结(二十七) -------------------JSP标签介绍
一.JSP标签介绍 JSP标签也称之为Jsp Action(JSP动作)元素,它用于在Jsp页面中提供业务逻辑功能,避免在JSP页面中直接编写java代码,造成jsp页面难以维护. 二.JSP常用标签 ...
- html中的a标签(超链接)的使用
a标签即超链接,用于从一张页面链接到另一张页面.其最重要的属性是href属性,它指示链接的目标. 例如: <a href="http://www.baidu.com/"> ...
- <button>标签与<input type="button">标签
<script type="text/javascript" src="/jquery-1.11.3.min.js"></script> ...
- JavaWeb---总结(十)JSP标签
一.JSP标签介绍 JSP标签也称之为Jsp Action(JSP动作)元素,它用于在Jsp页面中提供业务逻辑功能,避免在JSP页面中直接编写java代码,造成jsp页面难以维护. 二.JSP常用标签 ...
- jsp的标签
一.JSP标签介绍 JSP标签也称之为Jsp Action(JSP动作)元素,它用于在Jsp页面中提供业务逻辑功能,避免在JSP页面中直接编写java代码,造成jsp页面难以维护. 二.JSP常用标签 ...
- javaweb学习总结(二十七)——jsp简单标签开发案例和打包
一.开发标签库 1.1.开发防盗链标签 1.编写标签处理器类:RefererTag.java 1 package me.gacl.web.simpletag; 2 3 import java.io.I ...
随机推荐
- maven3.2.3+eclipse4.4+JDK1.8+win8.1_64bit环境搭建
--------------------------------------- 博文作者:迦壹 博客标题:win8.1_64bit+eclipse4.4+maven3.2.3+JDK1.8环境搭建 博 ...
- 转载:Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04
原文 http://www.powerxing.com/install-hadoop/ 当开始着手实践 Hadoop 时,安装 Hadoop 往往会成为新手的一道门槛.尽管安装其实很简单,书上有写到, ...
- 记录思想分享知识编辑器 Markdown 编辑阅读器
web使用:实现网页客户端实时自动解析Markdown为HTML内容小小的展示:Cmd Markdown 编辑阅读器使用必要性:怎样引导新手使用 Markdown? - 写作
- .NET批量删除代码前的行号
1 EmEditor Pro.EditPlus .visual studio ,把有行号的代码粘贴进去,按住键盘的Alt键,然后用鼠标拖出选择框列选行号,最后按Delete删除行号; 2 使用正则 ...
- jQuery EasyUI:根据数据库内容生成适合于easyui-tree的JSON数据格式
1,jQuery EasyUI中easyui-tree特定的JSON数据格式 [ {"id":1,"text":"某公司","ch ...
- HackerRank "Flatland Space Stations"
A bit Greedy can achieve O(m) - the mid station between 2 adjacent cities has the longest distance w ...
- [LeetCode] 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. public class ...
- AMap行政区查询服务
AMap.DistrictSearch行政区查询服务插件,提供全国各省.市.县.区的中心点经纬度.行政区边界坐标组.下级行政区等信息.根据行政区边界坐标组可在地图上绘制行政区边界.(本文为原创,并在项 ...
- jave占用CPU较高
转自http://www.tuicool.com/articles/YFVbia Linux下java进程CPU占用率高-分析方法 时间 2014-01-04 12:18:44 IT社区推荐资讯 原文 ...
- [转载]《民航科技》2012年4月专家论坛:罗喜伶《SWIM技术国际研究动态及对中国民航的借鉴意义》
专家介绍:罗喜伶,北京航空航天大学电子信息工程学院副教授,工学博士,硕士生导师,国家空管新航行系统技术重点实验室和协同式网络化空中交通管理系统研究教育部创新团队核心成员,民航空管广域信息系统专家组成员 ...