Actor Component Plugin

I’m attempting to write an actor component plugin much like the Custom Mesh Component that exists in the engine source. I can’t seem to get my component to show up in the list of available components.

The one thing I can see as a difference between mine and the Custom Mesh Component is the .generated.inl file that’s included in CustomMeshComponentPlugin.cpp.

Code below

MyPlugin.uplugin


{
    "PluginFileVersion" : 1,
	
	"FriendlyName" : "My Plugin",
	"Version" : 1,
	"VersionName" : "1.0",
	"CreatedBy" : "overlawled",
	"CreatedByURL" : "",
	"MinEngineVersion" : 1579795,
	"Description" : "My plugin",
	"CategoryPath" : "Utilities",
	
    "Modules" :
	
		{
			"Name" : "MyPlugin",
			"Type" : "Runtime"
		}
	]
}

MyPlugin.Build.cs


// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

namespace UnrealBuildTool.Rules
{
    public class MyPlugin : ModuleRules
    {
        public MyPlugin(TargetInfo Target)
        {
            PrivateIncludePaths.Add("MyPlugin/Private");

            PublicDependencyModuleNames.AddRange(
                new string]
				{
					"Core",
					"CoreUObject",
                    "Engine",
				}
            );
        }
    }
}


MyPluginPrivatePCH.h


// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#include "CoreUObject.h"
#include "Engine.h"

// You should place include statements to your module's private header files here.  You only need to
// add includes for headers that are used in most of your module's source files though.
#include "MyPlugin.h"

#include "MyPluginComponent.h"

IMyPlugin.h


// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "ModuleManager.h"


/**
* The public interface to this module
*/
class IMyPlugin : public IModuleInterface
{

public:

	/**
	* Singleton-like access to this module's interface.  This is just for convenience!
	* Beware of calling this during the shutdown phase, though.  Your module might have been unloaded already.
	*
	* @return Returns singleton instance, loading the module on demand if needed
	*/
	static inline IMyPlugin& Get()
	{
		return FModuleManager::LoadModuleChecked< IMyPlugin >("MyPlugin");
	}

	/**
	* Checks to see if this module is loaded and ready.  It is only valid to call Get() if IsAvailable() returns true.
	*
	* @return True if the module is loaded and ready to use
	*/
	static inline bool IsAvailable()
	{
		return FModuleManager::Get().IsModuleLoaded("MyPlugin");
	}
};

MyPlugin.cpp


#include "MyPluginPrivatePCH.h"

//#include "MyPluginComponent.generated.inl"


class FMyPlugin : public IMyPlugin
{
	/** IModuleInterface implementation */
	virtual void StartupModule() OVERRIDE;
	virtual void ShutdownModule() OVERRIDE;
};

IMPLEMENT_MODULE(FMyPlugin, MyPluginComponent)



void FMyPlugin::StartupModule()
{

}


void FMyPlugin::ShutdownModule()
{

}

MyPluginComponent.h


// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "Components/ActorComponent.h"
#include "MyPluginComponent.generated.h"

/**
*
*/
UCLASS(hidecategories = (Object, LOD, Physics, Collision), editinlinenew, meta = (BlueprintSpawnableComponent), ClassGroup = Utility)
class UMyPluginComponent : public UActorComponent
{
	GENERATED_UCLASS_BODY()

};

MyPluginComponent.cpp


// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. 

#include "MyPluginPrivatePCH.h"

UMyPluginComponent::UMyPluginComponent(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{

}

Any help would be much appreciated!

Hi Overlawled,

You need to include MyPlugin.generated.inl somewhere in your module, which includes/registers the reflection data for any UObject classes you declare in your module.

Cheers,
Michael Noland

Michael,

When I do it says it can’t be found. Since this is plugin code I hadn’t made it through the editor, is that why it can’t be found? And if so, is there a way when adding code through the editor to specify the directory?

Edit: I thought I should also mention that MyPluginComponent.generated.h is being made, but not MyPluginComponent.generated.inl

Hi overlawled,

There’s just one inl for the whole module, so it’ll be named ModuleName.generated.inl, not YourClassName.generated.inl. If that doesn’t work either, can you check in: Intermediate\Build\Win64\Inc[ModuleName] and list what files are in there?

Cheers,
Michael Noland

Thank you so much!