UE4之Slate:纯C++工程配置

概述:

Slate是UE4提供的UI框架,整个UE4 Editor UI都是使用Slate构建的;

Slate的官方文档:[Slate UI框架]

Slate底层内容,中文环境下能搜索到的有效资源也不多;

这里打算记录一些SlateCore、Slate模块的基础知识:

包括但不限于类介绍、接口分析、资源管理与加载、渲染等,也会包括一些英文翻译过来的教程;

目标

于UE4新入这来说,有一个step by step的教程,确保VS工程编译成功

工程配置:

注:

1、需要有C++基础,尽量不涉及到蓝图

2、需要熟悉UE4 Gameplay框架

3、目前使用的UE4版本是4.24.3,如版本不同,下面的配置可能会有些许不一致的地方。

4、Windows环境开发,使用Visual Studio作为IDE工具(UE4支持跨平台;同平台下也可以使用不同IDE)

1、使用空模板创建一个C++新工程,因为是纯C++工程,这里不带初学者资源包,以减少工程整体大小;项目名称为HelloSlate;

图1:选择工程类型-Games

                  图1:选择工程类型-Games

                  图2:选择空模板

                    图3:工程设置,C++工程,并且不带初学者内容

2、点击【Create Project】后,会自动打开Visual Studio

VS中打开“HelowSlate.Build.cs”文件,内容如下:

 

 1 // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
 2 
 3 using UnrealBuildTool;
 4 
 5 public class HelloSlate : ModuleRules
 6 {
 7     public HelloSlate(ReadOnlyTargetRules Target) : base(Target)
 8     {
 9         PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
10     
11         PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
12 
13         PrivateDependencyModuleNames.AddRange(new string[] {  });
14 
15         // Uncomment if you are using Slate UI
16         PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
17 
18         // Uncomment if you are using online features
19         // PrivateDependencyModuleNames.Add("OnlineSubsystem");
20 
21         // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
22     }
23 }

 * 第16行,默认应该是被注释掉了,这里需要取消注释,以便为Game模块添加Slate、SlateCore依赖模块;

3、在项目跟目录下面:我这里是E:\Projects\HelloSlate,双击HelloSlate.uproject工程文件,打开Editor;

Editor中,菜单File--Refresh Visual Studio Project,切换到VS中,会自动提示冲洗加载工程(或者直接关掉VS,重新打开工程)

4、VS中编译项目,确保编译成功

 

参考:
UE4官方文档-编程快速入门:https://docs.unrealengine.com/zh-CN/Programming/QuickStart/index.html

posted @ 2020-11-21 16:44  阿佑001  阅读(891)  评论(0编辑  收藏  举报