@@ -50,6 +50,43 @@ private string ScriptsPath
5050 get { return Path . GetFullPath ( Path . Combine ( ModuleDirectory , "../../Content/Scripts/" ) ) ; }
5151 }
5252
53+ public string GetUProjectPath ( )
54+ {
55+ return Path . Combine ( ModuleDirectory , "../../../.." ) ;
56+ }
57+
58+ private void CopyToProjectBinaries ( string Filepath , ReadOnlyTargetRules Target )
59+ {
60+ //System.Console.WriteLine("uprojectpath is: " + Path.GetFullPath(GetUProjectPath()));
61+
62+ string BinariesDir = Path . Combine ( GetUProjectPath ( ) , "Binaries" , Target . Platform . ToString ( ) ) ;
63+ string Filename = Path . GetFileName ( Filepath ) ;
64+
65+ //convert relative path
66+ string FullBinariesDir = Path . GetFullPath ( BinariesDir ) ;
67+
68+ if ( ! Directory . Exists ( FullBinariesDir ) )
69+ {
70+ Directory . CreateDirectory ( FullBinariesDir ) ;
71+ }
72+
73+ string FullExistingPath = Path . Combine ( FullBinariesDir , Filename ) ;
74+ bool ValidFile = false ;
75+
76+ //File exists, check if they're the same
77+ if ( File . Exists ( FullExistingPath ) )
78+ {
79+ ValidFile = true ;
80+ }
81+
82+ //No valid existing file found, copy new dll
83+ if ( ! ValidFile )
84+ {
85+ File . Copy ( Filepath , Path . Combine ( FullBinariesDir , Filename ) , true ) ;
86+ }
87+ }
88+
89+
5390 public void AddRuntimeDependenciesForCopying ( ReadOnlyTargetRules Target )
5491 {
5592 if ( ( Target . Platform == UnrealTargetPlatform . Win64 ) || ( Target . Platform == UnrealTargetPlatform . Win32 ) )
@@ -88,8 +125,18 @@ public void AddRuntimeDependenciesForCopying(ReadOnlyTargetRules Target)
88125 }
89126 }
90127 }
91- }
92- }
128+
129+ //Copy the thirdparty dll so ue4 loads it by default
130+ string DLLName = PythonType . ToLower ( ) + ".dll" ;
131+ string PluginDLLPath = Path . Combine ( BinariesPath , PlatformString , DLLName ) ;
132+ CopyToProjectBinaries ( PluginDLLPath , Target ) ;
133+
134+ //After it's been copied add it as a dependency so it gets copied on packaging
135+ string DLLPath = Path . GetFullPath ( Path . Combine ( GetUProjectPath ( ) , "Binaries" , PlatformString , DLLName ) ) ;
136+ RuntimeDependencies . Add ( DLLPath ) ;
137+
138+ } //end if thirdparty
139+ } //end windows
93140 }
94141
95142 private string [ ] windowsKnownPaths =
0 commit comments