Giter Site home page Giter Site logo

Unreal Engine 虚幻引擎 about blog HOT 9 OPEN

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024
Unreal Engine 虚幻引擎

from blog.

Comments (9)

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

使用VSCode作为UE5的C++编辑器并设置debug

https://docs.unrealengine.com/5.2/zh-CN/setting-up-visual-studio-code-for-unreal-engine/

安装 C++编译器 #168 (comment)

下载并安装VS Code以及针对VS Code的官方C/C++扩展包C#扩展。这些是读取虚幻引擎及其 编译工具(Build Tools) 的源代码所必需的。

针对你的操作系统,下载并安装对应的编译器工具集[Visual Studio 生成工具]

Windows:Microsoft Visual C++ (MSVC)编译器工具集
所有下载--用于 Visual Studio 的工具--Visual Studio 2022 生成工具

使用此类生成工具,可以通过命令行接口生成 Visual Studio 项目。 支持的项目包括: ASP.NET、Azure、C++ 桌面、ClickOnce、容器、.NET Core、.NET 桌面、Node.js、Office 和 SharePoint、Python、TypeScript、单元测试、UWP、WCF 和 Xamarin。 使用此工具需要有效的 Visual Studio 许可证,除非你正在为项目生成开源依赖项。 有关详细信息,请参阅 Build Tools 许可证

你是否正在查找某个 Visual Studio 2022 长期服务基线(LTSC)? 可在此处找到它们。

Mac:LLVM/Clang

Linux: LLVM/Clang.

Visual Studio 生成工具
image
image
勾选net core
或者手动安装 .NET 8.0 SDK 以上版本
https://dotnet.microsoft.com/zh-cn/download/dotnet/8.0

重启系统 可直接新建空白C++游戏项目

新建一个蓝图项目

image

编辑--编辑器偏好设置--源代码--Visual Studio Code
image
image

生成你的VS Code工作区 [非100%可用 / 废弃]

具体有三种做法:

1 打开 虚幻编辑器(Unreal Editor) 并点击 工具(Tools) > 刷新Visual Studio Code项目(Refresh Visual Studio Code Project) 。
image

在虚幻编辑器中刷新VS Code项目

2 在Windows和Mac上,右键点击项目的 .uproject 文件并点击 生成项目文件(Generate Project Files) 。完成后,你应该会在项目的文件夹中看到 .code-workspace 文件。

image

3 在命令行中,运行 /GenerateProjectFiles.bat -vscode 。添加 -vscode 参数将创建 .vscode 工作区而不是Visual Studio .sln 。如果你使用此方法,则不需要更改默认源代码编辑器。

生成你的VS Code工作区

Tools -- New C++ Class 将Blueprint项目升级为C++项目 [默认即可]

调试游戏

F5-类似 Launch TestGameEditor (Development) (TestGame) ,必须是编辑器版本的选项
ebbb2c682b36e2270139fc645ee5b062

注意:可能需要根据VSCode提示,配置G++编译器
调试时,关闭虚幻编辑器,否则报错

配置 VSCode 的虚幻5[UE5] 代码提示

项目根目录下编辑 .vscode\c_cpp_properties.json 的 键 includePath
windows平台使用\\[第一个斜杠用以转义第二个斜杠已测],
其他平台使用/[待测试]

{
    "configurations": [
        {
            "name": "CustomGame Editor Win64 Development",
            "intelliSenseMode": "msvc-x64",
            "compileCommands": "",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "includePath": [
                "${workspaceFolder}\\Engine\\Plugins\\**\\*",
                "${workspaceFolder}\\Engine\\Intermediate\\**\\*",
				"${workspaceFolder}\\Engine\\Source\\**\\*"
            ],
            "defines": [
                "UNICODE",
                "_UNICODE",
                "__UNREAL__",
                "UBT_COMPILED_PLATFORM=Windows",
                "WITH_ENGINE=1",
                "WITH_UNREAL_DEVELOPER_TOOLS=1",
                "WITH_APPLICATION_CORE=1",
                "WITH_COREUOBJECT=1"
            ]
        }
    ],
    "version": 4
}

或者将${workspaceFolder}替换为 E:\\UnrealEngine-5.1 即引擎源代码根目录

