From 0aba7911a2430995900b88b4bbc1f93d32d4ae18 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Thu, 10 Jun 2021 14:44:00 -0500 Subject: [PATCH] Implemented the DefaultProject Template default constructor and destructor The System Component now implements a constructor/destructor which is used to initialize/de-initialize the `${SanitizedCppName}Interface` instance --- .../Code/Source/${Name}SystemComponent.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Templates/DefaultProject/Template/Code/Source/${Name}SystemComponent.cpp b/Templates/DefaultProject/Template/Code/Source/${Name}SystemComponent.cpp index 82f7d7d17b..0d160bd45a 100644 --- a/Templates/DefaultProject/Template/Code/Source/${Name}SystemComponent.cpp +++ b/Templates/DefaultProject/Template/Code/Source/${Name}SystemComponent.cpp @@ -58,6 +58,22 @@ namespace ${SanitizedCppName} { AZ_UNUSED(dependent); } + + ${SanitizedCppName}SystemComponent::${SanitizedCppName}SystemComponent() + { + if (${SanitizedCppName}Interface::Get() == nullptr) + { + ${SanitizedCppName}Interface::Register(this); + } + } + + ${SanitizedCppName}SystemComponent::~${SanitizedCppName}SystemComponent() + { + if (${SanitizedCppName}Interface::Get() == this) + { + ${SanitizedCppName}Interface::Unregister(this); + } + } void ${SanitizedCppName}SystemComponent::Init() {