Skip to content

Commit 2953432

Browse files
committed
Automatic patch for reimport rule [excluding *.json]
1 parent 343e66f commit 2953432

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Plugins/UnrealJS/Source/JavascriptEditor/JavascriptEditor.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#include "JavascriptEditorTick.h"
66
#include "IV8.h"
77
#include "ScopedTransaction.h"
8+
#if WITH_EDITOR
9+
#include "Settings/EditorLoadingSavingSettings.h"
10+
#endif
811

912
class FJavascriptEditorModule : public IJavascriptEditorModule
1013
{
@@ -47,9 +50,44 @@ void FJavascriptEditorModule::RemoveExtension(IEditorExtension* Extension)
4750
#endif
4851
}
4952

53+
#if WITH_EDITOR
54+
static void PatchReimportRule()
55+
{
56+
FAutoReimportWildcard WildcardToInject;
57+
WildcardToInject.Wildcard = TEXT("Scripts/**.json");
58+
WildcardToInject.bInclude = false;
59+
60+
auto Default = GetMutableDefault<UEditorLoadingSavingSettings>();
61+
bool bHasChanged = false;
62+
for (auto& Setting : Default->AutoReimportDirectorySettings)
63+
{
64+
bool bFound = false;
65+
for (const auto& Wildcard : Setting.Wildcards)
66+
{
67+
if (Wildcard.Wildcard == WildcardToInject.Wildcard)
68+
{
69+
bFound = true;
70+
break;
71+
}
72+
}
73+
if (!bFound)
74+
{
75+
Setting.Wildcards.Add(WildcardToInject);
76+
bHasChanged = true;
77+
}
78+
}
79+
if (bHasChanged)
80+
{
81+
Default->PostEditChange();
82+
}
83+
}
84+
#endif
85+
5086
void FJavascriptEditorModule::StartupModule()
5187
{
5288
#if WITH_EDITOR
89+
PatchReimportRule();
90+
5391
auto Isolate = NewObject<UJavascriptIsolate>();
5492
auto Context = Isolate->CreateContext();
5593

0 commit comments

Comments
 (0)