{
    "configurations": [
        {
            "name": "CustomGame Editor Win64 Development",
            "intelliSenseMode": "msvc-x64",
            "compileCommands": "",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "includePath": [
                "E:\\UnrealEngine-5.1\\Engine\\Plugins\\**\\*",
                "E:\\UnrealEngine-5.1\\Engine\\Intermediate\\**\\*",
				"E:\\UnrealEngine-5.1\\Engine\\Source\\**\\*"
            ],
            "defines": [
                "UNICODE",
                "_UNICODE",
                "__UNREAL__",
                "UBT_COMPILED_PLATFORM=Windows",
                "WITH_ENGINE=1",
                "WITH_UNREAL_DEVELOPER_TOOLS=1",
                "WITH_APPLICATION_CORE=1",
                "WITH_COREUOBJECT=1"
            ]
        }
    ],
    "version": 4
}

对于虚幻引擎源代码编译 可以使用 VSCode 编写代码,VS2022 编译工程
但不可以同时使用两者打开同一代码,会相互覆盖代码

from blog.

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

笔记

F 聚焦到选定物体上
长按左键 移动
长按右键 平移
长按中键 上下移动
滚轮 缩放视图

长按右键 + WASD 平移
长按右键 + QE 上下移动

CTRL+I + 移动鼠标 控制太阳角度 模拟日出日落

选中物体后
w 移动
e 旋转
r 缩放

ctrl + w 复制对象

alt +移动 = 复制并移动对象

end 将对象落到下一个对象上

from blog.

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

UE issues

launch program unrealgame.exe does not exist

VSCode 调试时,选择编辑器版本,例如 Launch TestGameEditor (Development) (TestGame)

"UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformTime.h" (dependency of "D:\project\Unreal Projects\a1\GameFramework\Character.h")C/C++(1696)

虚幻编辑器-工具-刷新 VSCode项目
原因:再虚幻引擎编辑器中添加C++文件会导致该错误

LogStaticLightingSystem: Warning: Failed to build lighting!!! 虚幻Lightmass可执行文件已经过时。在Visual Studio中使用开发配置重新编译UnrealLightmass项目。

https://forums.unrealengine.com/t/unreal-lightmass-executable-is-outdated/680381/4

在 Windows 上:

打开 Powershell
导航到UnrealEngine\Engine\Build\BatchFiles
输入命令./Build.bat UnrealLightmass Win64 Development -verbose

staticMeshEditorExtension

https://forums.unrealengine.com/t/static-mesh-editor-extension-cannot-be-found-ue5/484131/9
image
在 4.27 中禁用多边形编辑测试版插件(使用重启编辑器)。
然后移植到 5.0。

The archive entry was compressed using an unsupported compression method

