create light from function?

Is it possible to create a light using a void function, instead of creating a new class and spawning an actor? (in editor from a plugin, not at runtime)

for example, I have: (mostly copied from the lightswitch tutorial)

.h


#pragma once

#include "GameFramework/Actor.h"
#include "vpCreate.generated.h"

UCLASS()
class  AvpCreate : public AActor
{
	GENERATED_BODY()
public:
	/** point light component */
	UPROPERTY()
	class UPointLightComponent* PointLight1;
	
	AvpCreate(const FObjectInitializer& ObjectInitializer);

	UFUNCTION()
	static void MakePLight(FString PLightName, FVector location);
};


.cpp


#include "m2uPluginPrivatePCH.h"
#include "vpCreate.h"

AvpCreate::AvpCreate(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	PointLight1 = ObjectInitializer.CreateDefaultSubobject<UPointLightComponent>(this, "PointLight1");
}

void AvpCreate::MakePLight(FString PLightName, FVector location)
{
	
}

Can I create a light with the MakePLight function? So that I can call it from another class? If so, do i even need the ObjectInitializer stuff?

thanks!

I guess you’d have to spawn it with
GetWorld()->SpawnActor<>(…)?

Will that work in editor though? Or just at runtime?

Ah, now I get what you want.
I’m not very experienced : P.

Why do you want to spawn actors by a plugin?
Anyway, I suppose you’d want to use ALight to spawn a light. Since you can’t spawn components.
I don’t know how you’d hook it up to the editor, though : /.


FTransform ActorTransform = FTransform::Identity;
GEditor->AddActor(GEditor->GetEditorWorldContext().World()->GetCurrentLevel(), UCLASS_HERE, ActorTransform);

Thanks! works great.