Skip to content

Commit ace4295

Browse files
author
Roberto De Ioris
committed
changed plugin icon
1 parent 7e0ce3d commit ace4295

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

Resources/Icon128.png

-3.43 KB
Loading

Resources/python128.png

-8.97 KB
Binary file not shown.
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
#include "UnrealEnginePythonPrivatePCH.h"
22

33
#include "PythonScriptFactory.h"
4+
#include "PythonScript.h"
45

56
UPythonScriptFactory::UPythonScriptFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
6-
bCreateNew = true;
7+
8+
Formats.Add(FString("py;Python Script"));
9+
10+
bCreateNew = false;
711
bEditAfterNew = true;
12+
13+
bEditorImport = true;
14+
815
SupportedClass = UPythonScript::StaticClass();
916
}
1017

11-
UObject* UPythonScriptFactory::FactoryCreateNew(UClass * Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) {
12-
UPythonScript *NewAsset = NewObject<UPythonScript>(InParent, Class, Name, Flags);
18+
UObject* UPythonScriptFactory::FactoryCreateFile(UClass * Class, UObject *InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext *Warn, bool& bOutOperationCanceled) {
19+
UPythonScript *NewAsset = NewObject<UPythonScript>(InParent, Class, InName, Flags);
20+
21+
NewAsset->ScriptPath = Filename;
1322

23+
bOutOperationCanceled = false;
1424
return NewAsset;
1525
}

Source/UnrealEnginePython/Private/UnrealEnginePython.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ void FUnrealEnginePythonModule::StartupModule()
125125

126126
PyEval_InitThreads();
127127

128+
StyleSet = MakeShareable(new FSlateStyleSet("UnrealEnginePython"));
129+
StyleSet->SetContentRoot(IPluginManager::Get().FindPlugin("UnrealEnginePython")->GetBaseDir() / "Resources");
130+
StyleSet->Set("ClassThumbnail.PythonScript", new FSlateImageBrush(StyleSet->RootToContentDir("Icon128.png"), FVector2D(128.0f, 128.0f)));
131+
FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get());
132+
#if ENGINE_MINOR_VERSION < 13
133+
FClassIconFinder::RegisterIconSource(StyleSet.Get());
134+
#endif
135+
128136
UESetupPythonInterpreter(true);
129137

130138
main_module = PyImport_AddModule("__main__");

Source/UnrealEnginePython/Public/PythonScript.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ class UPythonScript : public UObject
1111
public:
1212

1313
UPROPERTY(EditAnywhere, Category = "Python")
14-
FString PyScript;
15-
16-
UPROPERTY(EditAnywhere, meta=(MultiLine), Category = "Python")
17-
FString PyCode;
14+
FString ScriptPath;
1815
};
1916

Source/UnrealEnginePython/Public/PythonScriptFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class UPythonScriptFactory : public UFactory
88
{
99
GENERATED_UCLASS_BODY()
1010

11-
virtual UObject* FactoryCreateNew(UClass * Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override;
11+
virtual UObject* FactoryCreateFile(UClass * Class, UObject *InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext *Warn, bool& bOutOperationCanceled) override;
1212
};
1313

Source/UnrealEnginePython/Public/UnrealEnginePython.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "ModuleManager.h"
66

7+
#include "Runtime/SlateCore/Public/Styling/SlateStyle.h"
8+
79
DECLARE_LOG_CATEGORY_EXTERN(LogPython, Log, All);
810

911

@@ -28,6 +30,8 @@ class UNREALENGINEPYTHON_API FUnrealEnginePythonModule : public IModuleInterface
2830
void *main_dict;
2931
void *local_dict;
3032
void *main_module;
33+
34+
TSharedPtr<FSlateStyleSet> StyleSet;
3135
};
3236

3337
struct FScopePythonGIL {

0 commit comments

Comments
 (0)