通过虚幻源码编译引擎时,如果遇到网络错误,可以使用仓库提供的 Commit.gitdeps.xml
(https://github.com/EpicGames/UnrealEngine/releases/) 替换源码目录下的同名文件 Engine/Build/Commit.gitdeps.xml

`

The following modules are missing or built with a different engine version:

DataRegistryEditor
GameplayAbilitiesEditor

Engine modules cannot be compiled at runtime. Please build through your IDE.
`

删除 Binaries,Intermediate 文件夹。或者
如果项目使用引擎与当前引擎不同:新建项目,将旧项目的Content,Source文件夹复制到新项目。
新项目首先经过VS编译后,启用旧项目相关插件。

The following modules are missing or built with a different engine version:SubstanceCore SubstanceEditor

删除 Substance 插件的 Binaries,Intermediate 目录,重新编译引擎。
然后 GenerateProjectFiles.bat
最后项目重新生成 vs file

The following modules are missing or built with a different engine version:Engine modules cannot be compiled at runtime. Please build through your IDE.

这需要清理解决方案。

VS编辑器-生成-清理解决方案
image

将重新构建项目。需要时间较久。

这个错误通常出现在你尝试打开一个虚幻引擎项目时,但项目的二进制文件与当前引擎版本不匹配或者缺失。这种情况常见于下载了别人的项目、切换引擎版本或者源代码有更新后没有重新编译的场景。以下是一些解决这个问题的步骤:

1. 重新生成项目文件

  • 首先,尝试重新生成项目文件。在项目文件夹中找到.uproject文件,右键点击它并选择"Generate Visual Studio project files"(对于Windows用户)或相应的IDE选项。
  • 这一步将基于当前的虚幻引擎版本重新生成项目文件和解决方案。

2. 通过IDE编译项目

  • 打开生成的项目解决方案文件(例如,在Windows上是.sln文件)。
  • 使用IDE(如Visual Studio)进行构建。通常,你可以选择"Build"菜单中的"Build Solution"(或相应的构建选项)来编译整个项目。
  • 确保在IDE中设置为开发编辑器模式并选择正确的平台(例如,Win64)。

3. 清理和重建

  • 如果简单的重建不起作用,你可能需要先"Clean"项目(在Visual Studio中通常是在"Build"菜单下),然后再进行构建。
  • 清理操作将移除所有旧的编译文件,确保新的构建完全基于当前的引擎版本。

4. 确认引擎版本

  • 确保你打开项目的虚幻引擎版本与项目最初创建或最后成功编译的版本相同。如果不同,你可能需要下载并安装正确的引擎版本。

5. 重新下载或克隆项目

  • 如果上述步骤均无效,可能是项目文件本身存在问题。尝试重新下载或克隆项目,再从第一步开始尝试。

6. 查看文档和社区支持

  • 如果你在处理这个问题时遇到了困难,可以查看虚幻引擎的官方文档或访问虚幻引擎社区和论坛,那里有许多类似问题的讨论和解决方案。

执行上述步骤通常可以解决因引擎版本不一致或模块缺失引起的问题,让你能够成功打开和编译虚幻引擎项目。

from blog.

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

Blueprint 蓝图

蓝图是一种可视化的编程语言
与C++相反,蓝图是一种文本语言,它是专门为虚幻写的
可以直接在编辑器中编程,而C++是一种工业标准语言,需要独立的编辑器来为它编程

可以快速改变
对蓝图做了改变,你几乎可以立即玩你的游戏
初学者友好 设计师友好
艺术家和设计师可能更喜欢深入到蓝图中

C++显然有它自己的一套优势
比蓝图更简洁,是一种工业标准语言
可以访问虚幻中的所有领域和所有功能,而Blueprint在它能做的事情上有限制。
适合大型游戏
虚幻库是用C++编写
添加你自己的C++功能,然后你的蓝图也可以使用

from blog.

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

C++

新建 C++ 文件后,需要
在VSCode-终端-运行任务-
image
【在windows上】

或者 在虚幻引擎中 点击
image

C++文件才会出现
image

修改C++文件后,需要点击
image
生效,但临时数据在虚幻引擎关闭后消失。
可以关闭虚幻,重新执行VSCode调试编译或VSCode终端build,保持临时数据。

UPROPERTY(EditAnywhere) 将C++变量显示在虚幻引擎中
Source\a1\Public\SCharacter.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "SCharacter.generated.h"

UCLASS()
class A1_API ASCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	ASCharacter();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

	UPROPERTY(EditAnywhere)
	int32 MyInt = 99;

	UPROPERTY(EditAnywhere)
	float MyFloat = 6.66;
};

效果:
image

from blog.

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

虚幻引擎 5 – 新手入门

编辑器基础

创建一个空白 C++ 游戏项目 Learn
image

基础

文件-保存所有 用来保存项目
内容侧滑菜单-保存所有 同样用来保存项目
image
image

窗口-视口-视口2/3/4 可以打开多个视口查看编辑游戏
image
image

添加C++类后,需要刷新项目文件
项目工程根目录 Learn.uproject 右键
image

蓝图选项
image

电影 用来制作游戏预告片等
image

play 运行游戏
image

g 键 : 不运行游戏,而只是查看游戏场景外观

降低游戏的硬件消耗 :设置-引擎可延展性设置-极低
image

控制台 可输入命令

image

stat fps 显示游戏fps 再次运行命令为关闭显示fps

t.MaxFPS 999 无上限帧率 将尽可能使用高fps 999为自定义值

在多人游戏中,可输入命令模拟延迟

蓝图

蓝图-打开关卡蓝图
image
image

拖拽节点 添加打印节点
image
image
关闭蓝图 运行游戏 UI上将显示输入的字符串[2秒后消失]
image
但可以在输出日志中看到
image

视口

未运行时 长按右键 + wasd 可以在场景中导航,滚动鼠标中键改变导航摄像机移动速度

摄像机速度 设置
image

内容文件夹

image

创建关卡
内容文件夹下新建 Map 文件夹,在Map文件夹内新建关卡
image
右键-关卡 创建新关卡 Begin
image
双击打开关卡-保存/不保存
image
新关卡默认为黑

窗口-放置Actor

