The problem:
I am trying to make a custom curve asset type in Unreal Engine and add it to the menu so that users can create the curve asset. My asset is called RecoilPattern
, which inherits from UCurveFloat
. The asset displays fine when I Right click in content browser and go to miscellaneous section. The problem is, when I go to the original Curve
asset and create a Float Curve
it is creating a Recoil Pattern
.
How can I fix this?
For reference, here is my code:
RecoilPatternModule.h:
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "RecoilPatternActions.h"
class FRecoilPatternModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
private:
TSharedPtr<FRecoilPatternAssetTypeActions> RecoilPatternAssetTypeActions;
};
RecoilPatternModule.cpp:
#include "RecoilPatternModule.h"
#define LOCTEXT_NAMESPACE "FRecoilPatternModule"
void FRecoilPatternModule::StartupModule()
{
RecoilPatternAssetTypeActions = MakeShared<FRecoilPatternAssetTypeActions>();
FAssetToolsModule::GetModule().Get().RegisterAssetTypeActions(RecoilPatternAssetTypeActions.ToSharedRef());
}
void FRecoilPatternModule::ShutdownModule()
{
if (!FModuleManager::Get().IsModuleLoaded("AssetTools")) return;
FAssetToolsModule::GetModule().Get().UnregisterAssetTypeActions(RecoilPatternAssetTypeActions.ToSharedRef());
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FRecoilPatternModule, RecoilPattern)
RecoilPatternFactory.h:
#pragma once
#include "CoreMinimal.h"
#include "Factories/Factory.h"
#include "RecoilPatternFactory.generated.h"
/**
* Factory that creates recoil curve assets
*/
UCLASS(MinimalAPI)
class URecoilPatternFactory : public UFactory
{
GENERATED_UCLASS_BODY()
// UFactory interface
URecoilPatternFactory();
UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn);
// End of UFactory interface
};
RecoilPatternFactory.cpp:
#include "RecoilPatternFactory.h"
#include "RecoilPattern.h"
URecoilPatternFactory::URecoilPatternFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
SupportedClass = URecoilPattern::StaticClass();
bCreateNew = true;
}
UObject* URecoilPatternFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{
return NewObject<URecoilPattern>(InParent, Class, Name, Flags, Context);
}
RecoilPatternActions.h:
#pragma once
#include "CoreMinimal.h"
#include "AssetTypeActions_Base.h"
class FRecoilPatternAssetTypeActions : public FAssetTypeActions_Base
{
public:
FText GetName() const override;
UClass* GetSupportedClass() const override;
FColor GetTypeColor() const override;
uint32 GetCategories() override;
};
RecoilPatternActions.cpp:
#include "RecoilPatternActions.h"
#include "RecoilPattern.h"
UClass* FRecoilPatternAssetTypeActions::GetSupportedClass() const
{
return URecoilPattern::StaticClass();
}
FText FRecoilPatternAssetTypeActions::GetName() const
{
return INVTEXT("Recoil Pattern");
}
FColor FRecoilPatternAssetTypeActions::GetTypeColor() const
{
return FColor(78, 40, 165);
}
uint32 FRecoilPatternAssetTypeActions::GetCategories()
{
return EAssetTypeCategories::Misc;
}
RecoilPattern.h:
#pragma once
#include "CoreMinimal.h"
#include "Curves/CurveFloat.h"
class URecoilPattern : public UCurveFloat
{
};
RecoilPattern.cpp:
#include "RecoilPattern.h"