[UE4]Editor Extention and Programming
Keywords: UE4, Editor Extention and Programming
Documents
UE4 - Easy example of How to create menus in the editor
http://www.danielmayor.com/ue4-simple-menus
Creating an Editor Module
https://wiki.unrealengine.com/Creating_an_Editor_Module
Customizing the editor’s toolbar buttons menu via custom plugin
https://answers.unrealengine.com/questions/25609/customizing-the-editors-toolbar-buttons-menu-via-c.html
UE4 Editor Toolbar Extention
https://blog.csdn.net/hui211314ddhui/article/details/79375548
batch operations with editor utility blueprints in UE4
https://www.youtube.com/watch?v=5Ty_rQp34PQ
Editor Programming Related
How to set display index / order of property in Editor
e.g.
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayPriority = "1"))
int32 Value1 = -1;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayPriority = "2"))
int32 Value1 = -1;
Reference:
Metadata Specifiers
https://docs.unrealengine.com/en-US/Programming/UnrealArchitecture/Reference/Metadata/index.html
Editor Event
Properties changed event
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
Actor moved event
#if WITH_EDITOR
/** Called after an actor has been moved in the editor */
virtual void PostEditMove(bool bFinished);
#endif
How to customize Transform of Actor in Editor
Header: Add VisibleAnywhere
on properties.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = CameraEvent)
UBoxComponent* BoxComp;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = CameraEvent)
UArrowComponent* DirectionComp;
Constructor:
BoxComp = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxComp"));
BoxComp->SetupAttachment(GetDefaultAttachComponent());
DirectionComp = CreateDefaultSubobject<UArrowComponent>(TEXT("TriggerDirectionComp"));
DirectionComp->SetupAttachment(BoxComp);
In Bluerpint Editor:
In Level Editor:
In Bluerpint Editor, you can’t modify Location and Rotation of RootComponent, but you can modify them in Level Editor.
How to spawn actor in Editor
example:
AActor* newActor = GEditor->AddActor(
GEditor->LevelViewportClients[0]->GetWorld()->GetCurrentLevel(), AMyActorClass, MyTransform);
// modify properties on newActor
newActor->RerunConstructionScripts();
How to creat editor widget using C++
UE4 – C++ Editor Utility Widgets (4.22)
https://isaratech.com/ue4-c-editor-utility-widgets-4-22/
Issue:
Blueprint EditorUtilityWidget
Can’t inherit custom cpp class.
Solution:
Modify MyPlugin.uplugin
.
Origin:
"Modules": [
{
"Name": "MyExtender",
"Type": "Runtime",
"LoadingPhase": "Default"
}
]
New:
"Modules": [
{
"Name": "CppEditorWidget",
"Type": "Editor",
"LoadingPhase": "PostEngineInit"
}
]
Then delete all intermediate files and re-generate project files.
How to open the Windows file explorer (open directory dialog) to select the file
void UMyUserWidget::OnTestBtnClicked()
{
TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(TakeWidget());
void* ParentWindowHandle = (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid()) ? ParentWindow->GetNativeWindow()->GetOSWindowHandle() : nullptr;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (DesktopPlatform)
{
const FString ContentDireAbsolute = FPaths::ConvertRelativePathToFull(FPaths::ProjectConfigDir());
FString OutDire;
DesktopPlatform->OpenDirectoryDialog(ParentWindowHandle, TEXT("Choose Folder"), ContentDireAbsolute, OutDire);
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Cyan, OutDire);
}
}
Select files dialog:
/*
* Opens a file dialog for the specified data. Leave FileTypes empty to be able to select any files.
* Filetypes must be in the format of: <File type Description>|*.<actual extension>
* You can combine multiple extensions by placing ";" between them
* For example: Text Files|*.txt|Excel files|*.csv|Image Files|*.png;*.jpg;*.bmp will display 3 lines for 3 different type of files.
*/
TArray<FString> OutFileNames;
//Opening the file picker!
uint32 SelectionFlag = 0; //A value of 0 represents single file selection while a value of 1 represents multiple file selection
DesktopPlatform->OpenFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, FString(""), FileTypes, SelectionFlag, OutFileNames);
Reference
https://www.orfeasel.com/creating-a-file-picker/
Testing & Optimization
Testing Automation
Automation System Overview, Overview of the automation system used for unit testing, feature testing, and content stress testing.
https://docs.unrealengine.com/4.27/en-US/TestingAndOptimization/Automation/
静水流深(Still Water Runs Deep) ---拉丁谚语