image

放置 天空光照 Sky Light 到关卡
image
image

放置 天空大气 Sky Atmosphere
image

放置 指数级高度雾 Exponential Height Fog
image

放置 定向光源 Directional light
image
e 键旋转定向光 可模拟日出日落
image
定向光 光源移动性默认为 固定烘焙
如果设置为 可移动 光源,所有场景都将动态计算,不再需要构建灯光
如果设置为 静态 光源,在关卡中没有任何移动的物体时

右侧 可以调节选中对象的细节
image

光源的 移动性/Mobility

此组件被允许移动的频率,用于执行诸多优化。只有在构造函数中设置方为安全操作.
image

静态

阴影只是被烘焙出来,不需要动态计算
静态光源不能在游戏中修改
完全烘焙光照
渲染速度最快

固定

固定光源仅从由Liqhtmass烘焙的静态几何体获得阴影和反射光,所有其他光照均为动态。它可在游戏中改变颜色和强度。
*无法移动
*允许部分烘焙光照
*来自可移动对象的动态阴影

天空光照,定向光源

可移动

可移动光源能在游戏中进行移动和修改。
*完全动态
全场景动态阴影
渲染速度最慢

指数级高度雾 ,天空大气

大纲

包括所有场景对象
可以新建文件夹分组整理
image

地形模式

image
image

需要更大的世界时

点击 创建 默认地形
image

image

开始编辑地形
左键 单击/长按 可以雕刻隆起的山形状
image

逆运算 shift

按住 shift 将可以创建坑洞而非隆起

切换到 选项模式 结束地形编辑

蓝图 Blueprints

蓝图时可视化脚本语言,用来编写游戏逻辑
蓝图代码可以写入多种类型的资产中

内容-右键-蓝图类
image
image

通用

Actor:Actor是一种可在世界中放置或动态生成的对象
Pawn:Pawn是一种可以被“控制”的Actor,且可以接收来自Controller的输入。
角色:角色是Pawn的一种类型,增加了可四处走动的功能。
玩家控制器:PlayerController是Actor的一种子类型,其负责控制玩家所使用的Pawn。
游戏模式基础:GameModeBase定义了正在进行的游戏、其规则、得分以及游戏类型的其他方面。
Actor组件:ActorComponent是一种可复用组件,能被附加到任意Actor上。
场景组件:SceneComponent是一种组件,能够进行场景变换并可被附加到其他场景组件下

关卡蓝图

最基本的蓝图
打开begin关卡蓝图
image

image

节点

事件开始运行/Event BeginPlay

当前游戏是在游戏开始时调用/设置了默认为Begin关卡
即在加载关卡后调用,即使加载其他关卡也会调用该脚本
事件开始运行不是场地点击播放时运行

设置位置

设置位置需要一个操作对象,例如 点光源

场景中添加点光源
image

按 End 键,可将选择对象落到地面上
image

此时在蓝图面板 右键 即可创建对该点光源的引用,
这在内部是一个指针,指向关卡中的任意一个 Actor ,当前指向 点光源 Actor
image
image

在点光源节点右侧圆点[点光源引用]拖动,可创建获取位置函数
函数返回此Actor的RootComponent的位置,目标是Actor
image
image
image
image

from blog.

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

将蓝图转换为C++

本课程将教你如何将一个蓝图项目转换为C++代码,解释在虚幻引擎中使用C++的核心概念。通过这一旅程,你将掌握在虚幻引擎中使用C++时所需的核心概念和最佳方法。
https://dev.epicgames.com/community/learning/courses/re6/unreal-engine-c/z4EJ/unreal-engine-c

from blog.

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

虚幻引擎Quixel Bridge插件

https://docs.unrealengine.com/5.3/zh-CN/quixel-bridge-plugin-for-unreal-engine/

源码版更新插件,需从普通版拷贝 E:\UnrealEngine-5.3.2\Engine\Plugins\Bridge

from blog.

WangShuXian6 avatar WangShuXian6 commented on June 6, 2024

Rider

新项目首先需要经过 VS编译打开。
虚幻编辑器
image
image
image
image
image
image

如果出现编译错误,可使用VS重新编译项目。
格式化代码快捷键-如果使用了VS模式则一样:ctrl + K 然后ctrl + D

编译配置:选择 项目名称,例如 Aura。
提示安装Rider插件时,安装到游戏项目中,非引擎项目。
image

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.