Skip to content

Instantly share code, notes, and snippets.

@FilipSivak
FilipSivak / ue4_open_editor_utility_by_cpp.cpp
Created May 9, 2021 07:53
Unreal - open editor utility widget by C++
#include "EditorUtilityWidgetBlueprint.h"
#include "EditorUtilitySubsystem.h"
UObject * Blueprint = UEditorAssetLibrary::LoadAsset(FString(TEXT("EditorUtilityWidgetBlueprint'/Game/EditorUtilities/MyWidget.MyWidget'")));
if(IsValid(Blueprint)) {
UEditorUtilityWidgetBlueprint* EditorWidget = Cast<UEditorUtilityWidgetBlueprint>(Blueprint);
if (IsValid(EditorWidget)) {
UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>();
EditorUtilitySubsystem->SpawnAndRegisterTab(EditorWidget);
}
@FilipSivak
FilipSivak / MyBlueprintLibrary.cpp
Created August 5, 2021 08:37
Unreal engine open editor widget in asset editor with a button
#include "Editor/EditorEngine.h"
#include "Subsystems/AssetEditorSubsystem.h"
void UMyBlueprintLibrary::OpenWidgetInAssetEditor(UWidget * SelfWidget) {
if(IsValid(SelfWidget))
{
UObject * GeneratedBy = SelfWidget->WidgetGeneratedBy.Get();
if(IsValid(GeneratedBy))
{
UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
@FilipSivak
FilipSivak / struct_enum_unreal_engine_python.py
Created January 19, 2022 22:24
Struct and Enum in Unreal Engine python
# Example by Filip Sivak, written for https://filipsivak.medium.com/
import unreal
@unreal.uenum()
class MyPythonEnum(unreal.EnumBase):
FIRST = unreal.uvalue(0)
SECOND = unreal.uvalue(1)
FOURTH = unreal.uvalue(3)
@unreal.ustruct()
@FilipSivak
FilipSivak / pip_install_unreal.py
Last active December 7, 2022 13:23
Using pip install from Unreal Engine
import unreal
import subprocess
import pkg_resources
from pathlib import Path
PYTHON_INTERPRETER_PATH = unreal.get_interpreter_executable_path()
assert Path(PYTHON_INTERPRETER_PATH).exists(), f"Python not found at '{PYTHON_INTERPRETER_PATH}'"
def pip_install(packages):
# dont show window
@FilipSivak
FilipSivak / WindowResizeBlueprintLibrary.cpp
Created September 2, 2022 10:03
Prevent window resizing in Unreal Engine
bool UWindowResizeBlueprintLibrary::SetWindowNoResize(FText WindowName)
{
const TSharedPtr<SDockTab> ActiveTab = FGlobalTabmanager::Get()->GetActiveTab();
if(ActiveTab.IsValid())
{
const TSharedPtr<SWindow> Window = ActiveTab->GetParentWindow();
if(Window.IsValid() && Window->GetTitle().EqualTo(WindowName))
{
Window->SetSizingRule(ESizingRule::FixedSize);
return true;