├── Config ├── DefaultEditor.ini ├── DefaultGame.ini └── DefaultEngine.ini ├── .gitattributes ├── Content ├── Map.umap └── ConnectorActor.uasset ├── Source ├── ComponentViz │ ├── Public │ │ ├── ComponentViz.h │ │ └── Connector.h │ ├── Private │ │ ├── ComponentViz.cpp │ │ └── Connector.cpp │ └── ComponentViz.Build.cs ├── ComponentVizEditor │ ├── Public │ │ ├── ComponentVizEditor.h │ │ └── ConnectorVisualizer.h │ ├── ComponentVizEditor.Build.cs │ └── Private │ │ ├── ComponentVizEditor.cpp │ │ └── ConnectorVisualizer.cpp ├── ComponentViz.Target.cs └── ComponentVizEditor.Target.cs ├── ComponentViz.uproject └── .gitignore /Config/DefaultEditor.ini: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Content/Map.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sutheim/UE4-ComponentVisualizer-Example/HEAD/Content/Map.umap -------------------------------------------------------------------------------- /Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | 2 | [/Script/EngineSettings.GeneralProjectSettings] 3 | ProjectID=5F391F0949A582DF7EBF87BB74FEF370 4 | -------------------------------------------------------------------------------- /Content/ConnectorActor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sutheim/UE4-ComponentVisualizer-Example/HEAD/Content/ConnectorActor.uasset -------------------------------------------------------------------------------- /Source/ComponentViz/Public/ComponentViz.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | -------------------------------------------------------------------------------- /Source/ComponentViz/Private/ComponentViz.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "ComponentViz.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, ComponentViz, "ComponentViz" ); 7 | -------------------------------------------------------------------------------- /Source/ComponentVizEditor/Public/ComponentVizEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Modules/ModuleInterface.h" 3 | #include "Modules/ModuleManager.h" 4 | 5 | class FComponentVizEditorModule : public IModuleInterface 6 | { 7 | public: 8 | virtual void StartupModule() override; 9 | virtual void ShutdownModule() override; 10 | }; -------------------------------------------------------------------------------- /ComponentViz.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.25", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "ComponentViz", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default", 11 | "AdditionalDependencies": [ 12 | "Engine" 13 | ] 14 | }, 15 | { 16 | "Name": "ComponentVizEditor", 17 | "Type": "Editor", 18 | "LoadingPhase": "PostEngineInit" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /Source/ComponentVizEditor/Public/ConnectorVisualizer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ComponentVisualizer.h" 3 | 4 | class COMPONENTVIZEDITOR_API FConnectorVisualizer : public FComponentVisualizer 5 | { 6 | private: 7 | // This is the only method we need to override from FComponentVisualizer for this example 8 | virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override; 9 | }; 10 | -------------------------------------------------------------------------------- /Source/ComponentViz.Target.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class ComponentVizTarget : TargetRules 7 | { 8 | public ComponentVizTarget( TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Game; 11 | DefaultBuildSettings = BuildSettingsVersion.V2; 12 | ExtraModuleNames.AddRange( new string[] { "ComponentViz" } ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/ComponentVizEditor.Target.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class ComponentVizEditorTarget : TargetRules 7 | { 8 | public ComponentVizEditorTarget( TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Editor; 11 | DefaultBuildSettings = BuildSettingsVersion.V2; 12 | ExtraModuleNames.AddRange( new string[] { "ComponentViz", "ComponentVizEditor" } ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/ComponentVizEditor/ComponentVizEditor.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class ComponentVizEditor : ModuleRules 4 | { 5 | public ComponentVizEditor(ReadOnlyTargetRules Target) : base(Target) 6 | { 7 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 8 | // ComponentViz needed for the objects we're visualizing 9 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "Engine", "CoreUObject", "ComponentViz" }); 10 | // Needed for our editor logic 11 | PrivateDependencyModuleNames.AddRange(new string[] { "UnrealEd" }); 12 | } 13 | } -------------------------------------------------------------------------------- /Config/DefaultEngine.ini: -------------------------------------------------------------------------------- 1 | 2 | 3 | [/Script/HardwareTargeting.HardwareTargetingSettings] 4 | TargetedHardwareClass=Desktop 5 | AppliedTargetedHardwareClass=Desktop 6 | DefaultGraphicsPerformance=Maximum 7 | AppliedDefaultGraphicsPerformance=Maximum 8 | 9 | [/Script/Engine.Engine] 10 | +ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/ComponentViz") 11 | +ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/ComponentViz") 12 | +ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="ComponentVizGameModeBase") 13 | 14 | [/Script/EngineSettings.GameMapsSettings] 15 | EditorStartupMap=/Game/Map.Map 16 | GameDefaultMap=/Game/Map.Map 17 | 18 | -------------------------------------------------------------------------------- /Source/ComponentViz/Public/Connector.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Components/ActorComponent.h" 7 | #include "Connector.generated.h" 8 | 9 | 10 | UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) 11 | class COMPONENTVIZ_API UConnector : public UActorComponent 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | UConnector(); 17 | 18 | // Array to hold the targets 19 | UPROPERTY(BlueprintReadWrite, EditInstanceOnly) 20 | TArray targets; 21 | 22 | protected: 23 | virtual void BeginPlay() override; 24 | 25 | public: 26 | virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; 27 | }; 28 | -------------------------------------------------------------------------------- /Source/ComponentViz/ComponentViz.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class ComponentViz : ModuleRules 6 | { 7 | public ComponentViz(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); 12 | 13 | PrivateDependencyModuleNames.AddRange(new string[] { }); 14 | 15 | // Uncomment if you are using Slate UI 16 | // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); 17 | 18 | // Uncomment if you are using online features 19 | // PrivateDependencyModuleNames.Add("OnlineSubsystem"); 20 | 21 | // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/ComponentViz/Private/Connector.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Connector.h" 5 | 6 | // Sets default values for this component's properties 7 | UConnector::UConnector() 8 | { 9 | // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features 10 | // off to improve performance if you don't need them. 11 | PrimaryComponentTick.bCanEverTick = true; 12 | 13 | // ... 14 | } 15 | 16 | 17 | // Called when the game starts 18 | void UConnector::BeginPlay() 19 | { 20 | Super::BeginPlay(); 21 | 22 | // ... 23 | 24 | } 25 | 26 | 27 | // Called every frame 28 | void UConnector::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) 29 | { 30 | Super::TickComponent(DeltaTime, TickType, ThisTickFunction); 31 | 32 | // ... 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Source/ComponentVizEditor/Private/ComponentVizEditor.cpp: -------------------------------------------------------------------------------- 1 | #include "ComponentVizEditor.h" 2 | #include "UnrealEd.h" 3 | #include "ConnectorVisualizer.h" 4 | #include "Connector.h" 5 | 6 | // Actually registers the module 7 | IMPLEMENT_GAME_MODULE(FComponentVizEditorModule, ComponentVizEditor); 8 | 9 | void FComponentVizEditorModule::StartupModule() 10 | { 11 | if (GUnrealEd) 12 | { 13 | // Make a new instance of the visualizer 14 | TSharedPtr visualizer = MakeShareable(new FConnectorVisualizer()); 15 | 16 | // Register it to our specific component class 17 | GUnrealEd->RegisterComponentVisualizer(UConnector::StaticClass()->GetFName(), visualizer); 18 | visualizer->OnRegister(); 19 | } 20 | } 21 | 22 | void FComponentVizEditorModule::ShutdownModule() 23 | { 24 | if (GUnrealEd) 25 | { 26 | // Unregister when the module shuts down 27 | GUnrealEd->UnregisterComponentVisualizer(UConnector::StaticClass()->GetFName()); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio 2015 user specific files 2 | .vs/ 3 | .vscode/ 4 | 5 | # Compiled Object files 6 | *.slo 7 | *.lo 8 | *.o 9 | *.obj 10 | 11 | # Precompiled Headers 12 | *.gch 13 | *.pch 14 | 15 | # Compiled Dynamic libraries 16 | *.so 17 | *.dylib 18 | *.dll 19 | 20 | # Fortran module files 21 | *.mod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | *.ipa 34 | 35 | # These project files can be generated by the engine 36 | *.xcodeproj 37 | *.code-workspace 38 | *.xcworkspace 39 | *.sln 40 | *.suo 41 | *.opensdf 42 | *.sdf 43 | *.VC.db 44 | *.VC.opendb 45 | 46 | # Precompiled Assets 47 | SourceArt/**/*.png 48 | SourceArt/**/*.tga 49 | 50 | # Binary Files 51 | Binaries/* 52 | Plugins/*/Binaries/* 53 | 54 | # Builds 55 | Build/* 56 | 57 | # Whitelist PakBlacklist-.txt files 58 | !Build/*/ 59 | Build/*/** 60 | !Build/*/PakBlacklist*.txt 61 | 62 | # Don't ignore icon files in Build 63 | !Build/**/*.ico 64 | 65 | # Built data for maps 66 | *_BuiltData.uasset 67 | 68 | # Configuration files generated by the Editor 69 | Saved/* 70 | 71 | # Compiled source files for the engine to use 72 | Intermediate/* 73 | Plugins/*/Intermediate/* 74 | 75 | # Cache files for the editor to use 76 | DerivedDataCache/* 77 | -------------------------------------------------------------------------------- /Source/ComponentVizEditor/Private/ConnectorVisualizer.cpp: -------------------------------------------------------------------------------- 1 | #include "ConnectorVisualizer.h" 2 | #include "Connector.h" 3 | 4 | // Contains most of the stuff you need for visualization 5 | #include "SceneManagement.h" 6 | 7 | void FConnectorVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) 8 | { 9 | // Cast the incoming component to our UConnector class 10 | const UConnector* connector = Cast(Component); 11 | 12 | // Draw a cylinder around the object because why not 13 | DrawWireCylinder(PDI, 14 | connector->GetOwner()->GetActorLocation(), 15 | FVector(1, 0, 0), // The cylinder matrix, here it's just static 16 | FVector(0, 1, 0), 17 | FVector(0, 0, 1), 18 | FLinearColor(0, 0, 1), // Blue color 19 | 75, 75, 12, // Various measurements for the cylinder 20 | SDPG_Foreground, // Will render on top of everything 21 | 2.f // Line width 22 | ); 23 | 24 | // Loop over all the actors in the array 25 | for (int i = 0; i < connector->targets.Num(); i++) 26 | { 27 | // Grab it from the array and verify that it's valid, as indicies can be empty 28 | AActor* target = connector->targets[i]; 29 | if (target) 30 | { 31 | // Draw a line between the actor of the component and the target from the array 32 | PDI->DrawLine( 33 | connector->GetOwner()->GetActorLocation(), 34 | target->GetActorLocation(), 35 | FLinearColor(1.f, 0.f, 0.f), // Red color 36 | SDPG_World, // Will not render over other things 37 | 2.0f); // Line width 38 | } 39 | } 40 | } 41 | --------------------------------------------------------------------------------