Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/LGUI/Private/Core/LGUILifeCycleBehaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
14 changes: 13 additions & 1 deletion Source/LGUI/Private/PrefabSystem/LGUIPrefabManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions Source/LGUI/Public/PrefabSystem/LGUIPrefabManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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&);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,26 +493,31 @@ FText FLGUICanvasCustomization::GetSortOrderInfo(TWeakObjectPtr<ULGUICanvas> 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")));
}
Expand Down