I made a C++ code for a custom blueprint node, but I can’t see it in the graph editor. Did I forget to do something. This is my code.
Header
#pragma once
#include "EdGraph/EdGraphNode.h"
#include "EdGraph/EdGraphSchema.h"
#include "RenderViewToTexture.generated.h"
/**
*
*/
UCLASS()
class URenderViewToTexture : public UEdGraphNode
{
GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintPure, meta = (HidePin = "Render View to Texture", DefaultToSelf = "Render View to Texture", FriendlyName = "Render View to Texture", CompactNodeTitle = "Render", Keywords = "render view texture camera"), Category = "Test")
static float RenderView(UCameraComponent* cameraView);
};
CPP:
#include "Coding.h"
#include "RenderViewToTexture.h"
URenderViewToTexture::URenderViewToTexture(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
float URenderViewToTexture::RenderView(UCameraComponent* cameraView)
{
return 1;
}
cancel
February 3, 2015, 7:56am
2
Change your .h to this:
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "RenderViewToTexture.generated.h"
/**
*
*/
UCLASS()
class URenderViewToTexture : public UBlueprintFunctionLibrary
{
GENERATED_UCLASS_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "Test")
static float RenderView(class UCameraComponent* cameraView);
};
And your .cpp to this:
#include "Coding.h"
#include "RenderViewToTexture.h"
float URenderViewToTexture::RenderView(UCameraComponent* cameraView)
{
return 1.0f;
}
I finally got it to work, though I left in the constructor in the cpp because it gave a bunch of errors without it.
Thanks a lot, cancel.
Though all the tutorials I found used EdGraphNode.h and EdGraphSchema.h. Was there a recent change or is something else?
cancel
February 3, 2015, 2:51pm
4
Those tutorials are wrong, unless you are making a custom node with special behavior, like the Timeline node or the Cast node. If your node just has simple in/out functionality, like a function, then you don’t need to inherit from those classes. I think one of the tutorials on the wiki inherits from those unnecessarily, and it’s wrong.
Also, sorry about that: you do need the constructor if you use GENERATED_UCLASS_BODY(), but not if you use GENERATED_BODY() instead. If you change it to that, you can get rid of the constructor. Sorry about that.