Unreal Engine 4 C++ 为编辑器中Actor创建自己定义图标
有时候我们创建场景的时候,特定的Actor我们想给它一个特定的图标,便于观察。比方这样:
实现起来也非常easy。须要编写C++代码:
我们创建一个Actor,叫AMyActor。它包括一个Sprite(精灵),这个精灵负责显示自己定义图标:代码例如以下
#pragma once #include "GameFramework/Actor.h"
#include "Components/BillboardComponent.h"
#include "MyActor.generated.h" /**
*
*/
UCLASS()
class NANTOPDOWN_API AMyActor : public AActor
{
GENERATED_UCLASS_BODY() //virtual void BeginPlay() OVERRIDE; UPROPERTY()
TSubobjectPtr<UBillboardComponent> SpriteComponent; UTexture2D* SpriteTexture; };
#include "NanTopDown.h"
#include "MyActor.h" AMyActor::AMyActor(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
struct FConstructorStatics
{
ConstructorHelpers::FObjectFinderOptional<UTexture2D> NoteTextureObject; FName ID_Notes;
FText Name_Notes; FConstructorStatics()
: NoteTextureObject(TEXT("Texture2D'/Game/Textures/MyIcon.MyIcon'"))
, ID_Notes(TEXT("Notes"))
, Name_Notes(NSLOCTEXT("SpriteCategory", "Notes", "Notes"))
{
}
}; static FConstructorStatics Cs;
TSubobjectPtr<USceneComponent> SceneComponent = PCIP.CreateDefaultSubobject<USceneComponent>(
this, TEXT("SceneComp"));
RootComponent = SceneComponent;
RootComponent->Mobility = EComponentMobility::Static; #if WITH_EDITORONLY_DATA
SpriteComponent = PCIP.CreateEditorOnlyDefaultSubobject<UBillboardComponent>(this, TEXT("Sprite"));
if (SpriteComponent)
{
SpriteComponent->Sprite = Cs.NoteTextureObject.Get();
SpriteComponent->SpriteInfo.Category = Cs.ID_Notes;
SpriteComponent->SpriteInfo.DisplayName = Cs.Name_Notes;
SpriteComponent->AttachParent = RootComponent;
SpriteComponent->Mobility = EComponentMobility::Static;
}
#endif
}
AMyActor仅仅有一个UBillboardComponent组件。增加场景就能够看到自己定义的图片了。
參考文章:https://wiki.unrealengine.com/Add_in_editor_Icon_to_your_Custom_Actor
Unreal Engine 4 C++ 为编辑器中Actor创建自己定义图标的更多相关文章
- 剖析Unreal Engine超真实人类的渲染技术Part 1 - 概述和皮肤渲染
一.概述 1.1 数字人类的概要 数字人类(Digital Human)是利用计算机模拟真实人类的一种综合性的渲染技术.也被称为虚拟人类.超真实人类.照片级人类. 它是一种技术和艺术相结合的综合性模拟 ...
- Unreal Engine 4 C++ UCLASS构造函数易出错分析
Unreal Engine 4 C UCLASS构造函数易出错分析 GENERATED_BODY GENERATED_UCLASS_BODY 在Unreal Engine 4的任意类中通常会见到两个宏 ...
- [译]如何在Unity编辑器中添加你自己的工具
在这篇教程中你会学习如何扩展你的Unity3D编辑器,以便在你的项目中更好的使用它.你将会学习如何绘制你自己的gizmo,用代码来实现创建和删除物体,创建编辑器窗口,使用组件,并且允许用户撤销他们所作 ...
- [原][unreal][UE][spark]分析unreal engine 虚幻引擎的粒子编辑器:Cascade
参考:https://www.raywenderlich.com/270-unreal-engine-4-particle-systems-tutorial (使用了一个飞机射击游戏的粒子来展示,全英 ...
- Unreal Engine 4 中的 UI 优化技巧
转自:https://mp.weixin.qq.com/s/bybEHM9tF-jBPxxqXfrPOQ## Unreal Open Day 2017 活动上 Epic Games 开发者支持工程师郭 ...
- 实例甜点 Unreal Engine 4迷你教程(4)之用C++实现添加子Widget到VerticalBox中以及ClearChildren
前置教程: 1. 实例甜点前面的三篇教程: 2. 最好看看笔者前面的一篇关于博文(后记:本来笔者想用C++做DragAndDrop的功能,但是失败了,下面是蓝图实现的方法): http://www.c ...
- 游戏音频技术备忘 (四) Wwise Unreal Engine 集成代码浅析 (一)
在Engine\Plugins\Wwise\Source下为主要Wwise相关代码,AkAudio文件夹下为运行时相关代码,AudiokineticTools下为编辑器工具相关代码,Audiokine ...
- Unreal Engine 4 系列教程 Part 2:蓝图教程
.katex { display: block; text-align: center; white-space: nowrap; } .katex-display > .katex > ...
- Unreal Engine 4 系列教程 Part 5:制作简单游戏
.katex { display: block; text-align: center; white-space: nowrap; } .katex-display > .katex > ...
随机推荐
- Codeforces Round #512 (Div. 2) D.Vasya and Triangle 数学
题面 题意:给你n,m,k,在你在(0,0)到(n,m)的矩形内,选3个格点(x,y都是整数),使得三角形面积为n*m/k,不能找到则输出-1 题解:由毕克定理知道,格点多边形的面积必为1/2的整数倍 ...
- 关于java1.8中LocalDateTime实现日期,字符串互转小坑。
今天无聊,来看了下1.8的时间类型LocalDateTime,当想把字符串转成LocalDateTime的时候报错!! java.time.format.DateTimeParseException: ...
- Xcode7.3 使用NSURLSession发送HTTP请求报错
控制台打印:Application Transport Security has blocked a cleartext HTTP (http://) resource load since it i ...
- 9.13[XJOI] NOIP训练32
今日9.13 洛谷打卡:小吉(今天心情不错,决定取消密码) (日常记流水账) 上午 今天听说是鏼鏼的题目,题面非常的清真啊,也没有当初以为的爆零啊 T1 排排坐 非常非常清真的模拟或是结论题,再次将难 ...
- C#控制台显示进度条
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Prog ...
- art-template简单使用
art-template是一款较通用的前端模板引擎. 简单的使用方法如下: 具备3个要素 1)模板 <script type="text/template" id=" ...
- javascript中经典继承的兼容写法
function create(obj) { // 2.1 判断浏览器支持不支持 Object.create // 如果支持,直接使用 Object.create // 如果不支持,自己实现 if(O ...
- javascript中创建对象和实现继承
# oo ##创建对象 1. 原型.构造函数.实例之间的关系 * 原型的construct->构造函数:调用isPrototypeOf(obj)方法可以判定和实例的关系: * 构造函数的pro ...
- 容器化haproxy+keepalived
# 拉取haproxy镜像 docker pull haproxy:1.7.8-alpine mkdir /etc/haproxy cat >/etc/haproxy/haproxy.cfg&l ...
- [caffe] caffe训练tricks
Tags: Caffe Categories: Tools/Wheels --- 1. 将caffe训练时将屏幕输出定向到文本文件 caffe中自带可以画图的工具,在caffe路径下: ./tools ...