From 2d4772fe3c8105e3172ea7c31cb8318b5f3f234b Mon Sep 17 00:00:00 2001 From: ManasMakde Date: Fri, 20 Dec 2024 15:44:11 +0530 Subject: [PATCH] Added Snippet: Virtual functions in c++, Added Snippet: Custom components in Unreal Engine C++, Added Snippet: Exposing Static Constant to Blueprint from Unreal Engine C++, Minor Fixes --- .../Cpp/virtual-functions-in-cpp/index.mdx | 12 ++++++ .../ue-custom-component/index.mdx | 20 +++++++++ .../ue-expose-static-constant-to-bp/index.mdx | 43 +++++++++++++++++++ .../index.mdx | 0 .../index.mdx | 0 .../index.mdx | 4 +- .../index.mdx | 0 _static/siteguide.json | 2 +- index.html | 2 +- .../cpp/virtual-functions-in-cpp/index.html | 1 + .../ue-custom-component/index.html | 9 ++++ .../index.html | 27 ++++++++++++ .../index.html | 0 .../index.html | 0 .../index.html | 2 +- .../index.html | 0 16 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 _mdx/snippets/Cpp/virtual-functions-in-cpp/index.mdx create mode 100644 _mdx/snippets/Unreal Engine/ue-custom-component/index.mdx create mode 100644 _mdx/snippets/Unreal Engine/ue-expose-static-constant-to-bp/index.mdx rename _mdx/snippets/Unreal Engine/{unreal-engine-udelegates => ue-udelegates}/index.mdx (100%) rename _mdx/snippets/Unreal Engine/{unreal-engine-uenums => ue-uenums}/index.mdx (100%) rename _mdx/snippets/Unreal Engine/{unreal-engine-uinterfaces => ue-uinterfaces}/index.mdx (94%) rename _mdx/snippets/Unreal Engine/{unreal-engine-ustructs => ue-ustructs}/index.mdx (100%) create mode 100644 snippets/cpp/virtual-functions-in-cpp/index.html create mode 100644 snippets/unreal-engine/ue-custom-component/index.html create mode 100644 snippets/unreal-engine/ue-expose-static-constant-to-bp/index.html rename snippets/unreal-engine/{unreal-engine-udelegates => ue-udelegates}/index.html (100%) rename snippets/unreal-engine/{unreal-engine-uenums => ue-uenums}/index.html (100%) rename snippets/unreal-engine/{unreal-engine-uinterfaces => ue-uinterfaces}/index.html (97%) rename snippets/unreal-engine/{unreal-engine-ustructs => ue-ustructs}/index.html (100%) diff --git a/_mdx/snippets/Cpp/virtual-functions-in-cpp/index.mdx b/_mdx/snippets/Cpp/virtual-functions-in-cpp/index.mdx new file mode 100644 index 0000000..62aa44f --- /dev/null +++ b/_mdx/snippets/Cpp/virtual-functions-in-cpp/index.mdx @@ -0,0 +1,12 @@ +import { HTMLSkeleton, H1 } from "./global.jsx" + + +export const snippet_title = "Virtual Functions in C++" +export const snippet_category = "C++" + + + + +

{snippet_title}

+ +
\ No newline at end of file diff --git a/_mdx/snippets/Unreal Engine/ue-custom-component/index.mdx b/_mdx/snippets/Unreal Engine/ue-custom-component/index.mdx new file mode 100644 index 0000000..02743a4 --- /dev/null +++ b/_mdx/snippets/Unreal Engine/ue-custom-component/index.mdx @@ -0,0 +1,20 @@ +import { HTMLSkeleton, H1 } from "./global.jsx" + +export const snippet_title = "Custom components in Unreal Engine C++" +export const snippet_category = "Unreal Engine" + + + +

{snippet_title}

+ +```cpp +#include "Components/ActorComponent.h" + +UCLASS(meta=(BlueprintSpawnableComponent)) // without this the component will not show in blueprints +class MYPROJECT_API UExampleComponent : public UActorComponent +{ + GENERATED_BODY() + +}; +``` +
\ No newline at end of file diff --git a/_mdx/snippets/Unreal Engine/ue-expose-static-constant-to-bp/index.mdx b/_mdx/snippets/Unreal Engine/ue-expose-static-constant-to-bp/index.mdx new file mode 100644 index 0000000..71ddf91 --- /dev/null +++ b/_mdx/snippets/Unreal Engine/ue-expose-static-constant-to-bp/index.mdx @@ -0,0 +1,43 @@ +import { HTMLSkeleton, H1 } from "./global.jsx" + +export const snippet_title = "Exposing Static Constant to Blueprint from C++ in Unreal Engine" +export const snippet_category = "Unreal Engine" + + + +

{snippet_title}

