diff --git a/Source/LGUI/Private/Core/LGUILifeCycleBehaviour.cpp b/Source/LGUI/Private/Core/LGUILifeCycleBehaviour.cpp index 566364aeb..522c04797 100644 --- a/Source/LGUI/Private/Core/LGUILifeCycleBehaviour.cpp +++ b/Source/LGUI/Private/Core/LGUILifeCycleBehaviour.cpp @@ -76,7 +76,7 @@ void ULGUILifeCycleBehaviour::OnRegister() #if WITH_EDITOR if (GetWorld() && !GetWorld()->IsGameWorld()) { - if (GetWorld() != ULGUIPrefabManagerObject::GetPreviewWorldForPrefabPackage())//skip preview world + if (GetWorld() != ULGUIPrefabManagerObject::GetPreviewWorldForPrefabPackage(false))//skip preview world { //Only allow Editor world, skip EditorPreview (Thumbnail) world if (GetWorld()->WorldType == EWorldType::Editor) diff --git a/Source/LGUI/Private/PrefabSystem/ActorSerializer7_Deserialize.cpp b/Source/LGUI/Private/PrefabSystem/ActorSerializer7_Deserialize.cpp index d4f246c07..bfbd1897e 100644 --- a/Source/LGUI/Private/PrefabSystem/ActorSerializer7_Deserialize.cpp +++ b/Source/LGUI/Private/PrefabSystem/ActorSerializer7_Deserialize.cpp @@ -271,7 +271,7 @@ namespace LGUIPrefabSystem7 if (!ParentComp) { #if WITH_EDITOR - if (TargetWorld != ULGUIPrefabManagerObject::GetPreviewWorldForPrefabPackage())//skip preview world, only show this in PrefabEditor or LevelEditor + if (TargetWorld != ULGUIPrefabManagerObject::GetPreviewWorldForPrefabPackage(false))//skip preview world, only show this in PrefabEditor or LevelEditor { auto MissingParentMsg = FText::Format(LOCTEXT("MissingParentMsg", "Prefab '{0}' fail to find parent for component '{1}.{2}', do you delete it? The component will attach to root") , FText::FromString(PrefabAssetPath), FText::FromString(SceneComp->GetOwner()->GetActorLabel()), FText::FromString(SceneComp->GetName())); diff --git a/Source/LGUI/Private/PrefabSystem/ActorSerializer8_Deserialize.cpp b/Source/LGUI/Private/PrefabSystem/ActorSerializer8_Deserialize.cpp index 94be399ef..768547ca6 100644 --- a/Source/LGUI/Private/PrefabSystem/ActorSerializer8_Deserialize.cpp +++ b/Source/LGUI/Private/PrefabSystem/ActorSerializer8_Deserialize.cpp @@ -268,7 +268,7 @@ namespace LGUIPrefabSystem8 if (!ParentComp) { #if WITH_EDITOR - if (TargetWorld != ULGUIPrefabManagerObject::GetPreviewWorldForPrefabPackage())//skip preview world, only show this in PrefabEditor or LevelEditor + if (TargetWorld != ULGUIPrefabManagerObject::GetPreviewWorldForPrefabPackage(false))//skip preview world, only show this in PrefabEditor or LevelEditor { auto MissingParentMsg = FText::Format(LOCTEXT("MissingParentMsg", "Prefab '{0}' fail to find parent for component '{1}.{2}', do you delete it? The component will attach to root") , FText::FromString(PrefabAssetPath), FText::FromString(SceneComp->GetOwner()->GetActorLabel()), FText::FromString(SceneComp->GetName())); diff --git a/Source/LGUI/Private/PrefabSystem/LGUIPrefabManager.cpp b/Source/LGUI/Private/PrefabSystem/LGUIPrefabManager.cpp index 373683cb6..fd8357a11 100644 --- a/Source/LGUI/Private/PrefabSystem/LGUIPrefabManager.cpp +++ b/Source/LGUI/Private/PrefabSystem/LGUIPrefabManager.cpp @@ -210,7 +210,9 @@ bool ULGUIPrefabManagerObject::InitCheck() Instance->OnBlueprintPreCompileDelegateHandle = GEditor->OnBlueprintPreCompile().AddUObject(Instance, &ULGUIPrefabManagerObject::OnBlueprintPreCompile); Instance->OnBlueprintCompiledDelegateHandle = GEditor->OnBlueprintCompiled().AddUObject(Instance, &ULGUIPrefabManagerObject::OnBlueprintCompiled); } +#if 0 // only used for ULGUIPrefabHelperObject::OnComponentCreateDelete but that function is disabled, so this listener doesn't need to be created Instance->ObjectCreateDeleteListener = new FLGUIObjectCreateDeleteListener(Instance); +#endif } return true; } @@ -256,8 +258,18 @@ void ULGUIPrefabManagerObject::OnPackageReloaded(EPackageReloadPhase Phase, FPac } } -UWorld* ULGUIPrefabManagerObject::GetPreviewWorldForPrefabPackage() +UWorld* ULGUIPrefabManagerObject::GetPreviewWorldForPrefabPackage(bool bCreate) { + if (Instance && Instance->PreviewWorldForPrefabPackage) + { + return Instance->PreviewWorldForPrefabPackage; + } + + if (!bCreate) + { + return nullptr; + } + InitCheck(); auto& PreviewWorldForPrefabPackage = Instance->PreviewWorldForPrefabPackage; if (PreviewWorldForPrefabPackage == nullptr) diff --git a/Source/LGUI/Public/PrefabSystem/LGUIPrefabManager.h b/Source/LGUI/Public/PrefabSystem/LGUIPrefabManager.h index 08aa25ac9..cd674ece3 100644 --- a/Source/LGUI/Public/PrefabSystem/LGUIPrefabManager.h +++ b/Source/LGUI/Public/PrefabSystem/LGUIPrefabManager.h @@ -57,7 +57,7 @@ class LGUI_API ULGUIPrefabManagerObject :public UObject, public FTickableGameObj static ULGUIPrefabManagerObject* GetInstance(bool CreateIfNotValid = false); static bool IsSelected(AActor* InObject); static bool AnySelectedIsChildOf(AActor* InObject); - static UWorld* GetPreviewWorldForPrefabPackage(); + static UWorld* GetPreviewWorldForPrefabPackage(bool bCreate = true); static bool GetIsBlueprintCompiling(); static bool GetIsProcessingDelete(); private: @@ -111,8 +111,6 @@ class LGUI_API ULGUIPrefabWorldSubsystem : public UWorldSubsystem GENERATED_BODY() public: virtual bool ShouldCreateSubsystem(UObject* Outer) const override { return true; } - virtual void Initialize(FSubsystemCollectionBase& Collection)override {}; - virtual void Deinitialize()override {}; static ULGUIPrefabWorldSubsystem* GetInstance(UWorld* World); DECLARE_EVENT_OneParam(ULGUIPrefabWorldSubsystem, FDeserializeSession, const FGuid&); diff --git a/Source/LGUIEditor/Private/DetailCustomization/LGUICanvasCustomization.cpp b/Source/LGUIEditor/Private/DetailCustomization/LGUICanvasCustomization.cpp index 87a2e2300..097b1e768 100644 --- a/Source/LGUIEditor/Private/DetailCustomization/LGUICanvasCustomization.cpp +++ b/Source/LGUIEditor/Private/DetailCustomization/LGUICanvasCustomization.cpp @@ -493,26 +493,31 @@ FText FLGUICanvasCustomization::GetSortOrderInfo(TWeakObjectPtr Tar FText FLGUICanvasCustomization::GetDrawcallInfo()const { - auto LGUIManager = ULGUIManagerWorldSubsystem::GetInstance(TargetScriptArray[0]->GetWorld()); - if (TargetScriptArray.Num() > 0 && TargetScriptArray[0].IsValid() && LGUIManager) + if (TargetScriptArray.Num() > 0 && TargetScriptArray[0].IsValid()) { - auto& allCanvas = LGUIManager->GetCanvasArray(TargetScriptArray[0]->GetRenderMode()); - int allDrawcallCount = 0; - for (auto& canvasItem : allCanvas) + if (auto World = TargetScriptArray[0]->GetWorld()) { - if (TargetScriptArray[0]->GetActualRenderMode() == ELGUIRenderMode::RenderTarget) + if (auto LGUIManager = ULGUIManagerWorldSubsystem::GetInstance(World)) { - if (TargetScriptArray[0]->renderTarget == canvasItem->renderTarget && IsValid(canvasItem->renderTarget)) + auto& allCanvas = LGUIManager->GetCanvasArray(TargetScriptArray[0]->GetRenderMode()); + int allDrawcallCount = 0; + for (auto& canvasItem : allCanvas) { - allDrawcallCount += canvasItem->GetDrawcallCount(); + if (TargetScriptArray[0]->GetActualRenderMode() == ELGUIRenderMode::RenderTarget) + { + if (TargetScriptArray[0]->renderTarget == canvasItem->renderTarget && IsValid(canvasItem->renderTarget)) + { + allDrawcallCount += canvasItem->GetDrawcallCount(); + } + } + else + { + allDrawcallCount += canvasItem->GetDrawcallCount(); + } } - } - else - { - allDrawcallCount += canvasItem->GetDrawcallCount(); + return FText::FromString(FString::Printf(TEXT("%d/%d"), TargetScriptArray[0]->GetDrawcallCount(), allDrawcallCount)); } } - return FText::FromString(FString::Printf(TEXT("%d/%d"), TargetScriptArray[0]->GetDrawcallCount(), allDrawcallCount)); } return FText::FromString(FString::Printf(TEXT("0/0"))); }