|
@@ -0,0 +1,100 @@
|
|
|
+// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
+
|
|
|
+
|
|
|
+#include "AbilityEditorViewportClient.h"
|
|
|
+#include "PreviewScene.h"
|
|
|
+#include "AdvancedPreviewScene.h"
|
|
|
+#include "EditorViewportClient.h"
|
|
|
+#include "SEditorViewport.h"
|
|
|
+#include "Templates/SharedPointer.h"
|
|
|
+#include "SAbilityEditorViewport.h"
|
|
|
+#include "Editor/UnrealEd/Public/PackageTools.h"
|
|
|
+#include "Editor/UnrealEd/Public/FileHelpers.h"
|
|
|
+
|
|
|
+// FDialogueEditorViewportClient::FDialogueEditorViewportClient(const TSharedRef<SDialogueEditorViewport>& InThumbnailViewport,const TSharedRef<FAdvancedPreviewScene>& InPreviewScene, UMBRData* TestMBR)
|
|
|
+// : FEditorViewportClient(nullptr, &InPreviewScene.Get(), StaticCastSharedRef<SEditorViewport>(InThumbnailViewport))
|
|
|
+// , ViewportPtr(InThumbnailViewport)
|
|
|
+// , Dialogue(TestMBR)
|
|
|
+// {
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+FAbilityEditorViewportClient::FAbilityEditorViewportClient(const TSharedRef<SAbilityEditorViewport>& InThumbnailViewport, FAdvancedPreviewScene& InPreviewScene) //, UMBRData* TestMBR
|
|
|
+ : FEditorViewportClient(nullptr, &InPreviewScene, StaticCastSharedRef<SEditorViewport>(InThumbnailViewport))
|
|
|
+ , ViewportPtr(InThumbnailViewport)
|
|
|
+// , Dialogue(TestMBR)
|
|
|
+{
|
|
|
+
|
|
|
+// auto FindWorldInPackageOrFollowRedirector = [](UPackage*& InOutPackage)
|
|
|
+// {
|
|
|
+// UWorld* RetVal = nullptr;
|
|
|
+// TArray<UObject*> PotentialWorlds;
|
|
|
+// GetObjectsWithOuter(InOutPackage, PotentialWorlds, false);
|
|
|
+// for (auto ObjIt = PotentialWorlds.CreateConstIterator(); ObjIt; ++ObjIt)
|
|
|
+// {
|
|
|
+// RetVal = Cast<UWorld>(*ObjIt);
|
|
|
+// if (RetVal)
|
|
|
+// {
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// else if (UObjectRedirector* Redirector = Cast<UObjectRedirector>(*ObjIt))
|
|
|
+// {
|
|
|
+// RetVal = Cast<UWorld>(Redirector->DestinationObject);
|
|
|
+// if (RetVal)
|
|
|
+// {
|
|
|
+// // Patch up the WorldType if found in the PreLoad map
|
|
|
+// EWorldType::Type* PreLoadWorldType = UWorld::WorldTypePreLoadMap.Find(Redirector->GetOuter()->GetFName());
|
|
|
+// if (PreLoadWorldType)
|
|
|
+// {
|
|
|
+// RetVal->WorldType = *PreLoadWorldType;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // If we followed a redirector also update the package pointer to the actual returned world package
|
|
|
+// InOutPackage = RetVal->GetOutermost();
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return RetVal;
|
|
|
+// };
|
|
|
+//
|
|
|
+// ///Script/Engine.World'/Game/Untitled.Untitled'
|
|
|
+// //FString LongTempFname = TEXT("/Game/ThirdPerson/Maps/SuccessMap");
|
|
|
+//
|
|
|
+//
|
|
|
+// // TArray<UPackage*> WorldPackages;
|
|
|
+// // for (TObjectIterator<UWorld> It; It; ++It)
|
|
|
+// // {
|
|
|
+// // // Don't unload transient or newly created worlds, nor the world we're attempting to keep-alive
|
|
|
+// // UPackage* Package = It->GetPackage();
|
|
|
+// // if (Package != GetTransientPackage() && !Package->HasAnyPackageFlags(PKG_NewlyCreated)) // && *It != NewWorld
|
|
|
+// // {
|
|
|
+// // WorldPackages.AddUnique(Package);
|
|
|
+// // }
|
|
|
+// // }
|
|
|
+//
|
|
|
+// TArray<UPackage*> WorldPackages;
|
|
|
+//
|
|
|
+// FString LongTempFname = TEXT("/Game/Untitled");
|
|
|
+// FLinkerInstancingContext WorldPackageInstancingContext;
|
|
|
+// WorldPackageInstancingContext.AddTag(UWorld::KeepInitializedDuringLoadTag);
|
|
|
+// UPackage* TestPackage = LoadPackage(NULL, *LongTempFname, LOAD_None, nullptr, &WorldPackageInstancingContext);
|
|
|
+// UWorld* World = FindWorldInPackageOrFollowRedirector(TestPackage);
|
|
|
+//
|
|
|
+// //WorldPackages.Add(TestPackage);
|
|
|
+//
|
|
|
+// //UPackageTools::UnloadPackages(WorldPackages);
|
|
|
+// //FEditorFileUtils::GetOnLoadMapStartDelegate().AddSP(this, &FDialogueEditorViewportClient::CleanWorld);//.AddSP(this, &FDialogueEditorViewportClient::CleanWorld); //在LoadMap开始时,先清理掉当前Map
|
|
|
+//
|
|
|
+// FWorldContext& InitialWorldContext = GEngine->CreateNewWorldContext(EWorldType::Editor);
|
|
|
+// //InitialWorldContext.SetCurrentWorld(UWorld::CreateWorld(EWorldType::Editor, true ));
|
|
|
+// InitialWorldContext.SetCurrentWorld(World);
|
|
|
+// DialogueWorld = InitialWorldContext.World();
|
|
|
+}
|
|
|
+
|
|
|
+FAbilityEditorViewportClient::~FAbilityEditorViewportClient()
|
|
|
+{
|
|
|
+ UE_LOG(LogTemp, Warning, TEXT("Dialogue Editor"));
|
|
|
+}
|
|
|
+
|