void FAssetTypeActions_GAAbilityBlueprint::OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<IToolkitHost> EditWithinLevelEditor) { EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone; for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt) { auto Blueprint = Cast<UBlueprint>(*ObjIt); if (Blueprint && Blueprint->SkeletonGeneratedClass && Blueprint->GeneratedClass) { TSharedRef< FGAAbilityEditor > NewEditor(new FGAAbilityEditor()); TArray<UBlueprint*> Blueprints; Blueprints.Add(Blueprint); NewEditor->InitAbilitiesEditor(Mode, EditWithinLevelEditor, Blueprints, ShouldUseDataOnlyEditor(Blueprint)); } else { FMessageDialog::Open(EAppMsgType::Ok, FText::FromString("Ability Blueprint could not be loaded because it derives from an invalid class. Check to make sure the parent class for this blueprint hasn't been removed!")); } } }
void FAssetTypeActions_PathFollowerBlueprint::OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor) { EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone; for (UObject* Object : InObjects) { if (UBlueprint* Blueprint = Cast<UBlueprint>(Object)) { bool isFirstCreate = Blueprint->bIsNewlyCreated; TSharedRef<FPathFollowerEditor> Editor(new FPathFollowerEditor()); TArray<UBlueprint*> Blueprints; Blueprints.Add(Blueprint); Editor->InitPathFollowerEditor(Mode, EditWithinLevelEditor, Blueprints, ShouldUseDataOnlyEditor(Blueprint)); //第一次打开, 初始化部分对象. if(isFirstCreate) { Editor->AddComponent(USphereComponent::StaticClass(), TEXT("Sphere")); Editor->AddComponent(USplineComponent::StaticClass(), TEXT("Spline")); } } } }
void FAssetTypeActions_Blueprint::OpenAssetEditor( const TArray<UObject*>& InObjects, TSharedPtr<IToolkitHost> EditWithinLevelEditor ) { EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone; for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt) { auto Blueprint = Cast<UBlueprint>(*ObjIt); if (Blueprint && Blueprint->SkeletonGeneratedClass && Blueprint->GeneratedClass ) { FBlueprintEditorModule& BlueprintEditorModule = FModuleManager::LoadModuleChecked<FBlueprintEditorModule>( "Kismet" ); TSharedRef< IBlueprintEditor > NewKismetEditor = BlueprintEditorModule.CreateBlueprintEditor( Mode, EditWithinLevelEditor, Blueprint, ShouldUseDataOnlyEditor(Blueprint) ); } else { FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("FailedToLoadBlueprint", "Blueprint could not be loaded because it derives from an invalid class. Check to make sure the parent class for this blueprint hasn't been removed!")); } } }