I am new to unreal (Just over 2 weeks) but not programming and recently made the switch from unity. The editor programming is a black box despite visible code from the source file. I have spent 2 days going through every bit of my code and it is identical to all the samples that inspired it but no result.
The code is structured the same way as the online learning tutorial on plugin best practices, I was able to re-implement that tutorial with extra features no problem but my attempts at creating a viewport has been disastrous.
Debugging the program shows that this is where all the madness happens
TSharedPtr<FExtender> FExtensibilityManager::GetAllExtenders(const TSharedRef<FUICommandList>& CommandList, const TArray<UObject*>& ContextSensitiveObjects)
{
auto OutExtenders = Extenders;
for (int32 i = 0; i < ExtenderDelegates.Num(); ++i)
{
if (ExtenderDelegates*.IsBound())
{
OutExtenders.Add(ExtenderDelegates*.Execute(CommandList, ContextSensitiveObjects)); // <-- here delegates are nomally call
}
}
return FExtender::Combine(OutExtenders);
}
Register
void FMotionSetEditorToolkit::RegisterTabSpawners(const TSharedRef<FTabManager>& InTabManager)
{
WorkspaceMenuCategory = InTabManager->AddLocalWorkspaceMenuCategory(LOCTEXT("WorkspaceMenu_MotionSetEditor", "MotionSet Editor"));
auto WorkspaceMenuCategoryRef = WorkspaceMenuCategory.ToSharedRef();
FAssetEditorToolkit::RegisterTabSpawners(InTabManager);
InTabManager->RegisterTabSpawner(MotionSetEditor::Tabs::ViewportID, FOnSpawnTab::CreateSP(this, &FMotionSetEditorToolkit::SpawnTab_Viewport))
.SetDisplayName(LOCTEXT("ViewportTab", "Viewport"))
.SetGroup(WorkspaceMenuCategoryRef)
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.Viewports"));
InTabManager->RegisterTabSpawner(MotionSetEditor::Tabs::DetailsID, FOnSpawnTab::CreateSP(this, &FMotionSetEditorToolkit::SpawnTab_Details))
.SetDisplayName(LOCTEXT("DetailsTabLabel", "Details"))
.SetGroup(WorkspaceMenuCategoryRef)
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.ContentBrowser"));
/*
//Allternative
InTabManager->RegisterTabSpawner(MotionSetEditor::Tabs::ViewportID, FOnSpawnTab::CreateSP(this, &FMotionSetEditorToolkit::SpawnTab_Viewport, MotionSetEditor::Tabs::ViewportID))
.SetDisplayName(LOCTEXT("ViewportTab", "Viewport"))
.SetGroup(WorkspaceMenuCategoryRef)
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.Viewports"));
InTabManager->RegisterTabSpawner(MotionSetEditor::Tabs::DetailsID, FOnSpawnTab::CreateSP(this, &FMotionSetEditorToolkit::SpawnTab_Details, MotionSetEditor::Tabs::DetailsID))
.SetDisplayName(LOCTEXT("DetailsTabLabel", "Details"))
.SetGroup(WorkspaceMenuCategoryRef)
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.ContentBrowser"));
*/
}
Initialize
void FMotionSetEditorToolkit::Initialize(UMotionSet* InMotionSet, const EToolkitMode::Type InMode, const TSharedPtr<IToolkitHost>& InToolkitHost)
{
// Ensure asset exclusivity
FAssetEditorManager::Get().CloseOtherEditors(InMotionSet, this);
MotionSet = InMotionSet;
// ?
CurrentExtractionContextIndex = INDEX_NONE;
// Support undo/redo
//RF_Standalone Keep object around for editing even if unreferenced.
//MotionSet->SetFlags(RF_Transactional); // We set this already in CreateNew
//GEditor->RegisterForUndo(this);
FMotionSetEditorCommands::Register();
BindCommands();
TSharedPtr<FMotionSetEditorToolkit> MotionSetEditorPtr = SharedThis(this);
ViewportPtr = SNew(SMotionSetEditorViewport, MotionSetEditorPtr).MotionSet(this, &FMotionSetEditorToolkit::GetMotionSetBeingEdited);
// create Default tab layout
const TSharedRef<FTabManager::FLayout> Layout = FTabManager::NewLayout("Standalone_MotionSetEditor")
->AddArea
(
FTabManager::NewPrimaryArea()
->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.1f)
->SetHideTabWell(true)
->AddTab(GetToolbarTabId(), ETabState::OpenedTab)
)
->Split
(
FTabManager::NewSplitter()
->SetOrientation(Orient_Horizontal)
->SetSizeCoefficient(0.9f)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(1.f)
->SetHideTabWell(true)
->AddTab(MotionSetEditor::Tabs::ViewportID, ETabState::OpenedTab)
)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.75f)
->SetHideTabWell(true)
->AddTab(MotionSetEditor::Tabs::DetailsID, ETabState::OpenedTab)
)
)
);
//Frustration hack to force generation, doesnt work
//TSharedRef<class FGlobalTabmanager> tm = FGlobalTabmanager::Get();
//tm->InvokeTab(MotionSetEditor::Tabs::ViewportID);
//tm->InvokeTab(MotionSetEditor::Tabs::DetailsID);
// Initialize the asset editor and spawn nothing (dummy layout)
FAssetEditorToolkit::InitAssetEditor(
InMode,
InToolkitHost,
MotionSetEditor::AppIdentifier,
Layout, // The Slate us we created above
true /*bCreateDefaultStandaloneMenu*/,
true /*bCreateDefaultToolbar*/,
InMotionSet
);
//const FSpawnTabArgs* Dummy = nullptr;
//SpawnTab_Viewport(*Dummy);
//SpawnTab_Details(*Dummy);
// Extend things
ExtendMenu();
ExtendToolbar();
RegenerateMenusAndToolbars();
if(TagTimelineBoxPtr)
RebuildTagTimelines();
}