Skip to content
Permalink
Browse files

Chapter 32. Writing Nodes for Script Canvas

  • Loading branch information
Aristo7 committed Aug 4, 2019
1 parent dfcc2de commit fd90386952f610c6dd95d99616e0b18f99438c71
@@ -0,0 +1,23 @@
#include "MyIncrementNode.h"

using namespace ScriptCanvas;

namespace MyProject
{
void MyIncrementNode::OnInputSignal(const SlotId&)
{
float value = MyIncrementNodeProperty::GetValue(this);

value++;

const SlotId resultSlotId =
MyIncrementNodeProperty::GetResultSlotId(this);
const Slot* slot = GetSlot(resultSlotId);
PushOutput(Datum(value), *slot);

SignalOutput(
MyIncrementNodeProperty::GetOutSlotId(this));
}
}

#include <Source/ScriptCanvas/MyIncrementNode.generated.cpp>
@@ -0,0 +1,37 @@
#pragma once
#include <ScriptCanvas/Core/Node.h>
#include <ScriptCanvas/CodeGen/CodeGen.h>
#include <Source/ScriptCanvas/MyIncrementNode.generated.h>

namespace MyProject
{
class MyIncrementNode : public ScriptCanvas::Node
{
ScriptCanvas_Node(MyIncrementNode,
ScriptCanvas_Node::Name("My Increment Node")
ScriptCanvas_Node::Uuid(
"{4C8D4A9A-D19B-496F-8E4F-2DA6D7DA194A}")
ScriptCanvas_Node::Description("Increments by one"));

protected:
// Inputs
ScriptCanvas_In(ScriptCanvas_In::Name("In", "desc"));
// Outputs
ScriptCanvas_Out(ScriptCanvas_Out::Name("Out", "desc"));

ScriptCanvas_Property(float,
ScriptCanvas_Property::Name("Value",
"The input value.")
ScriptCanvas_Property::Visibility(true)
ScriptCanvas_Property::Input);

ScriptCanvas_Property(float,
ScriptCanvas_Property::Name("Result",
"The input incremented by one.")
ScriptCanvas_Property::Visibility(true)
ScriptCanvas_Property::Output
ScriptCanvas_Property::OutputStorageSpec);

void OnInputSignal(const ScriptCanvas::SlotId&) override;
};
}
@@ -2,6 +2,7 @@
#include <AzCore/Serialization/EditContext.h>
#include <ScriptCanvas/Libraries/Libraries.h>
#include "MyScriptCanvasNode.h"
#include "MyIncrementNode.h"

using namespace MyProject;
using namespace ScriptCanvas;
@@ -24,12 +25,14 @@ void MyNodeLibrary::InitNodeRegistry(NodeRegistry& nr)
{
using namespace ScriptCanvas::Library;
AddNodeToRegistry<MyNodeLibrary, MyScriptCanvasNode>(nr);
AddNodeToRegistry<MyNodeLibrary, MyIncrementNode>(nr);
}

AZStd::vector<AZ::ComponentDescriptor*>
MyNodeLibrary::GetComponentDescriptors()
{
return {
MyScriptCanvasNode::CreateDescriptor(),
MyIncrementNode::CreateDescriptor(),
};
}
@@ -26,6 +26,8 @@
"Source/MyProjectSystemComponent.h"
],
"Source/ScriptCanvas": [
"Source/ScriptCanvas/MyIncrementNode.cpp",
"Source/ScriptCanvas/MyIncrementNode.h",
"Source/ScriptCanvas/MyNodeLibrary.cpp",
"Source/ScriptCanvas/MyNodeLibrary.h",
"Source/ScriptCanvas/MyScriptCanvasNode.cpp",
@@ -8,6 +8,7 @@ def build(bld):
AZ_CODEGEN_ARGS = az_code_gen = [{
'files' : [
'Source/ScriptCanvas/MyScriptCanvasNode.h',
'Source/ScriptCanvas/MyIncrementNode.h',
],
'scripts' : [
os.path.join(script_canvas_dir,

0 comments on commit fd90386

Please sign in to comment.
You can’t perform that action at this time.