+ +**Note:** this is more of a workaround + +```cpp +// ExampleObject.h file + +UCLASS() +class MYPROJECT_API UExampleStatic : public UBlueprintFunctionLibrary +{ + GENERATED_BODY() + + public: + UFUNCTION(BlueprintPure) + static float GetMyConstant(); +}; + + +UCLASS() +class MYPROJECT_API UExampleObject : public UObject { + GENERATED_BODY() + + public: + static const float MY_CONSTANT; // Exposing to blueprints via Function Library + +}; +``` + +```cpp +// ExampleObject.cpp file + +const float UExampleObject::MY_CONSTANT = 10.5f; + +float UExampleStatic::GetMyConstant(){ return UExampleObject::MY_CONSTANT; } +``` +
\ No newline at end of file diff --git a/_mdx/snippets/Unreal Engine/unreal-engine-udelegates/index.mdx b/_mdx/snippets/Unreal Engine/ue-udelegates/index.mdx similarity index 100% rename from _mdx/snippets/Unreal Engine/unreal-engine-udelegates/index.mdx rename to _mdx/snippets/Unreal Engine/ue-udelegates/index.mdx diff --git a/_mdx/snippets/Unreal Engine/unreal-engine-uenums/index.mdx b/_mdx/snippets/Unreal Engine/ue-uenums/index.mdx similarity index 100% rename from _mdx/snippets/Unreal Engine/unreal-engine-uenums/index.mdx rename to _mdx/snippets/Unreal Engine/ue-uenums/index.mdx diff --git a/_mdx/snippets/Unreal Engine/unreal-engine-uinterfaces/index.mdx b/_mdx/snippets/Unreal Engine/ue-uinterfaces/index.mdx similarity index 94% rename from _mdx/snippets/Unreal Engine/unreal-engine-uinterfaces/index.mdx rename to _mdx/snippets/Unreal Engine/ue-uinterfaces/index.mdx index 6133ab8..d2033aa 100644 --- a/_mdx/snippets/Unreal Engine/unreal-engine-uinterfaces/index.mdx +++ b/_mdx/snippets/Unreal Engine/ue-uinterfaces/index.mdx @@ -1,4 +1,4 @@ -import { HTMLSkeleton, H1, H2, H3, LocalGuide } from "./global.jsx" +import { HTMLSkeleton, H1, H2, LocalGuide } from "./global.jsx" export const snippet_title = "UInterfaces in Unreal Engine C++" export const snippet_category = "Unreal Engine" @@ -59,7 +59,7 @@ class MYPROJECT_API IExampleInterface ... UCLASS() -class TESTING_API AExampleCharacter : public ACharacter, public IExampleInterface +class MYPROJECT_API AExampleCharacter : public ACharacter, public IExampleInterface { GENERATED_BODY() diff --git a/_mdx/snippets/Unreal Engine/unreal-engine-ustructs/index.mdx b/_mdx/snippets/Unreal Engine/ue-ustructs/index.mdx similarity index 100% rename from _mdx/snippets/Unreal Engine/unreal-engine-ustructs/index.mdx rename to _mdx/snippets/Unreal Engine/ue-ustructs/index.mdx diff --git a/_static/siteguide.json b/_static/siteguide.json index 79a8aac..a953b0e 100644 --- a/_static/siteguide.json +++ b/_static/siteguide.json @@ -1 +1 @@ -{"/snippets/unreal-engine/unreal-engine-udelegates/":{"category":"Unreal Engine","title":"UDelegates in Unreal Engine C++"},"/snippets/unreal-engine/unreal-engine-uenums/":{"category":"Unreal Engine","title":"UEnums in Unreal Engine C++"},"/snippets/unreal-engine/unreal-engine-uinterfaces/":{"category":"Unreal Engine","title":"UInterfaces in Unreal Engine C++"},"/snippets/unreal-engine/unreal-engine-ustructs/":{"category":"Unreal Engine","title":"UStructs in Unreal Engine C++"},"/snippets/cpp/cpp-hello-world/":{"category":"C++","title":"Hello World in C++"}} \ No newline at end of file +{"/snippets/unreal-engine/ue-uinterfaces/":{"category":"Unreal Engine","title":"UInterfaces in Unreal Engine C++"},"/snippets/unreal-engine/ue-udelegates/":{"category":"Unreal Engine","title":"UDelegates in Unreal Engine C++"},"/snippets/unreal-engine/ue-custom-component/":{"category":"Unreal Engine","title":"Custom components in Unreal Engine C++"},"/snippets/unreal-engine/ue-expose-static-constant-to-bp/":{"category":"Unreal Engine","title":"Exposing Static Constant to Blueprint from C++ in Unreal Engine"},"/snippets/unreal-engine/ue-uenums/":{"category":"Unreal Engine","title":"UEnums in Unreal Engine C++"},"/snippets/unreal-engine/ue-ustructs/":{"category":"Unreal Engine","title":"UStructs in Unreal Engine C++"},"/snippets/cpp/virtual-functions-in-cpp/":{"category":"C++","title":"Virtual Functions in C++"},"/snippets/cpp/cpp-hello-world/":{"category":"C++","title":"Hello World in C++"}} \ No newline at end of file diff --git a/index.html b/index.html index d81c5a7..9faa6dc 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -SourceSnippet

Welcome to SourceSnippet

- Years of experience, Stored in snippets


Unreal Engine

  1. UDelegates in Unreal Engine C++
  2. UEnums in Unreal Engine C++
  3. UInterfaces in Unreal Engine C++
  4. UStructs in Unreal Engine C++

C++

  1. Hello World in C++
\ No newline at end of file +SourceSnippet

Welcome to SourceSnippet

- Years of experience, Stored in snippets


Unreal Engine

  1. Custom components in Unreal Engine C++
  2. Exposing Static Constant to Blueprint from C++ in Unreal Engine
  3. UDelegates in Unreal Engine C++
  4. UEnums in Unreal Engine C++
  5. UInterfaces in Unreal Engine C++
  6. UStructs in Unreal Engine C++

C++

  1. Hello World in C++
  2. Virtual Functions in C++
\ No newline at end of file diff --git a/snippets/cpp/virtual-functions-in-cpp/index.html b/snippets/cpp/virtual-functions-in-cpp/index.html new file mode 100644 index 0000000..9793fe4 --- /dev/null +++ b/snippets/cpp/virtual-functions-in-cpp/index.html @@ -0,0 +1 @@ +Virtual Functions in C++ - SourceSnippet

Virtual Functions in C++



\ No newline at end of file diff --git a/snippets/unreal-engine/ue-custom-component/index.html b/snippets/unreal-engine/ue-custom-component/index.html new file mode 100644 index 0000000..31df394 --- /dev/null +++ b/snippets/unreal-engine/ue-custom-component/index.html @@ -0,0 +1,9 @@ +Custom components in Unreal Engine C++ - SourceSnippet

Custom components in Unreal Engine C++



#include "Components/ActorComponent.h"
+
+UCLASS(meta=(BlueprintSpawnableComponent)) // without this the component will not show in blueprints 
+class MYPROJECT_API UExampleComponent : public UActorComponent
+{
+    GENERATED_BODY()
+    
+};
+
\ No newline at end of file diff --git a/snippets/unreal-engine/ue-expose-static-constant-to-bp/index.html b/snippets/unreal-engine/ue-expose-static-constant-to-bp/index.html new file mode 100644 index 0000000..a000482 --- /dev/null +++ b/snippets/unreal-engine/ue-expose-static-constant-to-bp/index.html @@ -0,0 +1,27 @@ +Exposing Static Constant to Blueprint from C++ in Unreal Engine - SourceSnippet

Exposing Static Constant to Blueprint from C++ in Unreal Engine



Note: this is more of a workaround

// ExampleObject.h file
+
+UCLASS()
+class MYPROJECT_API UExampleStatic : public UBlueprintFunctionLibrary
+{
+    GENERATED_BODY()
+
+    public:
+        UFUNCTION(BlueprintPure)
+        static float GetMyConstant();
+};
+
+
+UCLASS()
+class MYPROJECT_API UExampleObject : public UObject {
+    GENERATED_BODY()
+    
+    public:
+      static const float MY_CONSTANT;  // Exposing to blueprints via Function Library
+
+};
+
// ExampleObject.cpp file
+
+const float UExampleObject::MY_CONSTANT = 10.5f;
+
+float UExampleStatic::GetMyConstant(){ return UExampleObject::MY_CONSTANT; }
+
\ No newline at end of file diff --git a/snippets/unreal-engine/unreal-engine-udelegates/index.html b/snippets/unreal-engine/ue-udelegates/index.html similarity index 100% rename from snippets/unreal-engine/unreal-engine-udelegates/index.html rename to snippets/unreal-engine/ue-udelegates/index.html diff --git a/snippets/unreal-engine/unreal-engine-uenums/index.html b/snippets/unreal-engine/ue-uenums/index.html similarity index 100% rename from snippets/unreal-engine/unreal-engine-uenums/index.html rename to snippets/unreal-engine/ue-uenums/index.html diff --git a/snippets/unreal-engine/unreal-engine-uinterfaces/index.html b/snippets/unreal-engine/ue-uinterfaces/index.html similarity index 97% rename from snippets/unreal-engine/unreal-engine-uinterfaces/index.html rename to snippets/unreal-engine/ue-uinterfaces/index.html index 761bd37..e33e066 100644 --- a/snippets/unreal-engine/unreal-engine-uinterfaces/index.html +++ b/snippets/unreal-engine/ue-uinterfaces/index.html @@ -33,7 +33,7 @@ ... UCLASS() -class TESTING_API AExampleCharacter : public ACharacter, public IExampleInterface +class MYPROJECT_API AExampleCharacter : public ACharacter, public IExampleInterface { GENERATED_BODY() diff --git a/snippets/unreal-engine/unreal-engine-ustructs/index.html b/snippets/unreal-engine/ue-ustructs/index.html similarity index 100% rename from snippets/unreal-engine/unreal-engine-ustructs/index.html rename to snippets/unreal-engine/ue-ustructs/index.html