77#include " EcsactEditor.h"
88#include " Async/Async.h"
99#include " Async/TaskGraphInterfaces.h"
10+ #include " Interfaces/IPluginManager.h"
1011#include " CoreGlobals.h"
1112#include " EcsactUnreal/Ecsact.h"
1213#include " Editor.h"
@@ -89,26 +90,61 @@ static auto PlatformEcsactPluginExtension() -> FString {
8990 return TEXT (" " );
9091}
9192
92- static auto PluginBinariesDir () -> FString {
93- auto & fm = FPlatformFileManager::Get ().GetPlatformFile ();
94- auto plugins_dir = FPaths::ProjectPluginsDir ();
95- auto plugin_dir = plugins_dir + " /" + " Ecsact" ;
96-
97- return FPaths::Combine ( //
98- FPaths::ProjectPluginsDir (),
99- " Ecsact" ,
100- " Binaries" ,
101- PlatformBinariesDirname ()
102- );
103- }
104-
10593static auto GetDirectoryWatcher () -> IDirectoryWatcher* {
10694 auto & watcher = FModuleManager::LoadModuleChecked<FDirectoryWatcherModule>( //
10795 TEXT (" DirectoryWatcher" )
10896 );
10997 return watcher.Get ();
11098}
11199
100+ auto FEcsactEditorModule::GetInstalledPluginDir () -> FString {
101+ auto Plugin = IPluginManager::Get ().FindPlugin (TEXT (" Ecsact" ));
102+ if (Plugin.IsValid ()) {
103+ return Plugin->GetBaseDir ();
104+ }
105+ return FString{};
106+ }
107+
108+ auto FEcsactEditorModule::GetEcsactSdkBinaryPath ( //
109+ FString BinaryName
110+ ) -> FString {
111+ auto plugin_install_dir = GetInstalledPluginDir ();
112+ if (plugin_install_dir.IsEmpty ()) {
113+ return BinaryName;
114+ }
115+
116+ auto ecsact_sdk_dir = FPaths::Combine ( //
117+ plugin_install_dir,
118+ " Source" ,
119+ " ThirdParty" ,
120+ " EcsactSDK"
121+ );
122+ if (!FPaths::DirectoryExists (ecsact_sdk_dir)) {
123+ return BinaryName;
124+ }
125+
126+ #ifdef _WIN32
127+ FString exe_suffix = " .exe" ;
128+ #else
129+ FString exe_suffix = " " ;
130+ #endif
131+
132+ auto binary_path = FPaths::Combine ( //
133+ ecsact_sdk_dir,
134+ " bin" ,
135+ BinaryName + exe_suffix
136+ );
137+ if (!FPaths::FileExists (binary_path)) {
138+ return BinaryName;
139+ }
140+
141+ return binary_path;
142+ }
143+
144+ auto FEcsactEditorModule::GetEcsactCli () -> FString {
145+ return GetEcsactSdkBinaryPath (" ecsact" );
146+ }
147+
112148auto FEcsactEditorModule::SpawnEcsactCli (
113149 const TArray<FString>& Args,
114150 FOnReceiveLine OnReceiveLine,
@@ -123,7 +159,7 @@ auto FEcsactEditorModule::SpawnEcsactCli(
123159
124160 AsyncTask (
125161 ENamedThreads::AnyBackgroundThreadNormalTask,
126- [=, OnExit = std::move (OnExit)] {
162+ [=, this , OnExit = std::move (OnExit)] {
127163 void * PipeWriteChild;
128164 void * PipeReadChild;
129165 void * PipeWriteParent;
@@ -133,7 +169,7 @@ auto FEcsactEditorModule::SpawnEcsactCli(
133169
134170 auto proc_id = uint32{};
135171 auto proc_handle = FPlatformProcess::CreateProc (
136- TEXT ( " ecsact " ),
172+ * GetEcsactCli ( ),
137173 *args_str,
138174 false ,
139175 true ,
@@ -263,12 +299,7 @@ auto FEcsactEditorModule::ShutdownModule() -> void {
263299 SourceDir (),
264300 SourcesWatchHandle
265301 );
266- watcher->UnregisterDirectoryChangedCallback_Handle (
267- PluginBinariesDir (),
268- PluginBinariesWatchHandle
269- );
270302 SourcesWatchHandle = {};
271- PluginBinariesWatchHandle = {};
272303 FEditorDelegates::OnEditorInitialized.RemoveAll (this );
273304}
274305
@@ -396,7 +427,6 @@ auto FEcsactEditorModule::OnAssetsRemoved( //
396427}
397428
398429auto FEcsactEditorModule::OnAssetRegistryFilesLoaded () -> void {
399- UE_LOG (LogTemp, Log, TEXT (" OnAssetRegistryFilesLoaded" ));
400430}
401431
402432auto FEcsactEditorModule::AddMenuEntry (FMenuBuilder& MenuBuilder) -> void {
0 commit comments