当前位置:网站首页>Ue5 hot update - remote server automatic download and version detection (simplehotupdate)
Ue5 hot update - remote server automatic download and version detection (simplehotupdate)
2022-07-05 07:27:00 【Human house】
Hello, everyone , My name is Renzhai , I'm glad to explain the above content to you :
Hot update plugin SimpleHotUpdate When using, many people don't know how to automatically download the hot update resources deployed at the remote end . I also often solve this problem remotely , Solved a lot , All the discoveries are The same question , Here is an article about how to automatically deploy code for hot update :
Just copy the following code to your own project Source Inside :
1. Directory structure
With MMOARPG Engineering as an example
2. In their own projects build.cs Lower include SimpleHotUpdate and UMG modular It's better to put Slate and SlateCore Also on
3. Copy the following code into your own code file
UI_HotUpdateMain.h
//Copyright (C) RenZhai.2022.All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "UI_HotUpdateMain.generated.h"
class UTextBlock;
class UProgressBar;
class UVersionControlObject;
enum class EServerVersionResponseType :uint8;
/**
*
*/
UCLASS()
class UUI_HotUpdateMain : public UUserWidget
{
GENERATED_BODY()
UPROPERTY(meta = (BindWidget))
UTextBlock* TipText;
UPROPERTY(meta = (BindWidget))
UTextBlock* VersionName;
UPROPERTY(meta = (BindWidget))
UTextBlock* DownloadSpeedText;
UPROPERTY(meta = (BindWidget))
UTextBlock* DownloadedResourceName;
UPROPERTY(meta = (BindWidget))
UTextBlock* DownloadDataSize;
UPROPERTY(meta = (BindWidget))
UProgressBar* DownLoadProgress;
UPROPERTY()
UVersionControlObject* VersionControlObject;
public:
UUI_HotUpdateMain(const FObjectInitializer& ObjectInitializer);
virtual void NativeConstruct();
virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime);
virtual void NativeDestruct();
private:
UFUNCTION()
void PlayHotUpdateAnim();
UFUNCTION()
void PlayTipAnim();
UFUNCTION()
void Downloading(float InValue, const FString& InName, int32 TotalBytes, int32 BytesReceived);
UFUNCTION()
void CheckVersion(EServerVersionResponseType InType);
void ResetTime();
private:
float PlayAnimTime;// Play animation time
int32 LastDownloadSize;// Last downloaded size
float DownloadTime;// Download timekeeping
bool bReset;// Recapture download time
int32 PreSReceived;// How many bytes of data are downloaded per second
};
UI_HotUpdateMain.cpp
//Copyright (C) RenZhai.2022.All Rights Reserved.
#include "UI_HotUpdateMain.h"
#include "Components/TextBlock.h"
#include "Components/ProgressBar.h"
#include "Object/SimpleHotUpdateObject.h"
//#include "ThreadManage.h"
#include "Kismet/GameplayStatics.h"
#define LOCTEXT_NAMESPACE "UI_HotUpdateMain"
UUI_HotUpdateMain::UUI_HotUpdateMain(const FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer)
, PlayAnimTime(10.f)
, LastDownloadSize(0)
, DownloadTime(0.f)
, bReset(false)
, PreSReceived(0)
{
}
void UUI_HotUpdateMain::NativeConstruct()
{
Super::NativeConstruct();
VersionControlObject = UVersionControlObject::CreateObject(UVersionControlObject::StaticClass(), GetWorld());
if (VersionControlObject)
{
VersionControlObject->ProgressDelegate.BindUObject(this, &UUI_HotUpdateMain::Downloading);
VersionControlObject->VersionDelegate.BindUObject(this, &UUI_HotUpdateMain::CheckVersion);
VersionControlObject->InitVersion();
// Play prompt animation
PlayTipAnim();
}
}
void UUI_HotUpdateMain::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
{
Super::NativeTick(MyGeometry, InDeltaTime);
// Animation play
{
PlayAnimTime += InDeltaTime;
if (PlayAnimTime >= 10.f)
{
PlayAnimTime = 0.f;
PlayHotUpdateAnim();
}
}
// Time capture record
{
DownloadTime += InDeltaTime;
if (DownloadTime >= 1.f)
{
DownloadTime = 0.f;
ResetTime();
}
}
}
void UUI_HotUpdateMain::NativeDestruct()
{
Super::NativeDestruct();
}
void UUI_HotUpdateMain::Downloading(float InValue, const FString& InName, int32 TotalBytes, int32 BytesReceived)
{
// Need real-time display
if (DownLoadProgress)
{
// Print download progress
DownLoadProgress->SetPercent(InValue);
}
// Update the print display every second
if (bReset)
{
bReset = false;
FNumberFormattingOptions FormattingOptions;
FormattingOptions.MaximumFractionalDigits = 1;// After decimal point 1 position
if (DownloadedResourceName)
{
// Remove suffix
FString ContentName = InName;
ContentName.RemoveFromEnd(FPaths::GetExtension(ContentName, true));
// Print name
DownloadedResourceName->SetText(FText::FromString(ContentName));
}
if (DownloadDataSize)
{
// Print size
DownloadDataSize->SetText(
FText::Format(LOCTEXT("Downloading_DownloadDataSize", "{0} / {1}"),
FText::AsMemory(TotalBytes, &FormattingOptions),
FText::AsMemory(BytesReceived, &FormattingOptions)));
}
if (VersionControlObject)
{
bReset = false;
PreSReceived = BytesReceived - LastDownloadSize;
LastDownloadSize = BytesReceived;
DownloadSpeedText->SetText(FText::Format(LOCTEXT("Downloading_DownloadSpeed", "{0} / s"),
FText::AsMemory(PreSReceived, &FormattingOptions)));
// Set the version name
VersionName->SetText(FText::Format(LOCTEXT("Downloading_Version", "{0}->{1}"),
FText::FromString(VersionControlObject->GetClientVersionName()),
FText::FromString(VersionControlObject->GetServerVersionName())));
}
}
}
void UUI_HotUpdateMain::CheckVersion(EServerVersionResponseType InType)
{
if (InType == EServerVersionResponseType::EQUAL)
{
//GThread::Get()->GetCoroutines().BindLambda(2.f, [&]()
//{
// UGameplayStatics::OpenLevel(GetWorld(), TEXT("Login"));
//});
}
}
void UUI_HotUpdateMain::ResetTime()
{
bReset = true;
}
void UUI_HotUpdateMain::PlayHotUpdateAnim()
{
//if (UWidgetAnimation* InAnim = GetNameWidgetAnimation(TEXT("PlayAnimRenzhai")))
//{
// PlayAnimation(InAnim);
//}
}
void UUI_HotUpdateMain::PlayTipAnim()
{
//if (UWidgetAnimation* InAnim = GetNameWidgetAnimation(TEXT("TipAnim")))
//{
// PlayAnimation(InAnim);
//}
}
#undef LOCTEXT_NAMESPACE
5. Create a UMG The blueprint , Fill in the missing fonts according to the format
Fill in the contents of these warnings
6. Create a blueprint , Put this UI Paste to viewport
边栏推荐
- What is soda?
- Database SQL practice 3. Find the current salary details of the current leaders of each department and their corresponding department number Dept_ no
- Word import literature -mendeley
- [untitled]
- 氢氧化钠是什么?
- An article was opened to test the real situation of outsourcing companies
- 纯碱是做什么的?
- list. files: List the Files in a Directory/Folder
- I 用c l 栈与队列的相互实现
- Today, share the wonderful and beautiful theme of idea + website address
猜你喜欢
Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘
CADD课程学习(6)-- 获得已有的虚拟化合物库(Drugbank、ZINC)
C#学习笔记
[untitled]
When jupyter notebook is encountered, erroe appears in the name and is not output after running, but an empty line of code is added downward, and [] is empty
Anaconda navigator click open no response, can not start error prompt attributeerror: 'STR' object has no attribute 'get‘
2022 PMP project management examination agile knowledge points (7)
借助 Navicat for MySQL 软件 把 不同或者相同数据库链接中的某数据库表数据 复制到 另一个数据库表中
Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL
第 2 章:小试牛刀,实现一个简单的Bean容器
随机推荐
Basic series of SHEL script (III) for while loop
The golang timer uses the stepped pit: the timer is executed once a day
Unconventional ending disconnected from the target VM, address: '127.0.0.1:62635', transport: 'socket‘
Light up the running light, rough notes for beginners (1)
What if the DataGrid cannot see the table after connecting to the database
Netease to B, soft outside, hard in
M2dgr slam data set of multi-source and multi scene ground robot
借助 Navicat for MySQL 软件 把 不同或者相同数据库链接中的某数据库表数据 复制到 另一个数据库表中
UNIX commands often used in work
2022年PMP项目管理考试敏捷知识点(7)
Powermanagerservice (I) - initialization
Clickhouse database installation deployment and remote IP access
行测--资料分析--fb--高照老师
Unity ugui how to match and transform coordinates between different UI panels or uis
Binary search (half search)
Unforgettable summary of 2021
2022.06.27_每日一题
I 用c I 实现队列
Rough notes of C language (2) -- constants
The problem of configuring opencv in qt5.13.2 is solved in detail