2019年4月18日在steam发布了个人一款独立动作游戏《EndlessHell》,本文将借此记录发布steam游戏的流程

游戏链接

UE4版本4.21

SteamWork入门指南

文中内容前半部分为提交当时编辑,搬运至博客后更新后续部分

配置

SteamDLL

复制steam程序中的dll文件至本地引擎文件内*\UE_4.21\Engine\Binaries\ThirdParty\Steamworks\Steamv139

如下图所示

最终效果如下

Engine.ini

添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480//测试ID,正式包用自己的ApplicationID
Achievement_0_Id=ACH_WIN_ONE_GAME //添加成就,正式包用自己的成就
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"

UE4配置

开启子系统,如下图

至此进入游戏后按shift+tab可以唤出steam窗口,记住需要使用==独立窗口模式运行==

  • 如需使用steamapi,在target.cs中开启如下选项
1
bUsesSteam = true;
  • 同时在build.cs中如下模块
1
2
3
4
5
6
7
PublicDependencyModuleNames.AddRange(new string[] {
"OnlineSubsystem",
"OnlineSubsystemUtils",
"Steamworks"
});

DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");

SteamWork

  • 首先需要注册一个stemawork账号
  • 发布steam游戏需要申请一个ID,本作ID是1055000(此数字+1为depot的ID),以下用的此数字均为游戏ID,另外需要一次性付费100美刀(当时价格),当销售额度达到1000美刀后返还
  • 另外需要提供个人银行账户,每月月初当上个月份税后金额达到100刀以上会打款到账户
  • 在进入下面之前需要先下载steamSDK,如steamwork首页右下角位置,如图

应用管理

应用程序

通用

设置正确的游戏名字和平台

steam输入

提供的输入方式,如手柄,xbox等

SteamPipe

提交版本

这个是版本生成器,用于提交版本和选择当前在商店下载的游戏版本

提交版本可以使用SDK包中的工具提交,在开始提交之前需要设置如下内容

  1. 修改 sdk\tools\ContentBuilder\scripts\app_build_*.vdf文件为app_build_1055000.vdf,同时修改内容为
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"appbuild"
{
"appid" "1055000"
"desc" "Your build description here" // description for this build
"buildoutput" "..\output\" // build output folder for .log, .csm & .csd files, relative to location of this file
"contentroot" "..\content\" // root content folder, relative to location of this file
"setlive" "" // branch to set live after successful build, non if empty
"preview" "0" // to enable preview builds
"local" "" // set to flie path of local content server

"depots"
{
"1055001" "depot_build_1055001.vdf"
}
}

必须修改的是appid和depots的内容, 对应的ID修改成自己的

  1. depot_build_1055001.vdf文件同样修改内容为
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"DepotBuildConfig"
{
// Set your assigned depot ID here
"DepotID" "1055001"

// Set a root for all content.
// All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths)
// will be resolved relative to this root.
// If you don't define ContentRoot, then it will be assumed to be
// the location of this script file, which probably isn't what you want
"ContentRoot" "E:\Download\steamworks_sdk_144\sdk\tools\ContentBuilder\content"

// include all files recursivley
"FileMapping"
{
// This can be a full path, or a path relative to ContentRoot
"LocalPath" "*"

// This is a path relative to the install folder of your game
"DepotPath" "."

// If LocalPath contains wildcards, setting this means that all
// matching files within subdirectories of LocalPath will also
// be included.
"recursive" "1"
}

// but exclude all symbol files
// This can be a full path, or a path relative to ContentRoot
"FileExclusion" "*.pdb"
}

