AAAAAAAAAAAAAAA
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"BuildId": "27405482",
|
||||
"Modules":
|
||||
{
|
||||
"GuidFixer": "UnrealEditor-GuidFixer.dll"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 3,
|
||||
"VersionName": "1.2",
|
||||
"FriendlyName": "GUID Fixer",
|
||||
"Description": "Fixes asset lighting GUIDs for Swarm lightning builds and texture streaming builds.",
|
||||
"Category": "Other",
|
||||
"CreatedBy": "sophie",
|
||||
"CreatedByURL": "",
|
||||
"DocsURL": "",
|
||||
"MarketplaceURL": "",
|
||||
"SupportURL": "https://github.com/davisctools/UnrealGuidFixer/issues",
|
||||
"CanContainContent": false,
|
||||
"IsBetaVersion": false,
|
||||
"IsExperimentalVersion": false,
|
||||
"Installed": false,
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "GuidFixer",
|
||||
"Type": "Editor",
|
||||
"LoadingPhase": "Default"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,58 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class GuidFixer : ModuleRules
|
||||
{
|
||||
public GuidFixer(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add public include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
// ... add other public dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Projects",
|
||||
"InputCore",
|
||||
"EditorFramework",
|
||||
"UnrealEd",
|
||||
"ToolMenus",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
// ... add private dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
// ... add any modules that your module loads dynamically here ...
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "GuidFixer.h"
|
||||
|
||||
#include "GuidFixerStyle.h"
|
||||
#include "GuidFixerCommands.h"
|
||||
#include "Misc/MessageDialog.h"
|
||||
#include "ToolMenus.h"
|
||||
|
||||
static const FName GuidFixerTabName("GuidFixer");
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FGuidFixerModule"
|
||||
|
||||
void FGuidFixerModule::StartupModule()
|
||||
{
|
||||
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
||||
|
||||
FGuidFixerStyle::Initialize();
|
||||
FGuidFixerStyle::ReloadTextures();
|
||||
|
||||
FGuidFixerCommands::Register();
|
||||
|
||||
FixMaterialGuidsCommands = MakeShareable(new FUICommandList);
|
||||
|
||||
FixMaterialGuidsCommands->MapAction(
|
||||
FGuidFixerCommands::Get().FixMaterialGuids,
|
||||
FExecuteAction::CreateRaw(this, &FGuidFixerModule::FixMaterialGuids),
|
||||
FCanExecuteAction());
|
||||
|
||||
FixTextureGuidsCommands = MakeShareable(new FUICommandList);
|
||||
|
||||
FixTextureGuidsCommands->MapAction(
|
||||
FGuidFixerCommands::Get().FixTextureGuids,
|
||||
FExecuteAction::CreateRaw(this, &FGuidFixerModule::FixTextureGuids),
|
||||
FCanExecuteAction());
|
||||
|
||||
FixEngineTextureGuidsCommands = MakeShareable(new FUICommandList);
|
||||
|
||||
FixEngineTextureGuidsCommands->MapAction(
|
||||
FGuidFixerCommands::Get().FixEngineTextureGuids,
|
||||
FExecuteAction::CreateRaw(this, &FGuidFixerModule::FixEngineTextureGuids),
|
||||
FCanExecuteAction());
|
||||
|
||||
UToolMenus::RegisterStartupCallback(
|
||||
FSimpleMulticastDelegate::FDelegate::CreateRaw(this, &FGuidFixerModule::RegisterMenus));
|
||||
}
|
||||
|
||||
void FGuidFixerModule::ShutdownModule()
|
||||
{
|
||||
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
|
||||
// we call this function before unloading the module.
|
||||
|
||||
UToolMenus::UnRegisterStartupCallback(this);
|
||||
|
||||
UToolMenus::UnregisterOwner(this);
|
||||
|
||||
FGuidFixerStyle::Shutdown();
|
||||
|
||||
FGuidFixerCommands::Unregister();
|
||||
}
|
||||
|
||||
void FGuidFixerModule::RegisterMenus()
|
||||
{
|
||||
// Owner will be used for cleanup in call to UToolMenus::UnregisterOwner
|
||||
FToolMenuOwnerScoped OwnerScoped(this);
|
||||
|
||||
UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.MainMenu.Tools");
|
||||
{
|
||||
FToolMenuSection& Section = Menu->AddSection("GuidFixer", LOCTEXT("GUID Fixer", "GUID Fixer"));
|
||||
Section.AddMenuEntryWithCommandList(FGuidFixerCommands::Get().FixMaterialGuids, FixMaterialGuidsCommands);
|
||||
Section.AddMenuEntryWithCommandList(FGuidFixerCommands::Get().FixTextureGuids, FixTextureGuidsCommands);
|
||||
Section.AddMenuEntryWithCommandList(FGuidFixerCommands::Get().FixEngineTextureGuids, FixEngineTextureGuidsCommands);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is a modified version of laggyluk's SwarmGuidFixer
|
||||
// https://github.com/laggyluk/SwarmGuidFixer
|
||||
void FGuidFixerModule::FixMaterialGuids() const
|
||||
{
|
||||
TMap<FGuid, UMaterialInterface*> Guids;
|
||||
|
||||
bool bUpdatedGuids = false;
|
||||
for (TObjectIterator<UMaterialInterface> Material; Material; ++Material)
|
||||
{
|
||||
const FGuid& LightingGuid = Material->GetLightingGuid();
|
||||
|
||||
if (!LightingGuid.IsValid())
|
||||
{
|
||||
if (!IsDefaultObject(*Material->GetPathName()))
|
||||
{
|
||||
SetMaterialLightingGuid(*Material);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
UMaterialInterface** Result = Guids.Find(LightingGuid);
|
||||
if (Result == nullptr)
|
||||
{
|
||||
Guids.Add(LightingGuid, *Material);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update the initial material with the same GUID if its GUID hasn't been updated already
|
||||
if ((*Result)->GetLightingGuid() == LightingGuid && !IsDefaultObject((*Result)->GetPathName()))
|
||||
{
|
||||
SetMaterialLightingGuid(*Result);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
|
||||
if (!IsDefaultObject(*Material->GetPathName()))
|
||||
{
|
||||
SetMaterialLightingGuid(*Material);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
}
|
||||
|
||||
const FText DialogText = FText::FromString(!bUpdatedGuids
|
||||
? "No duplicate or empty material GUIDs found."
|
||||
: "At least one material GUID has been changed.\n"
|
||||
"Use \"Save All\" to save these changes.\n\n\n"
|
||||
"Check the Output Log to see which materials have been updated.");
|
||||
FMessageDialog::Open(EAppMsgType::Ok, DialogText);
|
||||
}
|
||||
|
||||
bool FGuidFixerModule::IsDefaultObject(FString Path) const
|
||||
{
|
||||
return Path.StartsWith("/Engine/")
|
||||
|| Path.StartsWith("/Script/LevelSequence.Default__LevelSequenceMediaController");
|
||||
}
|
||||
|
||||
void FGuidFixerModule::SetMaterialLightingGuid(UMaterialInterface* Material) const
|
||||
{
|
||||
if (!Material)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Material->SetLightingGuid();
|
||||
Material->Modify();
|
||||
UE_LOG(LogTemp, Display, TEXT("%s: Material lighting GUID updated."), *Material->GetPathName());
|
||||
}
|
||||
|
||||
void FGuidFixerModule::FixTextureGuids() const
|
||||
{
|
||||
TMap<FGuid, UTexture*> Guids;
|
||||
|
||||
bool bUpdatedGuids = false;
|
||||
for (TObjectIterator<UTexture> Texture; Texture; ++Texture)
|
||||
{
|
||||
const FGuid& LightingGuid = Texture->GetLightingGuid();
|
||||
|
||||
if (!LightingGuid.IsValid())
|
||||
{
|
||||
if (!IsDefaultObject(*Texture->GetPathName()))
|
||||
{
|
||||
SetTextureLightingGuid(*Texture);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
UTexture** Result = Guids.Find(LightingGuid);
|
||||
if (Result == nullptr)
|
||||
{
|
||||
Guids.Add(LightingGuid, *Texture);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update the initial material with the same GUID if its GUID hasn't been updated already
|
||||
if ((*Result)->GetLightingGuid() == LightingGuid && !IsDefaultObject((*Result)->GetPathName()))
|
||||
{
|
||||
SetTextureLightingGuid(*Result);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
|
||||
if (!IsDefaultObject(*Texture->GetPathName()))
|
||||
{
|
||||
SetTextureLightingGuid(*Texture);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
}
|
||||
|
||||
const FText DialogText = FText::FromString(!bUpdatedGuids
|
||||
? "No duplicate or empty texture GUIDs found."
|
||||
: "At least one texture GUID has been changed.\n"
|
||||
"Use \"Save All\" to save these changes.\n\n\n"
|
||||
"Check the Output Log to see which textures have been updated.");
|
||||
FMessageDialog::Open(EAppMsgType::Ok, DialogText);
|
||||
}
|
||||
|
||||
void FGuidFixerModule::SetTextureLightingGuid(UTexture* Texture) const
|
||||
{
|
||||
Texture->SetLightingGuid();
|
||||
Texture->Modify();
|
||||
UE_LOG(LogTemp, Display, TEXT("%s: Texture lighting GUID updated."), *Texture->GetPathName());
|
||||
}
|
||||
|
||||
void FGuidFixerModule::FixEngineTextureGuids() const
|
||||
{
|
||||
TMap<FGuid, UTexture*> Guids;
|
||||
|
||||
bool bUpdatedGuids = false;
|
||||
for (TObjectIterator<UTexture> Texture; Texture; ++Texture)
|
||||
{
|
||||
const FGuid& LightingGuid = Texture->GetLightingGuid();
|
||||
|
||||
if (!LightingGuid.IsValid())
|
||||
{
|
||||
if (IsDefaultObject(*Texture->GetPathName()))
|
||||
{
|
||||
SetTextureLightingGuid(*Texture);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
UTexture** Result = Guids.Find(LightingGuid);
|
||||
if (Result == nullptr)
|
||||
{
|
||||
Guids.Add(LightingGuid, *Texture);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update the initial material with the same GUID if its GUID hasn't been updated already
|
||||
if ((*Result)->GetLightingGuid() == LightingGuid && IsDefaultObject((*Result)->GetPathName()))
|
||||
{
|
||||
SetTextureLightingGuid(*Result);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
|
||||
if (IsDefaultObject(*Texture->GetPathName()))
|
||||
{
|
||||
SetTextureLightingGuid(*Texture);
|
||||
bUpdatedGuids = true;
|
||||
}
|
||||
}
|
||||
|
||||
const FText DialogText = FText::FromString(!bUpdatedGuids
|
||||
? "No duplicate or empty texture GUIDs found."
|
||||
: "At least one texture GUID has been changed.\n"
|
||||
"Use \"Save All\" to save these changes.\n\n\n"
|
||||
"Check the Output Log to see which textures have been updated.");
|
||||
FMessageDialog::Open(EAppMsgType::Ok, DialogText);
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FGuidFixerModule, GuidFixer)
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "GuidFixerCommands.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FGuidFixerModule"
|
||||
|
||||
void FGuidFixerCommands::RegisterCommands()
|
||||
{
|
||||
UI_COMMAND(FixMaterialGuids, "Fix Material GUIDs",
|
||||
"Fixes material lighting GUIDs so that there are no materials with empty or duplicate GUIDs.",
|
||||
EUserInterfaceActionType::Button, FInputChord());
|
||||
UI_COMMAND(FixTextureGuids, "Fix Texture GUIDs",
|
||||
"Fixes texture lighting GUIDs so that there are no textures with empty or duplicate GUIDs.",
|
||||
EUserInterfaceActionType::Button, FInputChord());
|
||||
UI_COMMAND(FixEngineTextureGuids, "Fix Engine Texture GUIDs",
|
||||
"Try this if you still have issues after fixing texture GUIDs.\n"
|
||||
"Since this touches engine files, it will report making changes after each editor restart.",
|
||||
EUserInterfaceActionType::Button, FInputChord());
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "GuidFixerStyle.h"
|
||||
#include "GuidFixer.h"
|
||||
#include "Framework/Application/SlateApplication.h"
|
||||
#include "Styling/SlateStyleRegistry.h"
|
||||
#include "Slate/SlateGameResources.h"
|
||||
#include "Interfaces/IPluginManager.h"
|
||||
#include "Styling/SlateStyleMacros.h"
|
||||
|
||||
#define RootToContentDir Style->RootToContentDir
|
||||
|
||||
TSharedPtr<FSlateStyleSet> FGuidFixerStyle::StyleInstance = nullptr;
|
||||
|
||||
void FGuidFixerStyle::Initialize()
|
||||
{
|
||||
if (!StyleInstance.IsValid())
|
||||
{
|
||||
StyleInstance = Create();
|
||||
FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
|
||||
}
|
||||
}
|
||||
|
||||
void FGuidFixerStyle::Shutdown()
|
||||
{
|
||||
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
|
||||
ensure(StyleInstance.IsUnique());
|
||||
StyleInstance.Reset();
|
||||
}
|
||||
|
||||
FName FGuidFixerStyle::GetStyleSetName()
|
||||
{
|
||||
static FName StyleSetName(TEXT("GuidFixerStyle"));
|
||||
return StyleSetName;
|
||||
}
|
||||
|
||||
|
||||
const FVector2D Icon40x40(40.0f, 40.0f);
|
||||
const FVector2D Icon64x64(64.0f, 64.0f);
|
||||
|
||||
TSharedRef< FSlateStyleSet > FGuidFixerStyle::Create()
|
||||
{
|
||||
TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("GuidFixerStyle"));
|
||||
Style->SetContentRoot(IPluginManager::Get().FindPlugin("GuidFixer")->GetBaseDir() / TEXT("Resources"));
|
||||
|
||||
Style->Set("GuidFixer.FixMaterialGuids", new IMAGE_BRUSH(TEXT("MaterialButtonIcon_64x"), Icon64x64));
|
||||
Style->Set("GuidFixer.FixTextureGuids", new IMAGE_BRUSH(TEXT("TextureButtonIcon_40x"), Icon40x40));
|
||||
Style->Set("GuidFixer.FixEngineTextureGuids", new IMAGE_BRUSH(TEXT("EngineTextureButtonIcon_40x"), Icon40x40));
|
||||
return Style;
|
||||
}
|
||||
|
||||
void FGuidFixerStyle::ReloadTextures()
|
||||
{
|
||||
if (FSlateApplication::IsInitialized())
|
||||
{
|
||||
FSlateApplication::Get().GetRenderer()->ReloadTextureResources();
|
||||
}
|
||||
}
|
||||
|
||||
const ISlateStyle& FGuidFixerStyle::Get()
|
||||
{
|
||||
return *StyleInstance;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class FToolBarBuilder;
|
||||
class FMenuBuilder;
|
||||
|
||||
class FGuidFixerModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
void FixMaterialGuids() const;
|
||||
void FixTextureGuids() const;
|
||||
void FixEngineTextureGuids() const;
|
||||
|
||||
|
||||
private:
|
||||
void RegisterMenus();
|
||||
|
||||
bool IsDefaultObject(FString Path) const;
|
||||
|
||||
void SetMaterialLightingGuid(UMaterialInterface* Material) const;
|
||||
void SetTextureLightingGuid(UTexture* Texture) const;
|
||||
|
||||
private:
|
||||
TSharedPtr<class FUICommandList> FixMaterialGuidsCommands;
|
||||
TSharedPtr<class FUICommandList> FixTextureGuidsCommands;
|
||||
TSharedPtr<class FUICommandList> FixEngineTextureGuidsCommands;
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Framework/Commands/Commands.h"
|
||||
#include "GuidFixerStyle.h"
|
||||
|
||||
class FGuidFixerCommands : public TCommands<FGuidFixerCommands>
|
||||
{
|
||||
public:
|
||||
|
||||
FGuidFixerCommands()
|
||||
: TCommands<FGuidFixerCommands>(TEXT("GuidFixer"), NSLOCTEXT("Contexts", "GuidFixer", "GuidFixer Plugin"), NAME_None, FGuidFixerStyle::GetStyleSetName())
|
||||
{
|
||||
}
|
||||
|
||||
// TCommands<> interface
|
||||
virtual void RegisterCommands() override;
|
||||
|
||||
public:
|
||||
TSharedPtr< FUICommandInfo > FixMaterialGuids;
|
||||
TSharedPtr< FUICommandInfo > FixTextureGuids;
|
||||
TSharedPtr< FUICommandInfo > FixEngineTextureGuids;
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Styling/SlateStyle.h"
|
||||
|
||||
class FGuidFixerStyle
|
||||
{
|
||||
public:
|
||||
|
||||
static void Initialize();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
/** reloads textures used by slate renderer */
|
||||
static void ReloadTextures();
|
||||
|
||||
/** @return The Slate style set for the Shooter game */
|
||||
static const ISlateStyle& Get();
|
||||
|
||||
static FName GetStyleSetName();
|
||||
|
||||
private:
|
||||
|
||||
static TSharedRef< class FSlateStyleSet > Create();
|
||||
|
||||
private:
|
||||
|
||||
static TSharedPtr< class FSlateStyleSet > StyleInstance;
|
||||
};
|
||||
Reference in New Issue
Block a user