Skip to content

Commit b82f439

Browse files
修改:移除一些UE5的编译警告
1 parent d6ff0d7 commit b82f439

File tree

13 files changed

+63
-18
lines changed

13 files changed

+63
-18
lines changed

Plugins/UnLua/Source/UnLua/Private/DefaultParamCollection.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
// See the License for the specific language governing permissions and limitations under the License.
1414

1515
#include "DefaultParamCollection.h"
16+
#include "Misc/EngineVersionComparison.h"
1617
#include "CoreUObject.h"
1718

1819
TMap<FName, FFunctionCollection> GDefaultParamCollection;
1920

21+
#if UE_VERSION_OLDER_THAN(5, 2, 0)
2022
PRAGMA_DISABLE_OPTIMIZATION
23+
#else
24+
UE_DISABLE_OPTIMIZATION
25+
#endif
2126

2227
void CreateDefaultParamCollection()
2328
{
@@ -30,4 +35,8 @@ void CreateDefaultParamCollection()
3035
}
3136
}
3237

38+
#if UE_VERSION_OLDER_THAN(5, 2, 0)
3339
PRAGMA_ENABLE_OPTIMIZATION
40+
#else
41+
UE_ENABLE_OPTIMIZATION
42+
#endif

Plugins/UnLua/Source/UnLua/Private/DefaultParamCollection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#pragma once
1616

1717
#include "CoreMinimal.h"
18+
#include "UnLuaCompatibility.h"
1819

1920
class IParamValue
2021
{
@@ -53,7 +54,7 @@ class FRuntimeEnumParamValue : public IParamValue
5354
{
5455
if (!bInitialized)
5556
{
56-
UEnum* Enum = FindObjectChecked<UEnum>(ANY_PACKAGE, *TypeName);
57+
UEnum* Enum = FindFirstObject<UEnum>(*TypeName);
5758
Value = Enum->GetValueByIndex(Index);
5859
bInitialized = true;
5960
}

Plugins/UnLua/Source/UnLua/Private/ReflectionUtils/ClassDesc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
// See the License for the specific language governing permissions and limitations under the License.
1414

15+
#include "UnLuaCompatibility.h"
1516
#include "ClassDesc.h"
1617
#include "FieldDesc.h"
1718
#include "PropertyDesc.h"
@@ -163,7 +164,7 @@ void FClassDesc::Load()
163164
UnLoad();
164165

165166
FString Name = (ClassName[0] == 'U' || ClassName[0] == 'A' || ClassName[0] == 'F') ? ClassName.RightChop(1) : ClassName;
166-
UStruct* Found = FindObject<UStruct>(ANY_PACKAGE, *Name);
167+
UStruct* Found = FindFirstObject<UStruct>(*Name);
167168
if (!Found)
168169
Found = LoadObject<UStruct>(nullptr, *Name);
169170

Plugins/UnLua/Source/UnLua/Private/ReflectionUtils/EnumDesc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
// See the License for the specific language governing permissions and limitations under the License.
1414

15+
#include "UnLuaCompatibility.h"
1516
#include "EnumDesc.h"
1617
#include "LowLevel.h"
1718

@@ -28,7 +29,7 @@ void FEnumDesc::Load()
2829
if (Enum.IsValid())
2930
return;
3031

31-
Enum = FindObject<UEnum>(ANY_PACKAGE, *EnumName);
32+
Enum = FindFirstObject<UEnum>(*EnumName);
3233
if (!Enum.IsValid())
3334
Enum = LoadObject<UEnum>(nullptr, *EnumName);
3435

Plugins/UnLua/Source/UnLua/Private/Registries/ClassRegistry.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// See the License for the specific language governing permissions and limitations under the License.
1414

1515
#include "Registries/ClassRegistry.h"
16+
#include "UnLuaCompatibility.h"
1617
#include "LuaEnv.h"
1718
#include "Binding.h"
1819
#include "LowLevel.h"
@@ -280,11 +281,11 @@ namespace UnLua
280281
FString Name = UTF8_TO_TCHAR(InName);
281282

282283
// find candidates in memory
283-
UField* Ret = FindObject<UClass>(ANY_PACKAGE, *Name);
284+
UField* Ret = FindFirstObject<UClass>(*Name);
284285
if (!Ret)
285-
Ret = FindObject<UScriptStruct>(ANY_PACKAGE, *Name);
286+
Ret = FindFirstObject<UScriptStruct>(*Name);
286287
if (!Ret)
287-
Ret = FindObject<UEnum>(ANY_PACKAGE, *Name);
288+
Ret = FindFirstObject<UEnum>(*Name);
288289

289290
// load candidates if not found
290291
if (!Ret)

Plugins/UnLua/Source/UnLua/Private/Registries/PropertyRegistry.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Misc/EngineVersionComparison.h"
2+
#include "UnLuaCompatibility.h"
23
#include "PropertyRegistry.h"
34
#include "Binding.h"
45
#include "ClassRegistry.h"
@@ -12,7 +13,7 @@ namespace UnLua
1213
FPropertyRegistry::FPropertyRegistry(FLuaEnv* Env)
1314
: Env(Env)
1415
{
15-
PropertyCollector = FindObject<UScriptStruct>(ANY_PACKAGE, TEXT("PropertyCollector"));
16+
PropertyCollector = FindFirstObject<UScriptStruct>(TEXT("PropertyCollector"));
1617
check(PropertyCollector);
1718
}
1819

Plugins/UnLua/Source/UnLua/Private/UnLuaCompatibility.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "CoreUObject.h"
1818
#include "Runtime/Launch/Resources/Version.h"
19+
#include "Misc/EngineVersionComparison.h"
1920

2021
#if ENGINE_MAJOR_VERSION <= 4 && ENGINE_MINOR_VERSION < 19
2122
#define DEFINE_FUNCTION(func) void func( FFrame& Stack, RESULT_DECL )
@@ -152,3 +153,13 @@ struct TMulticastDelegateTraits<FMulticastScriptDelegate>
152153
return (FMulticastScriptDelegate*)PropertyValue;
153154
}
154155
};
156+
157+
#if UE_VERSION_OLDER_THAN(5, 1, 0)
158+
159+
template< class T >
160+
inline T* FindFirstObject(const TCHAR* Name)
161+
{
162+
return FindObject<T>(ANY_PACKAGE, Name);
163+
}
164+
165+
#endif

