How do you delete or rename a component you've made?

Let’s pretend I created this component and literally called it “NewBoxComponent”.
:laughing:

Now that I made it and it compiles it occurs to me that I don’t really know how to properly delete this and remake it. There’s no way I want to look for NewBox every time I add one. I see I can rename it in a few places but I don’t want it to just change the instance by accident. As we’ve seen the name is kept throughout the code but I need the component to be called TriggerVolume or whatever. There’s probably an easy fix for this, right?

Well the easiest fix is to just delete the class by deleting the C++ files, refreshing the project files (right click the ,.uproject or use Tools > Refresh Code Project in Unreal) and then rebuilding.

2 Likes

Is that all there is to it? I guess I was overcomplicating it.

So then clicking create C++ component is like using a wizard and it is just creating these files and filling them with that basic text for you? That makes enough sense.

There are “template” files in Engine\Content\Editor\Templates that will be copied over and then find and replaced e.g. this is ActorComponentClass.h.template

%COPYRIGHT_LINE%

#pragma once

#include "CoreMinimal.h"
%BASE_CLASS_INCLUDE_DIRECTIVE%
#include "%UNPREFIXED_CLASS_NAME%.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class %CLASS_MODULE_API_MACRO%%PREFIXED_CLASS_NAME% : public %PREFIXED_BASE_CLASS_NAME%
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	%PREFIXED_CLASS_NAME%();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

	%CLASS_FUNCTION_DECLARATIONS%	
	%CLASS_PROPERTIES%
};

The program will have a couple variables for those %THINGS% and be used to replace them.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms