本文整理汇总了C++中TWeakPtr::Pin方法的典型用法代码示例。如果您正苦于以下问题:C++ TWeakPtr::Pin方法的具体用法?C++ TWeakPtr::Pin怎么用?C++ TWeakPtr::Pin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TWeakPtr
的用法示例。
在下文中一共展示了TWeakPtr::Pin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnValueCommitted
void FMarginStructCustomization::OnValueCommitted( float NewValue, ETextCommit::Type CommitType, int32 PropertyIndex )
{
TWeakPtr<IPropertyHandle> WeakHandlePtr = ChildPropertyHandles[ PropertyIndex ];
WeakHandlePtr.Pin()->SetValue( NewValue );
}
示例2: ImportFBXChunks
void FDestructibleMeshEditorViewportClient::ImportFBXChunks()
{
// Get the FBX that we want to import
TArray<FString> OpenFilenames;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bOpened = false;
if (DesktopPlatform != NULL)
{
bOpened = DesktopPlatform->OpenFileDialog(
NULL,
NSLOCTEXT("UnrealEd", "ImportMatineeSequence", "Import UnrealMatinee Sequence").ToString(),
*(FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_IMPORT)),
TEXT(""),
TEXT("FBX document|*.fbx"),
EFileDialogFlags::None,
OpenFilenames);
}
if (bOpened)
{
// Get the filename from dialog
FString ImportFilename = OpenFilenames[0];
FString FileName = OpenFilenames[0];
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_IMPORT, FPaths::GetPath(FileName)); // Save path as default for next time.
const FString FileExtension = FPaths::GetExtension(FileName);
const bool bIsFBX = FCString::Stricmp(*FileExtension, TEXT("FBX")) == 0;
if (bIsFBX)
{
FlushRenderingCommands();
UnFbx::FFbxImporter* FFbxImporter = UnFbx::FFbxImporter::GetInstance();
if (FFbxImporter->ImportFromFile( *ImportFilename, FPaths::GetExtension( ImportFilename ) ) )
{
TArray<FbxNode*> FbxMeshArray;
FFbxImporter->FillFbxMeshArray(FFbxImporter->Scene->GetRootNode(), FbxMeshArray, FFbxImporter);
UFbxStaticMeshImportData* ImportData = NewObject<UFbxStaticMeshImportData>(GetTransientPackage(), NAME_None, RF_NoFlags, NULL);
TArray<UStaticMesh*> ChunkMeshes;
for (int32 i=0; i < FbxMeshArray.Num(); ++i)
{
UStaticMesh* TempStaticMesh = NULL;
TempStaticMesh = (UStaticMesh*)FFbxImporter->ImportStaticMesh(GetTransientPackage(), FbxMeshArray[i], NAME_None, RF_NoFlags, ImportData, 0);
ChunkMeshes.Add(TempStaticMesh);
}
UDestructibleMesh* DestructibleMesh = DestructibleMeshEditorPtr.Pin()->GetDestructibleMesh();
if (DestructibleMesh)
{
DestructibleMesh->SetupChunksFromStaticMeshes(ChunkMeshes);
}
}
FFbxImporter->ReleaseScene();
// Update the viewport
DestructibleMeshEditorPtr.Pin()->RefreshTool();
DestructibleMeshEditorPtr.Pin()->SetCurrentPreviewDepth(0xFFFFFFFF); // This will get clamped to the max depth
}
else
{
// Invalid filename
}
}
#if WITH_APEX
#endif // WITH_APEX
}
示例3: GetTextForItem
FText FActorInfoColumn::GetTextForItem( TWeakPtr<ITreeItem> TreeItem ) const
{
auto Item = TreeItem.Pin();
return Item.IsValid() ? FText::FromString(Item->Get(FGetInfo(CurrentMode))) : FText::GetEmpty();
}
示例4: FillFileMenu
static void FillFileMenu( FMenuBuilder& MenuBuilder, TWeakPtr< FAssetEditorToolkit > AssetEditorToolkitWeak )
{
auto AssetEditorToolkit( AssetEditorToolkitWeak.Pin().ToSharedRef() );
AssetEditorToolkit->FillDefaultFileMenuCommands( MenuBuilder );
}
示例5: EditorBuild
/**
* Perform an editor build with behavior dependent upon the specified id
*
* @param Id Action Id specifying what kind of build is requested
*
* @return true if the build completed successfully; false if it did not (or was manually canceled)
*/
bool FEditorBuildUtils::EditorBuild( UWorld* InWorld, EBuildOptions::Type Id, const bool bAllowLightingDialog )
{
FMessageLog("MapCheck").NewPage(LOCTEXT("MapCheckNewPage", "Map Check"));
// Make sure to set this flag to false before ALL builds.
GEditor->SetMapBuildCancelled( false );
// Will be set to false if, for some reason, the build does not happen.
bool bDoBuild = true;
// Indicates whether the persistent level should be dirtied at the end of a build.
bool bDirtyPersistentLevel = true;
// Stop rendering thread so we're not wasting CPU cycles.
StopRenderingThread();
// Hack: These don't initialize properly and if you pick BuildAll right off the
// bat when opening a map you will get incorrect values in them.
GSwarmDebugOptions.Touch();
// Show option dialog first, before showing the DlgBuildProgress window.
FLightingBuildOptions LightingBuildOptions;
if ( Id == EBuildOptions::BuildLighting )
{
// Retrieve settings from ini.
GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("OnlyBuildSelected"), LightingBuildOptions.bOnlyBuildSelected, GEditorUserSettingsIni );
GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("OnlyBuildCurrentLevel"), LightingBuildOptions.bOnlyBuildCurrentLevel, GEditorUserSettingsIni );
GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("OnlyBuildSelectedLevels"),LightingBuildOptions.bOnlyBuildSelectedLevels, GEditorUserSettingsIni );
GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("OnlyBuildVisibility"), LightingBuildOptions.bOnlyBuildVisibility, GEditorUserSettingsIni );
GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("UseErrorColoring"), LightingBuildOptions.bUseErrorColoring, GEditorUserSettingsIni );
GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("ShowLightingBuildInfo"), LightingBuildOptions.bShowLightingBuildInfo, GEditorUserSettingsIni );
int32 QualityLevel;
GConfig->GetInt( TEXT("LightingBuildOptions"), TEXT("QualityLevel"), QualityLevel, GEditorUserSettingsIni );
QualityLevel = FMath::Clamp<int32>(QualityLevel, Quality_Preview, Quality_Production);
LightingBuildOptions.QualityLevel = (ELightingBuildQuality)QualityLevel;
}
// Show the build progress dialog.
SBuildProgressWidget::EBuildType BuildType = SBuildProgressWidget::BUILDTYPE_Geometry;
switch (Id)
{
case EBuildOptions::BuildGeometry:
case EBuildOptions::BuildVisibleGeometry:
case EBuildOptions::BuildAll:
case EBuildOptions::BuildAllOnlySelectedPaths:
BuildType = SBuildProgressWidget::BUILDTYPE_Geometry;
break;
case EBuildOptions::BuildLighting:
BuildType = SBuildProgressWidget::BUILDTYPE_Lighting;
break;
case EBuildOptions::BuildAIPaths:
case EBuildOptions::BuildSelectedAIPaths:
BuildType = SBuildProgressWidget::BUILDTYPE_Paths;
break;
case EBuildOptions::BuildHierarchicalLOD:
BuildType = SBuildProgressWidget::BUILDTYPE_LODs;
break;
default:
BuildType = SBuildProgressWidget::BUILDTYPE_Unknown;
break;
}
TWeakPtr<class SBuildProgressWidget> BuildProgressWidget = GWarn->ShowBuildProgressWindow();
BuildProgressWidget.Pin()->SetBuildType(BuildType);
bool bShouldMapCheck = true;
switch( Id )
{
case EBuildOptions::BuildGeometry:
{
// We can't set the busy cursor for all windows, because lighting
// needs a cursor for the lighting options dialog.
const FScopedBusyCursor BusyCursor;
GUnrealEd->Exec( InWorld, TEXT("MAP REBUILD") );
TriggerNavigationBuilder(InWorld, Id);
// No need to dirty the persient level if we're building BSP for a sub-level.
bDirtyPersistentLevel = false;
break;
}
case EBuildOptions::BuildVisibleGeometry:
{
// If any levels are hidden, prompt the user about how to proceed
bDoBuild = GEditor->WarnAboutHiddenLevels( InWorld, true );
if ( bDoBuild )
{
// We can't set the busy cursor for all windows, because lighting
// needs a cursor for the lighting options dialog.
const FScopedBusyCursor BusyCursor;
GUnrealEd->Exec( InWorld, TEXT("MAP REBUILD ALLVISIBLE") );
//.........这里部分代码省略.........
示例6: Draw
void FMaterialEditorViewportClient::Draw(FViewport* InViewport,FCanvas* Canvas)
{
FEditorViewportClient::Draw(InViewport, Canvas);
MaterialEditorPtr.Pin()->DrawMessages(InViewport, Canvas);
}
示例7: Construct
/**
* Construct this widget. Called by the SNew() Slate macro.
*
* @param InArgs Declaration used by the SNew() macro to construct this widget
* @param Factory The factory this menu entry represents
*/
void Construct( const FArguments& InArgs, UFactory* Factory )
{
const FName ClassThumbnailBrushOverride = Factory->GetNewAssetThumbnailOverride();
const FSlateBrush* ClassThumbnail = nullptr;
if (ClassThumbnailBrushOverride.IsNone())
{
ClassThumbnail = FClassIconFinder::FindThumbnailForClass(Factory->GetSupportedClass());
}
else
{
// Instead of getting the override thumbnail directly from the editor style here get it from the
// ClassIconFinder since it may have additional styles registered which can be searched by passing
// it as a default with no class to search for.
ClassThumbnail = FClassIconFinder::FindThumbnailForClass(nullptr, ClassThumbnailBrushOverride);
}
FAssetToolsModule& AssetToolsModule = FAssetToolsModule::GetModule();
TWeakPtr<IAssetTypeActions> AssetTypeActions = AssetToolsModule.Get().GetAssetTypeActionsForClass(Factory->GetSupportedClass());
FLinearColor AssetColor = FLinearColor::White;
if ( AssetTypeActions.IsValid() )
{
AssetColor = AssetTypeActions.Pin()->GetTypeColor();
}
ChildSlot
[
SNew( SHorizontalBox )
+SHorizontalBox::Slot()
.Padding( 4, 0, 0, 0 )
.VAlign(VAlign_Center)
.AutoWidth()
[
SNew( SOverlay )
+SOverlay::Slot()
[
SNew( SBox )
.WidthOverride( InArgs._Width + 4 )
.HeightOverride( InArgs._Height + 4 )
[
SNew( SBorder )
.BorderImage( FEditorStyle::GetBrush("AssetThumbnail.AssetBackground") )
.BorderBackgroundColor(AssetColor.CopyWithNewOpacity(0.3f))
.Padding( 2.0f )
.VAlign( VAlign_Center )
.HAlign( HAlign_Center )
[
SNew( SImage )
.Image( ClassThumbnail )
]
]
]
+SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Bottom)
[
SNew( SBorder )
.BorderImage( FEditorStyle::GetBrush("WhiteBrush") )
.BorderBackgroundColor( AssetColor )
.Padding( FMargin(0, FMath::Max(FMath::CeilToFloat(InArgs._Width*0.025f), 3.0f), 0, 0) )
]
]
+SHorizontalBox::Slot()
.VAlign(VAlign_Center)
.Padding(4, 0, 4, 0)
[
SNew( SVerticalBox )
+SVerticalBox::Slot()
.Padding(0, 0, 0, 1)
.AutoHeight()
[
SNew(STextBlock)
.Font( FEditorStyle::GetFontStyle("LevelViewportContextMenu.AssetLabel.Text.Font") )
.Text( Factory->GetDisplayName() )
]
]
];
SetToolTip(IDocumentation::Get()->CreateToolTip(Factory->GetToolTip(), nullptr, Factory->GetToolTipDocumentationPage(), Factory->GetToolTipDocumentationExcerpt()));
}
示例8: OpenEditorForAssets
bool FAssetEditorManager::OpenEditorForAssets( const TArray< UObject* >& Assets, const EToolkitMode::Type ToolkitMode, TSharedPtr< IToolkitHost > OpenedFromLevelEditor )
{
if( Assets.Num() == 1 )
{
return OpenEditorForAsset(Assets[0], ToolkitMode, OpenedFromLevelEditor);
}
else if (Assets.Num() > 0)
{
// If any of the assets are already open, remove them from the list of assets to open an editor for
TArray<UObject*> AlreadyOpenAssets;
for (auto Asset : Assets)
{
if( FindEditorForAsset(Asset, true) != nullptr )
{
AlreadyOpenAssets.Add(Asset);
}
}
// Verify that all the assets are of the same class
bool bAssetClassesMatch = true;
auto AssetClass = Assets[0]->GetClass();
for (int32 i = 1; i < Assets.Num(); i++)
{
if (Assets[i]->GetClass() != AssetClass)
{
bAssetClassesMatch = false;
break;
}
}
// If the classes don't match or any of the selected assets are already open, just open each asset in its own editor.
if (bAssetClassesMatch && AlreadyOpenAssets.Num() == 0)
{
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
TWeakPtr<IAssetTypeActions> AssetTypeActions = AssetToolsModule.Get().GetAssetTypeActionsForClass(AssetClass);
if (AssetTypeActions.IsValid())
{
GWarn->BeginSlowTask(LOCTEXT("OpenEditor", "Opening Editor(s)..."), true);
// Determine the appropriate toolkit mode for the asset type
auto ActualToolkitMode = ToolkitMode;
if (AssetTypeActions.Pin()->ShouldForceWorldCentric())
{
// This asset type prefers a specific toolkit mode
ActualToolkitMode = EToolkitMode::WorldCentric;
if (!OpenedFromLevelEditor.IsValid())
{
// We don't have a level editor to spawn in world-centric mode, so we'll find one now
// @todo sequencer: We should eventually eliminate this code (incl include dependencies) or change it to not make assumptions about a single level editor
OpenedFromLevelEditor = FModuleManager::LoadModuleChecked< FLevelEditorModule >("LevelEditor").GetFirstLevelEditor();
}
}
if (ActualToolkitMode != EToolkitMode::WorldCentric && OpenedFromLevelEditor.IsValid())
{
// @todo toolkit minor: Kind of lame use of a static variable here to prime the new asset editor. This was done to avoid refactoring a few dozen files for a very minor change.
FAssetEditorToolkit::SetPreviousWorldCentricToolkitHostForNewAssetEditor(OpenedFromLevelEditor.ToSharedRef());
}
// Some assets (like UWorlds) may be destroyed and recreated as part of opening. To protect against this, keep the path to each asset and try to re-find any if they disappear.
struct FLocalAssetInfo
{
TWeakObjectPtr<UObject> WeakAsset;
FString AssetPath;
FLocalAssetInfo(const TWeakObjectPtr<UObject>& InWeakAsset, const FString& InAssetPath)
: WeakAsset(InWeakAsset), AssetPath(InAssetPath) {}
};
TArray<FLocalAssetInfo> AssetInfoList;
AssetInfoList.Reserve(Assets.Num());
for (auto Asset : Assets)
{
AssetInfoList.Add(FLocalAssetInfo(Asset, Asset->GetPathName()));
}
// How to handle multiple assets is left up to the type actions (i.e. open a single shared editor or an editor for each)
AssetTypeActions.Pin()->OpenAssetEditor(Assets, ActualToolkitMode == EToolkitMode::WorldCentric ? OpenedFromLevelEditor : TSharedPtr<IToolkitHost>());
// If any assets were destroyed, attempt to find them if they were recreated
for (int32 i = 0; i < Assets.Num(); i++)
{
auto& AssetInfo = AssetInfoList[i];
auto Asset = Assets[i];
if (!AssetInfo.WeakAsset.IsValid() && !AssetInfo.AssetPath.IsEmpty())
{
Asset = FindObject<UObject>(nullptr, *AssetInfo.AssetPath);
}
}
//@todo if needed, broadcast the event for every asset. It is possible, however, that a single shared editor was opened by the AssetTypeActions, not an editor for each asset.
/*AssetEditorOpenedEvent.Broadcast(Asset);*/
GWarn->EndSlowTask();
}
}
else
//.........这里部分代码省略.........
示例9: OnMouseButtonDown
FReply STimelineLabelAnchor::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
if (MouseEvent.GetEffectingButton() == EKeys::RightMouseButton && TimelineOwner.IsValid() && TimelineOwner.Pin()->IsSelected())
{
SetIsOpen(!IsOpen());
return FReply::Handled();
}
return FReply::Unhandled();
}
示例10: MenuBuilder
TSharedRef< SWidget > FLevelEditorToolBar::GenerateMatineeMenuContent( TSharedRef<FUICommandList> InCommandList, TWeakPtr<SLevelEditor> LevelEditorWeakPtr )
{
#define LOCTEXT_NAMESPACE "LevelToolBarMatineeMenu"
const bool bShouldCloseWindowAfterMenuSelection = true;
FMenuBuilder MenuBuilder( bShouldCloseWindowAfterMenuSelection, InCommandList );
// We can't build a list of Matinees while the current World is a PIE world.
FSceneOutlinerInitializationOptions InitOptions;
{
InitOptions.Mode = ESceneOutlinerMode::ActorPicker;
// We hide the header row to keep the UI compact.
// @todo: Might be useful to have this sometimes, actually. Ideally the user could summon it.
InitOptions.bShowHeaderRow = false;
// Only display Matinee actors
InitOptions.ActorFilters = MakeShareable( new TFilterCollection< const AActor* const >() );
struct Local
{
static bool IsMatineeActor( const AActor* const Actor )
{
return Actor->IsA( AMatineeActor::StaticClass() );
}
};
InitOptions.ActorFilters->Add( MakeShareable( new TDelegateFilter< const AActor* const >( TDelegateFilter< const AActor* const >::FPredicate::CreateStatic( &Local::IsMatineeActor ) ) ) );
}
// actor selector to allow the user to choose a Matinee actor
FSceneOutlinerModule& SceneOutlinerModule = FModuleManager::LoadModuleChecked<FSceneOutlinerModule>( "SceneOutliner" );
TSharedRef< SWidget > MiniSceneOutliner =
SNew( SVerticalBox )
+SVerticalBox::Slot()
.AutoHeight()
.MaxHeight(400.0f)
[
SceneOutlinerModule.CreateSceneOutliner(
InitOptions,
FOnContextMenuOpening(), //no context menu allowed here
FOnActorPicked::CreateStatic( &FLevelEditorToolBar::OnMatineeActorPicked ) )
];
// Give the scene outliner a border and background
const FSlateBrush* BackgroundBrush = FEditorStyle::GetBrush( "Menu.Background" );
TSharedRef< SBorder > RootBorder =
SNew( SBorder )
.Padding(3)
.BorderImage( BackgroundBrush )
.ForegroundColor( FEditorStyle::GetSlateColor("DefaultForeground") )
// Assign the box panel as the child
[
SNew( SVerticalBox )
+SVerticalBox::Slot()
.AutoHeight()
.Padding( 5 )
.HAlign( HAlign_Center )
[
SNew( STextBlock )
.Text( LOCTEXT( "SelectMatineeActorToEdit", "Select a Matinee actor" ) )
]
+SVerticalBox::Slot()
.AutoHeight()
.Padding( 2 )
[
MiniSceneOutliner
]
]
;
MenuBuilder.BeginSection("LevelEditorNewMatinee", LOCTEXT("MatineeMenuCombo_NewHeading", "New"));
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().AddMatinee );
}
MenuBuilder.EndSection();
bool bHasAnyMatineeActors = false;
TActorIterator<AMatineeActor> MatineeIt( LevelEditorWeakPtr.Pin()->GetWorld() );
bHasAnyMatineeActors = MatineeIt;
//Add a heading to separate the existing matinees from the 'Add New Matinee Actor' button
MenuBuilder.BeginSection("LevelEditorExistingMatinee", LOCTEXT( "MatineeMenuCombo_ExistingHeading", "Edit Existing Matinee" ) );
{
if( bHasAnyMatineeActors )
{
MenuBuilder.AddWidget(MiniSceneOutliner, FText::GetEmpty(), false);
}
}
MenuBuilder.EndSection();
#undef LOCTEXT_NAMESPACE
return MenuBuilder.MakeWidget();
}
示例11: OpenEditorForAsset
bool FAssetEditorManager::OpenEditorForAsset(UObject* Asset, const EToolkitMode::Type ToolkitMode, TSharedPtr< IToolkitHost > OpenedFromLevelEditor )
{
check(Asset);
// @todo toolkit minor: When "Edit Here" happens in a different level editor from the one that an asset is already
// being edited within, we should decide whether to disallow "Edit Here" in that case, or to close the old asset
// editor and summon it in the new level editor, or to just foreground the old level editor (current behavior)
const bool bBringToFrontIfOpen = true;
// Don't open asset editors for cooked packages
if (UPackage* Package = Asset->GetOutermost())
{
if (Package->bIsCookedForEditor)
{
return false;
}
}
AssetEditorRequestOpenEvent.Broadcast(Asset);
if( FindEditorForAsset(Asset, bBringToFrontIfOpen) != nullptr )
{
// This asset is already open in an editor! (the call to FindEditorForAsset above will bring it to the front)
return true;
}
else
{
GWarn->BeginSlowTask( LOCTEXT("OpenEditor", "Opening Editor..."), true);
}
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
TWeakPtr<IAssetTypeActions> AssetTypeActions = AssetToolsModule.Get().GetAssetTypeActionsForClass( Asset->GetClass() );
auto ActualToolkitMode = ToolkitMode;
if( AssetTypeActions.IsValid() )
{
if( AssetTypeActions.Pin()->ShouldForceWorldCentric() )
{
// This asset type prefers a specific toolkit mode
ActualToolkitMode = EToolkitMode::WorldCentric;
if( !OpenedFromLevelEditor.IsValid() )
{
// We don't have a level editor to spawn in world-centric mode, so we'll find one now
// @todo sequencer: We should eventually eliminate this code (incl include dependencies) or change it to not make assumptions about a single level editor
OpenedFromLevelEditor = FModuleManager::LoadModuleChecked< FLevelEditorModule >( "LevelEditor" ).GetFirstLevelEditor();
}
}
}
if( ActualToolkitMode != EToolkitMode::WorldCentric && OpenedFromLevelEditor.IsValid() )
{
// @todo toolkit minor: Kind of lame use of a static variable here to prime the new asset editor. This was done to avoid refactoring a few dozen files for a very minor change.
FAssetEditorToolkit::SetPreviousWorldCentricToolkitHostForNewAssetEditor( OpenedFromLevelEditor.ToSharedRef() );
}
// Disallow opening an asset editor for classes
bool bCanSummonSimpleAssetEditor = !Asset->IsA<UClass>();
if( AssetTypeActions.IsValid() )
{
TArray<UObject*> AssetsToEdit;
AssetsToEdit.Add(Asset);
// Some assets (like UWorlds) may be destroyed and recreated as part of opening. To protect against this, keep the path to the asset and try to re-find it if it disappeared.
TWeakObjectPtr<UObject> WeakAsset = Asset;
const FString AssetPath = Asset->GetPathName();
AssetTypeActions.Pin()->OpenAssetEditor(AssetsToEdit, ActualToolkitMode == EToolkitMode::WorldCentric ? OpenedFromLevelEditor : TSharedPtr<IToolkitHost>());
// If the Asset was destroyed, attempt to find it if it was recreated
if ( !WeakAsset.IsValid() && !AssetPath.IsEmpty() )
{
Asset = FindObject<UObject>(nullptr, *AssetPath);
}
AssetEditorOpenedEvent.Broadcast(Asset);
}
else if( bCanSummonSimpleAssetEditor )
{
// No asset type actions for this asset. Just use a properties editor.
FSimpleAssetEditor::CreateEditor(ActualToolkitMode, ActualToolkitMode == EToolkitMode::WorldCentric ? OpenedFromLevelEditor : TSharedPtr<IToolkitHost>(), Asset);
}
GWarn->EndSlowTask();
return true;
}
示例12: GetOpenGameModeBlueprintLabel
FText FLevelEditorToolBar::GetOpenGameModeBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
if(IsValidGameModeBlueprint(InLevelEditor))
{
return FText::Format( LOCTEXT("GameModeEditBlueprint", "GameMode: Edit {GameModeName}"), FText::FromString(InLevelEditor.Pin()->GetWorld()->GetWorldSettings()->DefaultGameMode->ClassGeneratedBy->GetName()));
}
return LOCTEXT("GameModeCreateBlueprint", "GameMode: Create...");
#undef LOCTEXT_NAMESPACE
}
示例13: IsValidGameModeBlueprint
bool FLevelEditorToolBar::IsValidGameModeBlueprint(TWeakPtr< SLevelEditor > InLevelEditor)
{
AWorldSettings* WorldSettings = InLevelEditor.Pin()->GetWorld()->GetWorldSettings();
return WorldSettings->DefaultGameMode && WorldSettings->DefaultGameMode->ClassGeneratedBy;
}
示例14: MakeSubLevelsMenu
TSharedRef< SWidget > FLevelEditorToolBar::GenerateOpenBlueprintMenuContent( TSharedRef<FUICommandList> InCommandList, TWeakPtr< SLevelEditor > InLevelEditor )
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
struct FBlueprintMenus
{
/** Generates a sub-level Blueprints sub-menu */
static void MakeSubLevelsMenu(FMenuBuilder& InMenuBuilder, TWeakPtr< SLevelEditor > InLvlEditor)
{
FSlateIcon EditBP(FEditorStyle::Get().GetStyleSetName(), TEXT("LevelEditor.OpenLevelBlueprint"));
InMenuBuilder.BeginSection(NAME_None, LOCTEXT("SubLevelsHeading", "Sub-Level Blueprints"));
{
UWorld* World = InLvlEditor.Pin()->GetWorld();
for (int32 iLevel = 0; iLevel < World->GetNumLevels(); iLevel++)
{
ULevel* Level = World->GetLevel(iLevel);
if (Level != NULL && Level->GetOutermost() != NULL)
{
if (!Level->IsPersistentLevel())
{
FUIAction UIAction
(
FExecuteAction::CreateStatic(&FLevelEditorToolBar::OnOpenSubLevelBlueprint, Level)
);
FText DisplayName = FText::Format(LOCTEXT("SubLevelBlueprintItem", "Edit {LevelName}"), FText::FromString(FPaths::GetCleanFilename(Level->GetOutermost()->GetName())));
InMenuBuilder.AddMenuEntry(DisplayName, FText::GetEmpty(), EditBP, UIAction);
}
}
}
}
InMenuBuilder.EndSection();
}
/** Handle BP being selected from popup picker */
static void OnBPSelected(const class FAssetData& AssetData)
{
UBlueprint* SelectedBP = Cast<UBlueprint>(AssetData.GetAsset());
if(SelectedBP)
{
FAssetEditorManager::Get().OpenEditorForAsset(SelectedBP);
}
}
/** Generates 'eopn blueprint' sub-menu */
static void MakeOpenClassBPMenu(FMenuBuilder& InMenuBuilder)
{
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>(TEXT("ContentBrowser"));
// Configure filter for asset picker
FAssetPickerConfig Config;
Config.Filter.ClassNames.Add(UBlueprint::StaticClass()->GetFName());
Config.InitialAssetViewType = EAssetViewType::List;
Config.ThumbnailScale = 0; // make thumbnails as small as possible
Config.OnAssetSelected = FOnAssetSelected::CreateStatic(&FBlueprintMenus::OnBPSelected);
Config.bAllowDragging = false;
// Don't show stuff in Engine
Config.Filter.PackagePaths.Add("/Game");
Config.Filter.bRecursivePaths = true;
TSharedRef<SWidget> Widget =
SNew(SBox)
.WidthOverride(300.f)
.HeightOverride(300.f)
[
ContentBrowserModule.Get().CreateAssetPicker(Config)
];
InMenuBuilder.BeginSection(NAME_None, LOCTEXT("BrowseHeader", "Browse"));
{
InMenuBuilder.AddWidget(Widget, FText::GetEmpty());
}
InMenuBuilder.EndSection();
}
};
const bool bShouldCloseWindowAfterMenuSelection = true;
FMenuBuilder MenuBuilder( bShouldCloseWindowAfterMenuSelection, InCommandList );
MenuBuilder.BeginSection(NAME_None, LOCTEXT("LevelScriptBlueprints", "Level Blueprints"));
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().OpenLevelBlueprint );
// If there are any sub-levels, display the sub-menu. A single level means there is only the persistent level
UWorld* World = InLevelEditor.Pin()->GetWorld();
if(World->GetNumLevels() > 1)
{
MenuBuilder.AddSubMenu(
LOCTEXT( "SubLevelsSubMenu", "Sub-Levels" ),
LOCTEXT( "SubLevelsSubMenu_ToolTip", "Shows available sub-level Blueprints that can be edited." ),
FNewMenuDelegate::CreateStatic( &FBlueprintMenus::MakeSubLevelsMenu, InLevelEditor ),
FUIAction(), NAME_None, EUserInterfaceActionType::Button, false, FSlateIcon(FEditorStyle::Get().GetStyleSetName(), TEXT("LevelEditor.OpenLevelBlueprint")) );
}
}
MenuBuilder.EndSection();
//.........这里部分代码省略.........
示例15: OnKeyDown
FReply SVisualLoggerTimelinesContainer::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent)
{
if (InKeyEvent.GetKey() == EKeys::A && InKeyEvent.IsLeftControlDown())
{
for (TSharedPtr<SLogVisualizerTimeline>& Timeline : TimelineItems)
{
SetSelectionState(Timeline, true, false);
}
return FReply::Handled();
}
else if (InKeyEvent.GetKey() == EKeys::Platform_Delete && CachedSelectedTimelines.Num() > 0)
{
TWeakPtr<SLogVisualizerTimeline> NotSelectedOne;
for (TSharedPtr<SLogVisualizerTimeline>& CurrentNode : CachedSelectedTimelines)
{
TSharedPtr<SLogVisualizerTimeline> LastSelected = CachedSelectedTimelines[CachedSelectedTimelines.Num() - 1];
bool bFoundSelectedOne = false;
for (TSharedPtr<SLogVisualizerTimeline>& Timeline : TimelineItems)
{
if (IsNodeSelected(Timeline) == false)
{
NotSelectedOne = Timeline;
}
if (LastSelected == Timeline)
{
if (bFoundSelectedOne && NotSelectedOne.IsValid())
{
break;
}
bFoundSelectedOne = true;
}
}
FVisualLoggerDatabase::Get().RemoveRow(CurrentNode->GetName());
TimelineItems.Remove(CurrentNode);
ContainingBorder->RemoveSlot(CurrentNode.ToSharedRef());
}
if (NotSelectedOne.IsValid())
{
SetSelectionState(NotSelectedOne.Pin(), true, true);
}
return FReply::Handled();
}
else if (InKeyEvent.GetKey() == EKeys::Up || InKeyEvent.GetKey() == EKeys::Down)
{
TSharedPtr<SLogVisualizerTimeline> PreviousTimeline;
TSharedPtr<SLogVisualizerTimeline> LastSelected = CachedSelectedTimelines[CachedSelectedTimelines.Num() - 1];
for (int32 Index = 0; Index < TimelineItems.Num(); ++Index)
{
auto& CurrentItem = TimelineItems[Index];
if (LastSelected == CurrentItem)
{
if (InKeyEvent.GetKey() == EKeys::Up && PreviousTimeline.IsValid())
{
SetSelectionState(PreviousTimeline, true, true);
}
else if (InKeyEvent.GetKey() == EKeys::Down)
{
// let's find next visible time line
if (TimelineItems.IsValidIndex(Index + 1))
{
for (int32 i = Index + 1; i < TimelineItems.Num(); ++i)
{
if (TimelineItems[i]->GetVisibility() == EVisibility::Visible)
{
SetSelectionState(TimelineItems[i], true, true);
break;
}
}
}
}
break;
}
if (CurrentItem->GetVisibility() == EVisibility::Visible)
{
PreviousTimeline = CurrentItem;
}
}
return FReply::Handled();
}
return FReply::Unhandled();
}