Plugins/UnLua/Source/UnLua/Private/UnLuaDebugBase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
// See the License for the specific language governing permissions and limitations under the License.
1414

15-
#include "Misc/EngineVersionComparison.h"
15+
#include "UnLuaCompatibility.h"
1616
#include "UnLuaDebugBase.h"
1717
#include "Containers/LuaSet.h"
1818
#include "Containers/LuaMap.h"
@@ -227,7 +227,7 @@ namespace UnLua
227227
if (ClassNamePtr)
228228
{
229229
FString ClassName(ClassNamePtr);
230-
UStruct *Struct = FindObject<UStruct>(ANY_PACKAGE, *ClassName + 1);
230+
UStruct *Struct = FindFirstObject<UStruct>(*ClassName + 1);
231231
if (Struct)
232232
{
233233
// the userdata is a struct instance

Plugins/UnLua/Source/UnLuaEditor/Private/Toolbars/UnLuaEditorToolbar.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#include "UnLuaPrivate.h"
1+
#include "Misc/EngineVersionComparison.h"
2+
#include "UnLuaPrivate.h"
23
#include "UnLuaEditorCore.h"
34
#include "UnLuaEditorToolbar.h"
45
#include "UnLuaEditorCommands.h"
@@ -147,7 +148,11 @@ void FUnLuaEditorToolbar::BindToLua_Executed() const
147148
if (TargetClass->ImplementsInterface(UUnLuaInterface::StaticClass()))
148149
return;
149150

151+
#if UE_VERSION_OLDER_THAN(5, 1, 0)
150152
const auto Ok = FBlueprintEditorUtils::ImplementNewInterface(Blueprint, FName("UnLuaInterface"));
153+
#else
154+
const auto Ok = FBlueprintEditorUtils::ImplementNewInterface(Blueprint, FTopLevelAssetPath(UUnLuaInterface::StaticClass()));
155+
#endif
151156
if (!Ok)
152157
return;
153158

@@ -178,7 +183,7 @@ void FUnLuaEditorToolbar::BindToLua_Executed() const
178183
InterfaceDesc.Graphs[0]->Nodes[1]->Pins[1]->DefaultValue = LuaModuleName;
179184
}
180185

181-
#if ENGINE_MAJOR_VERSION > 4 || (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 26)
186+
#if !UE_VERSION_OLDER_THAN(4, 26, 0)
182187

183188
const auto BlueprintEditors = FModuleManager::LoadModuleChecked<FBlueprintEditorModule>("Kismet").GetBlueprintEditors();
184189
for (auto BlueprintEditor : BlueprintEditors)
@@ -209,9 +214,13 @@ void FUnLuaEditorToolbar::UnbindFromLua_Executed() const
209214
if (!TargetClass->ImplementsInterface(UUnLuaInterface::StaticClass()))
210215
return;
211216

217+
#if UE_VERSION_OLDER_THAN(5, 1, 0)
212218
FBlueprintEditorUtils::RemoveInterface(Blueprint, FName("UnLuaInterface"));
219+
#else
220+
FBlueprintEditorUtils::RemoveInterface(Blueprint, FTopLevelAssetPath(UUnLuaInterface::StaticClass()));
221+
#endif
213222

214-
#if ENGINE_MAJOR_VERSION > 4 || (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 26)
223+
#if !UE_VERSION_OLDER_THAN(4, 26, 0)
215224

216225
const auto BlueprintEditors = FModuleManager::LoadModuleChecked<FBlueprintEditorModule>("Kismet").GetBlueprintEditors();
217226
for (auto BlueprintEditor : BlueprintEditors)

Plugins/UnLua/Source/UnLuaEditor/Private/UnLuaAboutScreen.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// See the License for the specific language governing permissions and limitations under the License.
1414

1515
#include "UnLuaAboutScreen.h"
16+
#include "Misc/EngineVersionComparison.h"
1617
#include "Widgets/SBoxPanel.h"
1718
#include "Widgets/SOverlay.h"
1819
#include "Widgets/SWindow.h"
@@ -63,7 +64,11 @@ void SUnLuaAboutScreen::Construct(const FArguments& InArgs)
6364
.Padding(FMargin(10.f, 10.f, 0.f, 0.f))
6465
[
6566
SAssignNew(LogoButton, SButton)
67+
#if UE_VERSION_OLDER_THAN(5, 1, 0)
6668
.ButtonStyle(FEditorStyle::Get(), "NoBorder")
69+
#else
70+
.ButtonStyle(FAppStyle::Get(), "NoBorder")
71+
#endif
6772
.OnClicked(this, &SUnLuaAboutScreen::OnLogoButtonClicked)
6873
[
6974
SNew(SImage).Image(FUnLuaEditorStyle::GetInstance()->GetBrush("UnLuaEditor.UnLuaLogo"))

0 commit comments

Comments
 (0)