主要修改depotsid和content的路径

  1. 运行 \sdk\tools\ContentBuilder\builder\steamcmd.exe准备提交内容

  2. ```\sdk\tools\ContentBuilder\content``内是游戏包的内容,请确保exe启动名字与==[安装>通用安装>启动选项>可执行文件]==名字一样

  3. 更新>登录>运行如下脚本提交

    1
    run_app_build E:\Download\steamworks_sdk_144\sdk\tools\ContentBuilder\scripts\app_build_1055000.vdf

    路径为app_build文件的路径

  4. 提交后看到如下图的新的分支,修改default为当前展示和下载的分支

depot设置

此页面比较简单,需要正确设置程序支持的语言平台

安装

通用安装
安装文件夹

下载安装以后的文件夹名字

启动选项
  • 可执行文件:启动程序,一般就是引擎打包以后那个exe文件
  • 其他正确设置就可以
可再发行文件

Steam 可以自动安装您的许多常见可再发行文件

客户端图像

根据要求规格上传各种icon文件

统计与成就

统计

设置统计的类型和名称

成就

设置名称、描述和icon

本地化

成就名称和描述的本地化,可以下载文档再提交更新

管理序列号

申请序列号,注意其中不同的序列号的用途

在首页有下载选项

发布

所有修改完后都需要进入发布选项进行发布到商店,系统会提示差异

成就API

  • 很容易被忘记的一点,ini文件利必须设置与网站成就对应的字符串,如下图

  • 蓝图api

读写成就之前必须先缓存成功

目前版本对于成就进度条的读取和设置只有0或者1,所以只要写入的参数大于0成就即完成,不知后续更新能不能完善

蓝图方法DrawDebugLine(以及其他图形)的方法只能在开发者模式中使用

下文为了得到发布版的DrawLine之类的功能

LineBatchComponent

  • 在UWorld中看到如下声明
1
2
3
4
5
6
7
8
9
10
11
/** Line Batchers. All lines to be drawn in the world. */
UPROPERTY(Transient)
class ULineBatchComponent* LineBatcher;

/** Persistent Line Batchers. They don't get flushed every frame. */
UPROPERTY(Transient)
class ULineBatchComponent* PersistentLineBatcher;

/** Foreground Line Batchers. This can't be Persistent. */
UPROPERTY(Transient)
class ULineBatchComponent* ForegroundLineBatcher;
  • 然后创建并注册组件
1
2
3
4
5
6
7
8
9
10
11
12
*****
if(!LineBatcher)
{
LineBatcher = NewObject<ULineBatchComponent>();
LineBatcher->bCalculateAccurateBounds = false;
}

if(!LineBatcher->IsRegistered())
{
LineBatcher->RegisterComponentWithWorld(this);
}
****
  • 再到组件LineBatchComponent.h

  • 先关注组件内部申明的类FLineBatcherSceneProxy : public FPrimitiveSceneProxy

    • 这个代理继承自FPrimitiveSceneProxy,这个类可以得到重要的FPrimitiveDrawInterface,通过这个类可以画出需要的图形(其他各类方法基本都是通过PDI来画出图形),代码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//重写的方法,不需要自己调用
void FLineBatcherSceneProxy::GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const
{
QUICK_SCOPE_CYCLE_COUNTER( STAT_LineBatcherSceneProxy_GetDynamicMeshElements );

for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
{
if (VisibilityMap & (1 << ViewIndex))
{const FSceneView* View = Views[ViewIndex];
//得到PDI
FPrimitiveDrawInterface* PDI = Collector.GetPDI(ViewIndex);

for (int32 i = 0; i < Lines.Num(); i++)
{
//通过PDI画线,Lines是TArray<FBatchedLine>私有成员
PDI->DrawLine(Lines[i].Start, Lines[i].End, Lines[i].Color, Lines[i].DepthPriority, Lines[i].Thickness);
}

for (int32 i = 0; i < Points.Num(); i++)
{
//同理画点
PDI->DrawPoint(Points[i].Position, Points[i].Color, Points[i].PointSize, Points[i].DepthPriority);
}
  • 代理构造的时候提供ULineBatchComponent
  • 目的是把ULineBatchComponent的数据传给此代理
1
2
3
4
5
6
FLineBatcherSceneProxy::FLineBatcherSceneProxy(const ULineBatchComponent* InComponent) :
FPrimitiveSceneProxy(InComponent), Lines(InComponent->BatchedLines),
Points(InComponent->BatchedPoints), Meshes(InComponent->BatchedMeshes)
{
bWillEverBeLit = false;
}
  • 下面到ULineBatchComponent
  • ::DrawLine方法把FBatchedLine添加到数组,然后通过Tick递减时间并删除
1
2
3
4
5
6
7
8
void ULineBatchComponent::DrawLine(const FVector& Start, const FVector& End, const FLinearColor& Color, uint8 DepthPriority, const float Thickness, const float LifeTime)
{
//构造一个FBatchedLine成员
new(BatchedLines) FBatchedLine(Start, End, Color, LifeTime, Thickness, DepthPriority);

// LineBatcher and PersistentLineBatcher components will be updated at the end of UWorld::Tick
MarkRenderStateDirty();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void ULineBatchComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
bool bDirty = false;
// Update the life time of batched lines, removing the lines which have expired.
for(int32 LineIndex=0; LineIndex < BatchedLines.Num(); LineIndex++)
{
FBatchedLine& Line = BatchedLines[LineIndex];
if (Line.RemainingLifeTime > 0.0f)
{
Line.RemainingLifeTime -= DeltaTime;
if(Line.RemainingLifeTime <= 0.0f)
{
// The line has expired, remove it.
BatchedLines.RemoveAtSwap(LineIndex--);
bDirty = true;
}
}
}
*************************

DrawDebug版本

通过world得到相应的LineBatcher然后调用DrawLine方法

1
2
3
4
5
6
7
8
9
if (GEngine->GetNetMode(InWorld) != NM_DedicatedServer)
{
// this means foreground lines can't be persistent
ULineBatchComponent* const LineBatcher = GetDebugLineBatcher( InWorld, bPersistentLines, LifeTime, (DepthPriority == SDPG_Foreground) );
if(LineBatcher != NULL)
{
float const LineLifeTime = GetDebugLineLifeTime(LineBatcher, LifeTime, bPersistentLines);
LineBatcher->DrawLine(LineStart, LineEnd, Color, DepthPriority, Thickness, LineLifeTime);

封装蓝图函数库

FlibDrawGraphics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "FlibDrawGraphics.generated.h"

/**
*
*/
class ULineBatchComponent;
UCLASS()
class GWORLD_API UFlibDrawGraphics : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
private:
static ULineBatchComponent* GetDebugLineBatcher(const UWorld* InWorld, bool bPersistentLines, float LifeTime, bool bDepthIsForeground);

public:
UFUNCTION(BlueprintCallable)
static void G_DrawLine(UObject* context, FVector Start, FVector End, FLinearColor Color, uint8 DepthPriority, float Thickness, float Duration, bool bPersistent = false);
UFUNCTION(BlueprintCallable)
static void G_DrawBox(UObject* context, FVector Center, FVector Box, FLinearColor Color, uint8 DepthPriority, float Thickness, float Duration, bool bPersistent = false);
UFUNCTION(BlueprintCallable, meta = (context = "WorldContextObject"))
static void G_DrawSoildBox(UObject* context, FVector Center, FVector Extent, FLinearColor Color, uint8 DepthPriority, float Duration, bool bPersistent = false);


};

FlibDrawGraphics.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "FlibDrawGraphics.h"
#include "Components/LineBatchComponent.h"
#include "Engine/World.h"

ULineBatchComponent* ULibGameFunc::GetDebugLineBatcher(const UWorld* InWorld, bool bPersistentLines, float LifeTime, bool bDepthIsForeground)
{

return (InWorld ? (bDepthIsForeground ? InWorld->ForegroundLineBatcher : ((bPersistentLines || (LifeTime > 0.f)) ? InWorld->PersistentLineBatcher : InWorld->LineBatcher)) : NULL);

}


//画线
void ULibGameFunc::BP_DrawLine(UObject* context, FVector Start, FVector End, FLinearColor Color, uint8 DepthPriority, float Thickness, float Duration, bool bPersistent /*= false*/)
{
UWorld* world = context->GetWorld();
if (world)
{
//通过优先级得到对应的组件
ULineBatchComponent* const LineBatcher = GetDebugLineBatcher(world, bPersistent, Duration, DepthPriority == SDPG_Foreground);
//如果是永久的设置时间-1
float const ActualLifetime = bPersistent ? -1.0f : ((Duration > 0.f) ? Duration : LineBatcher->DefaultLifeTime);
LineBatcher->DrawLine(Start, End, Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
}
}


//画盒子边框,通过8个点然后DrawLine得到
void ULibGameFunc::BP_DrawBox(UObject* context, FVector Center, FVector Box, FLinearColor Color, uint8 DepthPriority, float Thickness, float Duration, bool bPersistent /*= false*/)
{

UWorld* world = context->GetWorld();
if (world)
{

ULineBatchComponent* const LineBatcher = GetDebugLineBatcher(world, bPersistent, Duration, DepthPriority == SDPG_Foreground);
float const ActualLifetime = bPersistent ? -1.0f : ((Duration > 0.f) ? Duration : LineBatcher->DefaultLifeTime);
if (LineBatcher)
{ LineBatcher->DrawLine(Center + FVector(Box.X, Box.Y, Box.Z), Center + FVector(Box.X, -Box.Y, Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(Box.X, -Box.Y, Box.Z), Center + FVector(-Box.X, -Box.Y, Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(-Box.X, -Box.Y, Box.Z), Center + FVector(-Box.X, Box.Y, Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(-Box.X, Box.Y, Box.Z), Center + FVector(Box.X, Box.Y, Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(Box.X, Box.Y, -Box.Z), Center + FVector(Box.X, -Box.Y, -Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(Box.X, -Box.Y, -Box.Z), Center + FVector(-Box.X, -Box.Y, -Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(-Box.X, -Box.Y, -Box.Z), Center + FVector(-Box.X, Box.Y, -Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(-Box.X, Box.Y, -Box.Z), Center + FVector(Box.X, Box.Y, -Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(Box.X, Box.Y, Box.Z), Center + FVector(Box.X, Box.Y, -Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(Box.X, -Box.Y, Box.Z), Center + FVector(Box.X, -Box.Y, -Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(-Box.X, -Box.Y, Box.Z), Center + FVector(-Box.X, -Box.Y, -Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);
LineBatcher->DrawLine(Center + FVector(-Box.X, Box.Y, Box.Z), Center + FVector(-Box.X, Box.Y, -Box.Z), Color.ToFColor(true), DepthPriority, Thickness, ActualLifetime);

}
}

}

//画实体的盒子
void ULibGameFunc::DrawSoildBox(UObject* context, FVector Center, FVector Extent, FLinearColor Color, uint8 DepthPriority, float Duration, bool bPersistent/*=false*/)
{
FBox Box = FBox::BuildAABB(Center, Extent);

if (context)
{
UWorld* World = context->GetWorld();
if (World)
{

ULineBatchComponent* const LineBatcher = GetDebugLineBatcher(World, bPersistent, Duration, DepthPriority == SDPG_Foreground);
if (LineBatcher != NULL)
{

float const ActualLifetime = bPersistent ? -1.0f : ((Duration > 0.f) ? Duration : LineBatcher->DefaultLifeTime);
LineBatcher->DrawSolidBox(Box, FTransform::Identity, Color.ToFColor(true), DepthPriority, ActualLifetime);
}
}

}
}

蓝图测试

前言

本文介绍从max到UE4顶点动画实现流程

使用的方式是贴图记录顶点位置和法线信息通过材质球使静态模型模拟动画的播放

Alt text

脚本下载

阅读全文 »

开发环境配置流程

MXSPyCom
  1. 下载GitHub的MXSPyComRelease包,链接
  2. 解压,并将安装包内的MXSPyCOM.exe文件复制到自定义目录
  3. initialize_COM_server.ms脚本放到max对应版本的startup目录中,默认路径是%localappdata%\autodesk\3dsmax\scripts\startup
VsCode
  1. 下载LanguageMaxScript插件

  2. 设置工作区

  3. 创建/配置task.json,可以ctrl+e搜索框中输入>task搜索到Configure Default Build Task,在文件内设置如下代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    {
    "version": "2.0.0",
    "tasks": [
    {
    "label": "Execute in Max",
    "type": "process",
    "command": "C:/MXSPyCOM.exe", //MXSPyCom.exe的路径
    "args": ["-f", "${file}"],
    "presentation": {
    "reveal": "always",
    "panel": "new"
    }
    }
    ]
    }

  4. 更改快捷键配置,方便调试

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    [
    {
    "key": "ctrl+e",
    "command": "workbench.action.tasks.runTask",
    "args": "Execute in Max" //对应任务的名称
    },
    {
    "key": "shift+e",
    "command": "workbench.action.quickOpen" //原来的ctrl+e功能
    },
    {
    "key": "shift+e",
    "command": "workbench.action.quickOpenNavigateNextInFilePicker",
    "when": "inFilesPicker && inQuickOpen"
    }
    ]


测试脚本
  1. 在工作目录创建后缀为 ms格式的脚本文件
  2. 启动max
  3. 复制如下代码到脚本文件内,按 ctrl+e 调试
1
2
3
4
5
6
7
8
9
10
11
12
13
rollout rename_rollout "Enter New Base Name"
(
edittext base_name ""
button rename_them "RENAME"
On rename_them pressed do
(
if base_name.text!="" do (
for i in selection do i.name=uniqueName base_name.text
)
)
)
CreateDialog rename_rollout 250 50

  1. max生成如下窗口