添加ReactUMG插件

搭建TS环境
This commit is contained in:
2024-12-13 15:34:14 +08:00
parent 1d64e61b15
commit bed8becdf4
26 changed files with 1180 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
#include "FMCJsEnvManager.h"
#include "JsEnv.h"
void FMCJsEnvManager::Init(TObjectPtr<UGameInstance> GameInstance)
{
M_GameInstance = GameInstance;
//TODO:从PuertsSettings获取是否开启Debug,是否阻塞,端口号等信息
//8080是调试端口
M_JsEnv = MakeShared<puerts::FJsEnv>(std::make_unique<puerts::DefaultJSModuleLoader>(TEXT("JavaScript")), std::make_shared<puerts::FDefaultLogger>(), 8080);
//M_JsEnv->WaitDebugger();
TArray<TPair<FString, UObject*>> Arguments;
Arguments.Add(TPair<FString, UObject*>(TEXT("GameInstance"), GameInstance)); // 可选步骤
M_JsEnv->Start("entry.js", Arguments);
//GameScript = MakeShared<puerts::FJsEnv>(std::make_unique<puerts::DefaultJSModuleLoader>(TEXT("JavaScript")), std::make_shared<puerts::FDefaultLogger>(), 8080);
}
void FMCJsEnvManager::Release()
{
M_JsEnv.Reset();
}
+16
View File
@@ -0,0 +1,16 @@
#pragma once
namespace puerts
{
class FJsEnv;
}
class FMCJsEnvManager
{
public:
void Init(TObjectPtr<UGameInstance> GameInstance);
void Release();
private:
TObjectPtr<UGameInstance> M_GameInstance;
TSharedPtr<puerts::FJsEnv> M_JsEnv;
};
+18
View File
@@ -0,0 +1,18 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MingGameInstance.h"
void UMingGameInstance::Init()
{
Super::Init();
M_JsEnvManager = MakeShared<FMCJsEnvManager>(FMCJsEnvManager());
M_JsEnvManager->Init(this);
}
void UMingGameInstance::Shutdown()
{
M_JsEnvManager->Release();
Super::Shutdown();
}
+22
View File
@@ -0,0 +1,22 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "FMCJsEnvManager.h"
#include "Kismet/BlueprintPlatformLibrary.h"
#include "MingGameInstance.generated.h"
/**
*
*/
UCLASS()
class MINGSIMULATOR_API UMingGameInstance : public UPlatformGameInstance
{
GENERATED_BODY()
public:
virtual void Init() override;
virtual void Shutdown() override;
private:
TSharedPtr<FMCJsEnvManager> M_JsEnvManager;
};
+1 -1
View File
@@ -8,6 +8,6 @@ public class MingSimulator : ModuleRules
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "Niagara", "EnhancedInput" });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "Niagara", "EnhancedInput","JsEnv" });
}
}