# Table of Contents - [Home | UnrealSharp](#home-unrealsharp) - [FAQ | UnrealSharp](#faq-unrealsharp) - [Debugging | UnrealSharp](#debugging-unrealsharp) - [Setup | UnrealSharp](#setup-unrealsharp) - [Known Issues | UnrealSharp](#known-issues-unrealsharp) - [Module Lifecycle | UnrealSharp](#module-lifecycle-unrealsharp) - [Packaging | UnrealSharp](#packaging-unrealsharp) - [Create New Plugin | UnrealSharp](#create-new-plugin-unrealsharp) - [C# Plugins | UnrealSharp](#c-plugins-unrealsharp) - [Your First Script | UnrealSharp](#your-first-script-unrealsharp) - [Logging | UnrealSharp](#logging-unrealsharp) - [Add C# To Existing Plugin | UnrealSharp](#add-c-to-existing-plugin-unrealsharp) - [C++ Properties with Getters/Setters | UnrealSharp](#c-properties-with-getters-setters-unrealsharp) - [C++ Functions As C# Properties | UnrealSharp](#c-functions-as-c-properties-unrealsharp) - [Classes | UnrealSharp](#classes-unrealsharp) - [Enums | UnrealSharp](#enums-unrealsharp) - [Interfaces | UnrealSharp](#interfaces-unrealsharp) - [Subsystems | UnrealSharp](#subsystems-unrealsharp) - [Properties | UnrealSharp](#properties-unrealsharp) - [Structs | UnrealSharp](#structs-unrealsharp) - [Meta Data | UnrealSharp](#meta-data-unrealsharp) - [Custom C# Getter / Setter | UnrealSharp](#custom-c-getter-setter-unrealsharp) - [Functions | UnrealSharp](#functions-unrealsharp) - [Delegates | UnrealSharp](#delegates-unrealsharp) - [Default Actor Components | UnrealSharp](#default-actor-components-unrealsharp) - [Flags | UnrealSharp](#flags-unrealsharp) - [Collections | UnrealSharp](#collections-unrealsharp) - [Primary Data Assets | UnrealSharp](#primary-data-assets-unrealsharp) - [Helper Methods | UnrealSharp](#helper-methods-unrealsharp) - [TArray | UnrealSharp](#tarray-unrealsharp) - [Replicated Properties | UnrealSharp](#replicated-properties-unrealsharp) - [TNativeArray | UnrealSharp](#tnativearray-unrealsharp) - [Loading Soft References | UnrealSharp](#loading-soft-references-unrealsharp) - [TSet | UnrealSharp](#tset-unrealsharp) - [Multiplayer | UnrealSharp](#multiplayer-unrealsharp) - [Async | UnrealSharp](#async-unrealsharp) - [Loading Primary Data Assets | UnrealSharp](#loading-primary-data-assets-unrealsharp) - [Static Variables | UnrealSharp](#static-variables-unrealsharp) - [TMap | UnrealSharp](#tmap-unrealsharp) - [Developer Settings | UnrealSharp](#developer-settings-unrealsharp) - [Gameplay Tags | UnrealSharp](#gameplay-tags-unrealsharp) - [Trace Channels | UnrealSharp](#trace-channels-unrealsharp) - [FGameStaticVar | UnrealSharp](#fgamestaticvar-t-unrealsharp) - [RPCs (Remote Procedure Calls) | UnrealSharp](#rpcs-remote-procedure-calls-unrealsharp) - [C# Created Gameplay Tags | UnrealSharp](#c-created-gameplay-tags-unrealsharp) - [FWorldStaticVar | UnrealSharp](#fworldstaticvar-t-unrealsharp) - [Widgets | UnrealSharp](#widgets-unrealsharp) - [Replicated UObjects | UnrealSharp](#replicated-uobjects-unrealsharp) - [Gameplay Tag Container | UnrealSharp](#gameplay-tag-container-unrealsharp) - [Create/Compose Widgets | UnrealSharp](#create-compose-widgets-unrealsharp) - [Cheats / Debug Commands | UnrealSharp](#cheats-debug-commands-unrealsharp) - [Extension / Mixin Methods | UnrealSharp](#extension-mixin-methods-unrealsharp) - [Show Widget On Screen | UnrealSharp](#show-widget-on-screen-unrealsharp) --- # Home | UnrealSharp UnrealSharp is a free and open-source plugin for Unreal Engine 5 that allows game developers to use C# with the power of .NET 9. [hashtag](https://www.unrealsharp.com/#jump-right-in) Jump right in ------------------------------------------------------------------------ [](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart) **Getting Started** Setup UnrealSharp [](https://www.unrealsharp.com/unreal-framework/classes) **Documentation** Overview of the API documentation [hashtag](https://www.unrealsharp.com/#features) Features -------------------------------------------------------------- * **C# Integration**: Write your game logic in C#. * **Seamless Unreal Engine 5 Compatibility**: Fully integrated with the latest UE5 features and API. * **Hot reload:** Compile and reload code on the fly without having to restart the engine for changes. * **Automatic Bindings:** Automatically generates C# API based on what is exposed to reflection. * **.NET Ecosystem:** Use any NuGet package to extend functionality. * **MIT License:** UnrealSharp is released under the MIT License, meaning you're free to use it in any project, whether personal or commercial, entirely free of charge. [hashtag](https://www.unrealsharp.com/#supported-platforms) Supported Platforms ------------------------------------------------------------------------------------ * **Windows** - Yes * **Mac** - Yes * **iOS** - Planned * **Android** - Planned * **Linux** - Planned [hashtag](https://www.unrealsharp.com/#sample-project) Sample Projects --------------------------------------------------------------------------- [Sample Defense Gamearrow-up-right](https://github.com/UnrealSharp/UnrealSharp-SampleDefenseGame) , project made for Mini Jam 174. [Slime Guzzlerarrow-up-right](https://github.com/UnrealSharp/Epic-MegaJam-Project) , project made for Epic MegaJam 2025. [UnrealSharp-Cropoutarrow-up-right](https://github.com/UnrealSharp/UnrealSharp-Cropout/tree/main) , originally created in Blueprints by Epic Games, now converted to C# using UnrealSharp. [hashtag](https://www.unrealsharp.com/#discord) Discord ------------------------------------------------------------ Join the discord community to stay up to date with the recent updates and plugin support! [Discord communityarrow-up-right](https://discord.gg/HQuJUYFxeV) [NextFAQchevron-right](https://www.unrealsharp.com/faq) Last updated 14 days ago * [Jump right in](https://www.unrealsharp.com/#jump-right-in) * [Features](https://www.unrealsharp.com/#features) * [Supported Platforms](https://www.unrealsharp.com/#supported-platforms) * [Sample Projects](https://www.unrealsharp.com/#sample-project) * [Discord](https://www.unrealsharp.com/#discord) --- # FAQ | UnrealSharp [hashtag](https://www.unrealsharp.com/faq#general) General --------------------------------------------------------------- ### [hashtag](https://www.unrealsharp.com/faq#id-1-what-is-unrealsharp) 1\. What is UnrealSharp? UnrealSharp is a plugin for Unreal Engine that allows developers to use C# for game development and editor tooling. It is designed to offer the same functionalities as Blueprint, and even more, providing a familiar environment for C# developers. It is developed with fast iteration in mind, so you can develop your games in C# with the engine open, and it will compile the code for you on the fly. ### [hashtag](https://www.unrealsharp.com/faq#id-2-can-i-make-a-game-with-unrealsharp) 2\. Can I make a game with UnrealSharp? The plugin is not production ready yet, but the plan is yes you will be able to! ### [hashtag](https://www.unrealsharp.com/faq#id-3-how-do-i-download-unrealsharp) 3\. How do I download UnrealSharp? You can compile a source build from the [GitHub repositoryarrow-up-right](https://github.com/UnrealSharp/UnrealSharp) . ### [hashtag](https://www.unrealsharp.com/faq#id-4-im-coming-from-unity-with-a-c-background-is-unrealsharp-a-good-fit-for-me) 4\. I’m coming from Unity with a C# background, is UnrealSharp a good fit for me? It is recommended you have Unreal Engine experience and an engineer familiar with C++ to use UnrealSharp. Having an understanding of the [Blueprint / C++ architecturearrow-up-right](https://youtu.be/VMZftEVDuCE?si=bxRZj6z9VDTC0Fkk) and how they’re used side by side is extremely important to have knowledge on. Additionally, UnrealSharp can only access what is exposed to [reflectionarrow-up-right](https://www.unrealsharp.com/faq.html#1-what-is-reflection) , so similar to Blueprints you will still need to use C++ to expose certain systems or features. The plugin has an ongoing effort to help expose things to C# out of the box, such as subsystems, but you won’t be able to rely on that for everything. ### [hashtag](https://www.unrealsharp.com/faq#id-5-can-i-use-unrealsharp-for-commercial-projects) 5\. Can I use UnrealSharp for commercial projects? Absolutely! UnrealSharp is completely free of charge and open-source for both personal and commercial use. ### [hashtag](https://www.unrealsharp.com/faq#id-5-does-unrealsharp-support-platform) 5\. Does UnrealSharp support \[ platform \]? The [Home Pagearrow-up-right](https://www.unrealsharp.com/index.md#supported-platforms) has a Supported Platforms section listing out the supported and planned platforms. ### [hashtag](https://www.unrealsharp.com/faq#id-6-is-there-an-eta-for-feature) 6\. Is there an ETA for \[ feature \]? To avoid setting expectations or putting stress on any contributors release dates are not provided. UnrealSharp is a passion project worked on in people’s free time, so it does not follow a schedule or deadlines. ### [hashtag](https://www.unrealsharp.com/faq#id-7-what-features-are-being-worked-on) 7\. What features are being worked on? You can look at the [Roadmaparrow-up-right](https://github.com/orgs/UnrealSharp/projects/3) for a look at what is currently in development and also on the todo list. ### [hashtag](https://www.unrealsharp.com/faq#id-8-what-are-the-system-requirements-for-unrealsharp) 8\. What are the system requirements for UnrealSharp? UnrealSharp requires the same system specifications as [Unreal Enginearrow-up-right](https://dev.epicgames.com/documentation/en-us/unreal-engine/hardware-and-software-specifications-for-unreal-engine) . Additionally, the [.NET 9.0 SDKarrow-up-right](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) is necessary to use this plugin. [hashtag](https://www.unrealsharp.com/faq#technical) Technical ------------------------------------------------------------------- ### [hashtag](https://www.unrealsharp.com/faq#id-1-what-is-reflection) 1\. What is reflection? You can read more about the Unreal reflection system [herearrow-up-right](https://www.unrealengine.com/en-US/blog/unreal-property-system-reflection) , but in simple terms it’s how Unreal exposes C++ classes, functions, properties, and other types to engine systems such blueprints, replication, and garbage collection. Due to all of Unreal systems being written in C++, if a class, struct, or function is not exposed to reflection, blueprints cannot access it. UnrealSharp utilizes reflection for generating C# code and communicating with Unreal, so it has the same restriction as blueprints. ### [hashtag](https://www.unrealsharp.com/faq#id-2-what-is-the-difference-between-a-binary-and-source-build-of-the-plugin) 2\. What is the difference between a binary and source build of the plugin? A binary build is a precompiled and packaged version that doesn’t need to be manually compiled by the end user. A source build is when the end user needs to download the source code and compile the code themselves for use. Due to UnrealSharp not being production ready and making quick changes we do not consistently release up-to-date binary builds. You will need to compile the source yourself. Here is a [resourcearrow-up-right](https://youtu.be/94FvzO1HVzY?si=fWKC3CY-eIKN1VPt) on how to set up an Unreal C++ project to start. ### [hashtag](https://www.unrealsharp.com/faq#id-3-do-i-need-to-use-blueprints) 3\. Do I need to use Blueprints? Blueprints is not just visual scripting, it’s an [interfacearrow-up-right](https://youtu.be/VMZftEVDuCE?si=QE0sKi4w9Q2YSlYm) to your game assets. It is highly recommended to make blueprint subclasses of C# classes like you would with C++ so designers can easily control properties and functionality of your systems. ### [hashtag](https://www.unrealsharp.com/faq#id-4-do-i-need-to-use-c) 4\. Do I need to use C++? Most likely yes. UnrealSharp can only access what is exposed to [reflectionarrow-up-right](https://www.unrealsharp.com/faq.html#1-what-is-reflection) like Blueprints, so you will need an engineer to use C++ to expose certain systems or features. ### [hashtag](https://www.unrealsharp.com/faq#id-5-what-is-the-difference-between-new-t-and-newobjectt) 5\. What is the difference between `new T()` and `NewObject()>`? Use `NewObject()` for any classes inheriting from `uobject`. `new T()` does not work with constructing `uobject`’s, trying to would result in creating an object with no underlying `uobject` or blueprint subclass. ### [hashtag](https://www.unrealsharp.com/faq#id-6-can-i-make-a-c-plugin) 6\. Can I make a C# plugin? Yes! Follow the guides [here](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins) . [PreviousHomechevron-left](https://www.unrealsharp.com/) [NextKnown Issueschevron-right](https://www.unrealsharp.com/known-issues) Last updated 25 days ago * [General](https://www.unrealsharp.com/faq#general) * [1\. What is UnrealSharp?](https://www.unrealsharp.com/faq#id-1-what-is-unrealsharp) * [2\. Can I make a game with UnrealSharp?](https://www.unrealsharp.com/faq#id-2-can-i-make-a-game-with-unrealsharp) * [3\. How do I download UnrealSharp?](https://www.unrealsharp.com/faq#id-3-how-do-i-download-unrealsharp) * [4\. I’m coming from Unity with a C# background, is UnrealSharp a good fit for me?](https://www.unrealsharp.com/faq#id-4-im-coming-from-unity-with-a-c-background-is-unrealsharp-a-good-fit-for-me) * [5\. Can I use UnrealSharp for commercial projects?](https://www.unrealsharp.com/faq#id-5-can-i-use-unrealsharp-for-commercial-projects) * [5\. Does UnrealSharp support \[ platform \]?](https://www.unrealsharp.com/faq#id-5-does-unrealsharp-support-platform) * [6\. Is there an ETA for \[ feature \]?](https://www.unrealsharp.com/faq#id-6-is-there-an-eta-for-feature) * [7\. What features are being worked on?](https://www.unrealsharp.com/faq#id-7-what-features-are-being-worked-on) * [8\. What are the system requirements for UnrealSharp?](https://www.unrealsharp.com/faq#id-8-what-are-the-system-requirements-for-unrealsharp) * [Technical](https://www.unrealsharp.com/faq#technical) * [1\. What is reflection?](https://www.unrealsharp.com/faq#id-1-what-is-reflection) * [2\. What is the difference between a binary and source build of the plugin?](https://www.unrealsharp.com/faq#id-2-what-is-the-difference-between-a-binary-and-source-build-of-the-plugin) * [3\. Do I need to use Blueprints?](https://www.unrealsharp.com/faq#id-3-do-i-need-to-use-blueprints) * [4\. Do I need to use C++?](https://www.unrealsharp.com/faq#id-4-do-i-need-to-use-c) * [5\. What is the difference between new T() and NewObject()>?](https://www.unrealsharp.com/faq#id-5-what-is-the-difference-between-new-t-and-newobjectt) * [6\. Can I make a C# plugin?](https://www.unrealsharp.com/faq#id-6-can-i-make-a-c-plugin) --- # Debugging | UnrealSharp Once you have setup your project you can start the project through the C# project by pressing F5, and you will attach a debugger to the Unreal Engine instance, and you can start debugging. [PreviousYour First Scriptchevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/your-first-script) [NextPackagingchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging) Last updated 1 month ago --- # Setup | UnrealSharp [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#prerequisites) Prerequisites ------------------------------------------------------------------------------------------------------------------- C++ Project (Highly recommended but not required. See warning under "**Compiling UnrealSharp**") Unreal Engine 5.5 - 5.7 Install the [required build toolsarrow-up-right](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine) for Unreal Engine Install [.NET 9.0 SDKarrow-up-right](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) (9.0.305+) [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#install-unrealsharp-to-your-project) Clone UnrealSharp to your project ------------------------------------------------------------------------------------------------------------------------------------------------------------- Clone [this arrow-up-right](https://github.com/UnrealSharp/UnrealSharp) repo and place **UnrealSharp** in the **ProjectRootDirectory/Plugins** folder (make the Plugins folder if it doesn’t exist) in your Unreal Engine project. Copy git clone https://github.com/UnrealSharp/UnrealSharp.git [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#generate-project-files) Generate Project Files ------------------------------------------------------------------------------------------------------------------------------------- Right click on your project's **.uproject** file and generate project files [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#compiling-unrealsharp) Compiling UnrealSharp ----------------------------------------------------------------------------------------------------------------------------------- Compile the Unreal Engine project using the IDE of your choice. UnrealSharp will automatically generate glue and compile the bindings as part of the C++ build process. triangle-exclamation Avoid compiling the plugin by clicking on the .uproject file. It introduces several issues, such as outdated binaries even when the source code has changed, which complicates debugging and support. If you do choose this option, you need to remove **Binaries/Intermediate** folders in the **project/UnrealSharp** folder, whenever you fetch a new version of the plugin from Git. [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#launching-unrealsharp) Launching UnrealSharp ----------------------------------------------------------------------------------------------------------------------------------- Launch your Unreal Engine project through the **solution file** or **.uproject**. Once Unreal Engine has fully opened, this prompt should appear: ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2Fraw.githubusercontent.com%2FUnrealSharp%2Funrealsharp.github.io%2Fmain%2Fmedia%2Fget-started%2FNoProjectFoundPrompt.PNG&width=768&dpr=3&quality=100&sign=13139b24&sv=2) Press **Yes** and the **Create C# Project** menu should appear like this: ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FrKKCou5nGnbD0lOew0Rq%252Fimage.png%3Falt%3Dmedia%26token%3D98acb910-d5a3-42a2-ac40-85c08dcc1789&width=768&dpr=3&quality=100&sign=7f54bf41&sv=2) You can choose a custom project name, and the project will be located in the **ProjectRootFolder/Script** directory. Subdirectories within Script are also supported, allowing you to organize your project files in any folder structure you prefer. Owner is either a plugin or the project. UnrealSharp supports having C# code in a plugin. circle-info **By default it’ll create a new folder for each new project!** [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#quick-access-to-unrealsharps-editor-features) Quick Access to UnrealSharp’s editor features ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- If you lose track or need to start over, you can easily access the project setup feature again. Navigate to the top of the editor viewport and you’ll find the **UnrealSharp** logo. Click on **New C# Project** and you’re back on track. [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#project-setup-completed) Project Setup Completed --------------------------------------------------------------------------------------------------------------------------------------- Once the project is created and the solution opens, you will see two projects in the Solution Explorer. **ProjectName.Glue**: This project contains the automatically generated glue code that is related to your C++ API. It's part of the interop process, and it will be regenerated with each build that trigger UnrealHeaderTool. Therefore, do not modify or directly use this project. Any changes made here will be overwritten. **Plugins:** Here any plugins within the project will reside. The glue for each plugin will be in **PluginRootFolder\\Script\\PluginName.Glue** ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FK5tyXCcpY6UHFQ4tQJ0E%252FScreenshot%25202025-08-09%2520121710.png%3Falt%3Dmedia%26token%3D9f4b4f54-5e81-4187-a8a6-48ba37cc9a69&width=768&dpr=3&quality=100&sign=48fa6882&sv=2) [PreviousKnown Issueschevron-left](https://www.unrealsharp.com/known-issues) [NextYour First Scriptchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/your-first-script) Last updated 7 days ago * [Prerequisites](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#prerequisites) * [Clone UnrealSharp to your project](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#install-unrealsharp-to-your-project) * [Generate Project Files](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#generate-project-files) * [Compiling UnrealSharp](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#compiling-unrealsharp) * [Launching UnrealSharp](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#launching-unrealsharp) * [Quick Access to UnrealSharp’s editor features](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#quick-access-to-unrealsharps-editor-features) * [Project Setup Completed](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart#project-setup-completed) --- # Known Issues | UnrealSharp #### [hashtag](https://www.unrealsharp.com/known-issues#json-serialization) JSON Serialization Using **Newtonsoft.Json** together with UnrealSharp’s AssemblyLoadContext based hot reload system can cause reloads to fail. More info and workaround [herearrow-up-right](https://github.com/UnrealSharp/UnrealSharp/issues/544) . #### [hashtag](https://www.unrealsharp.com/known-issues#glue-not-generating-on-engine-upgrade-or-enabling-engine-plugins) Glue not generating on engine upgrade or enabling engine plugins When upgrading to a new engine version or enabling an engine plugin, UnrealBuildTool doesn't trigger because it doesn't detect any source code changes, and no new glue will be generated. To fix this you need to force a glue re-generation by manually deleting the `Intermediate` and `Saved` folders in the UnrealSharp plugin folder. Now compile as usual, and the glue will be re-generated. [PreviousFAQchevron-left](https://www.unrealsharp.com/faq) [NextSetupchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart) Last updated 8 days ago --- # Module Lifecycle | UnrealSharp In C#, similar to C++, you can define a class to represent your module. These module classes are automatically generated when you create a new module using the UnrealSharp toolbar in the editor. If your module was created before this feature was available and doesn’t have a module class, you can simply define it manually anywhere in your module. To do this, create a new class and implement the `IModuleInterface`. Here’s an example of how a module class might look: Copy using UnrealSharp.Engine.Core.Modules; namespace ModuleShowcase; public class FModuleShowcase : IModuleInterface { // Called when opening the engine or reloading an assembly during hot reload public void StartupModule() { } // Called when the engine is closing or reloading an assembly during hot reload public void ShutdownModule() { } } `StartupModule` and `ShutdownModule` get called when you start or close the editor, and also during hot reloads. When hot reloading, the old assembly gets unloaded, and the new one is loaded, so these methods handle setting things up and cleaning up as needed. [PreviousLoggingchevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/logging) [NextC# Pluginschevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins) Last updated 2 days ago --- # Packaging | UnrealSharp circle-exclamation _**Currently only Windows/Mac is supported**_ Begin by packaging your game as you would normally in Unreal Engine. Ensure you select the correct platform (Windows) and configurations for your game. This initial step does not differ from the standard game packaging procedure in Unreal Engine. There are two ways to package UnrealSharp, you can either package it via the editor or the command prompt. Both options are explained below. [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#packaging-via-unreal-editor) Packaging via Unreal Editor ---------------------------------------------------------------------------------------------------------------------------------------------- You can easily package your C# project and runtime directly through the Unreal Editor. Follow these steps: ### [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#open-the-packaging-tool) Open the Packaging Tool In the editor, navigate to the **UnrealSharp** toolbar located at the top of the viewport, and click on **Package Project**. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252Fgit-blob-ac2ab0e6e1f309d0eedcae738f50917ca2173d3a%252Fpackagetool.png%3Falt%3Dmedia&width=768&dpr=3&quality=100&sign=efad7d4e&sv=2) A file explorer dialog will appear, prompting you to choose the directory where your project will be packaged. Select the **root folder** of your packaged project. This is the folder containing your **.exe** file. After selecting the correct folder, you should see the packaging process start. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252Fgit-blob-3187e9dc3770bb8a9bdf22faa193762dd5e6ec0b%252Fpackaging.png%3Falt%3Dmedia&width=768&dpr=3&quality=100&sign=7c6ac5e&sv=2) Once the prompt disappears, the packaging is complete, and your game is ready to be launched. [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#packaging-via-command-prompt) Packaging via Command Prompt ------------------------------------------------------------------------------------------------------------------------------------------------ Open **Command Prompt** or **PowerShell** window and navigate to `UnrealSharp\Binaries\Managed` ### [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#package-project-script) Package Project Script **–Action:** The action you want UnrealSharpBuildTool to run. **–ProjectDirectory:** The path to your project root directory (where .uproject resides). **–ProjectName:** The name of your Unreal Engine project **–PluginDirectory:** The path to the directory where the UnrealSharp plugin is installed within your project or engine. **–ArchiveDirectory:** The root directory for where the packaged game is archived. ### [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#example-usage) Example Usage: If your project is named “MyGame” and is located at `C:/Users/CoolName/Documents/Unreal Projects/MyGame`, with the UnrealSharp plugin in the project’s “Plugins” folder and you want to archive the packaged game to the desktop, your command would look like this: [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#done-and-dusted) Done and dusted! ----------------------------------------------------------------------------------------------------------------------- Now the `MyProjectName\Binaries\Managed` folder in your packaged game should be populated and the game is ready to run. [PreviousDebuggingchevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/debugging) [NextLoggingchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/logging) Last updated 1 year ago * [Packaging via Unreal Editor](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#packaging-via-unreal-editor) * [Open the Packaging Tool](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#open-the-packaging-tool) * [Packaging via Command Prompt](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#packaging-via-command-prompt) * [Package Project Script](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#package-project-script) * [Example Usage:](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#example-usage) * [Done and dusted!](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging#done-and-dusted) Copy dotnet UnrealSharpBuildTool.dll --Action PackageProject --ProjectDirectory "" --ProjectName "" --PluginDirectory "" --AdditionalArgs BuildConfig=Release ArchiveDirectory="" Copy dotnet UnrealSharpBuildTool.dll --Action PackageProject --ProjectDirectory "C:/Users/CoolName/Documents/Unreal Projects/MyGame/" --ProjectName "MyGame" --PluginDirectory "C:/Users/CoolName/Documents/Unreal Projects/MyGame/Plugins/UnrealSharp" --AdditionalArgs BuildConfig=Release ArchiveDirectory="C:/Users/CoolName/Desktop/Windows" --- # Create New Plugin | UnrealSharp Go to the **Plugins** window by following the steps in the image below: ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FyRXMsNiJFBFnp1MxeaHU%252Fimage.png%3Falt%3Dmedia%26token%3Dc7d36a4d-317b-4f1e-9b6d-078ccf13d882&width=768&dpr=3&quality=100&sign=432b4bd4&sv=2) Now click on **Add** as seen in the image below: ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252F3NTT6NMz9vvw8CtVFnzJ%252Fimage.png%3Falt%3Dmedia%26token%3D4a3da396-0200-448e-88b2-f32fafe130fd&width=768&dpr=3&quality=100&sign=a1361d80&sv=2) This will open up the plugin wizard where there are a bunch of templates, **C# Only** and **C++/C# Joint** being two of them. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252Ft94T0rl5HzjPJ3NVrHLN%252Fimage.png%3Falt%3Dmedia%26token%3D5ab024cc-a89e-42ff-a631-75b7d85a681d&width=768&dpr=3&quality=100&sign=c9ccc563&sv=2) Choose C# plugin template, choose plugin name and press **Create Plugin**. [PreviousC# Pluginschevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins) [NextAdd C# To Existing Pluginchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins/add-c-to-existing-plugin) Last updated 26 days ago --- # C# Plugins | UnrealSharp [Create New Pluginchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins/create-new-plugin) [Add C# To Existing Pluginchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins/add-c-to-existing-plugin) [PreviousModule Lifecyclechevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/module-lifecycle) [NextCreate New Pluginchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins/create-new-plugin) Last updated 25 days ago --- # Your First Script | UnrealSharp [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/your-first-script#first-script) First Script ------------------------------------------------------------------------------------------------------------------------ Example setup of a basic UnrealSharp class Copy using UnrealSharp.Attributes; using UnrealSharp.Engine; namespace ManagedTestCSharp; [UClass] public partial class AMyTestClass : AActor { [UProperty(PropertyFlags.BlueprintReadOnly)] public partial int MyInt { get; set; } public override void BeginPlay() { PrintString("Hello from C#!"); base.BeginPlay(); } [UFunction(FunctionFlags.BlueprintCallable)] public void MyFunction(int myInt) { MyInt = myInt; PrintString($"MyInt set to {MyInt}"); } } Now go back to Unreal Engine and it should compile your code and your class should be able to be found in the editor. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252Fgit-blob-23d656e5c0f6b9b7f26bccb36c738ce7ac3c4d74%252Funreal_class_wizard.png%3Falt%3Dmedia&width=768&dpr=3&quality=100&sign=d615b23b&sv=2) [hashtag](https://www.unrealsharp.com/getting-started-and-fundamentals/your-first-script#debugging) ------------------------------------------------------------------------------------------------------- [PreviousSetupchevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/quickstart) [NextDebuggingchevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/debugging) Last updated 28 days ago * [First Script](https://www.unrealsharp.com/getting-started-and-fundamentals/your-first-script#first-script) * [](https://www.unrealsharp.com/getting-started-and-fundamentals/your-first-script#debugging) --- # Logging | UnrealSharp **Define Custom Log Categories** The `[CustomLog]` attribute is used on a `partial` (and preferably `static`) class to define a custom log category, for the Unreal Engine output log. The category's API will then generate automatically with methods such as `Log` / `LogWarning` / `LogError` / `LogFatal`. Copy [CustomLog] public static partial class LogMyFirstLog; [CustomLog(ELogVerbosity.Verbose)] public static partial class LogMySecondLog; * `LogMyFirstLog`: Defaults to `ELogVerbosity.Display` when no verbosity is specified. * `LogMySecondLog`: Explicitly uses `ELogVerbosity.Verbose`. * * * **Use the Log Categories** Here’s an example of how to log with your custom categories: Copy [UClass] public partial class ALogShowcase : AActor { public ALogShowcase() { LogMyFirstLog.Log("ALogShowcase constructor executed"); } public override void BeginPlay() { LogMyFirstLog.Log("BeginPlay executed"); base.BeginPlay(); } } And they will show up like this in the output log in the engine: [PreviousPackagingchevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/packaging) [NextModule Lifecyclechevron-right](https://www.unrealsharp.com/getting-started-and-fundamentals/module-lifecycle) Last updated 2 days ago Copy LogMyFirstLog: Display: ALogShowcase constructor executed LogMyFirstLog: Display: BeginPlay executed --- # Add C# To Existing Plugin | UnrealSharp Go to the **UnrealSharp** toolbar in the editor and choose **Create C# Project** ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FugIc37MNM2o0WBvKnDJH%252Fimage.png%3Falt%3Dmedia%26token%3D6c2e3b43-bfa9-4cb2-84e7-6d45a77e5adb&width=768&dpr=3&quality=100&sign=457a5a4d&sv=2) Now select your plugin in the **Owner** dropdown and press **Create C# Project** ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252F7YV7Cce0lllH86KrzpMW%252Fimage.png%3Falt%3Dmedia%26token%3De7ba6a03-4329-4f8d-a141-953dcbac8290&width=768&dpr=3&quality=100&sign=8e163632&sv=2) [PreviousCreate New Pluginchevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins/create-new-plugin) [NextClasseschevron-right](https://www.unrealsharp.com/unreal-framework/classes) Last updated 25 days ago --- # C++ Properties with Getters/Setters | UnrealSharp UnrealSharp will attempt to pair up C++ member variables with their designated getters/setters and call these functions rather than setting the value directly in memory. It also supports the new native Getter/Setters workflow that was implemented in 5.1. The following C++ member: Copy UPROPERTY(BlueprintGetter=K2_GetRootComponent, Category="Transformation") TObjectPtr RootComponent; maps to this C# code, which calls `K2_GetRootComponent` to retrieve the value: Copy public UnrealSharp.Engine.USceneComponent RootComponent { get { unsafe { byte* ParamsBufferAllocation = stackalloc byte[K2_GetRootComponent_ParamsSize]; nint ParamsBuffer = (nint) ParamsBufferAllocation; UStructExporter.CallInitializeStruct(K2_GetRootComponent_NativeFunction, ParamsBuffer); UObjectExporter.CallInvokeNativeFunction(NativeObject, K2_GetRootComponent_NativeFunction, ParamsBuffer); UnrealSharp.Engine.USceneComponent returnValue; returnValue = ObjectMarshaller.FromNative(IntPtr.Add(ParamsBuffer, K2_GetRootComponent_ReturnValue_Offset), 0); return (UnrealSharp.Engine.USceneComponent)returnValue; } } } [PreviousC++ Functions As C# Propertieschevron-left](https://www.unrealsharp.com/unreal-framework/classes/properties/c++-functions-as-c-properties) [NextCustom C# Getter / Setterchevron-right](https://www.unrealsharp.com/unreal-framework/classes/properties/custom-c-getter-setter) Last updated 25 days ago --- # C++ Functions As C# Properties | UnrealSharp UnrealSharp automatically generates properties for any C++ function with a `Get` or `Set` prefix, provided the function either returns a value or accepts a single parameter. This includes `Get` functions that has an out parameter or just a `WorldContextObject`as parameter, like shown below. Copy /** Returns the game instance object */ UFUNCTION(BlueprintPure, Category="Game", meta=(WorldContext="WorldContextObject")) static ENGINE_API class UGameInstance* GetGameInstance(const UObject* WorldContextObject); The generator will attempt to pair corresponding getter and setter functions into a single C# property. The following functions: Copy UFUNCTION(BlueprintCallable) void SetTestValue(int32 Value); UFUNCTION(BlueprintCallable) int32 GetTestValue(); turns into a property in C#: Copy public int TestValue { get { unsafe { byte* ParamsBufferAllocation = stackalloc byte[GetTestValue_ParamsSize]; nint ParamsBuffer = (nint) ParamsBufferAllocation; UStructExporter.CallInitializeStruct(GetTestValue_NativeFunction, ParamsBuffer); UObjectExporter.CallInvokeNativeFunction(NativeObject, GetTestValue_NativeFunction, ParamsBuffer); int returnValue; returnValue = BlittableMarshaller.FromNative(IntPtr.Add(ParamsBuffer, GetTestValue_ReturnValue_Offset), 0); return returnValue; } } set { unsafe { byte* ParamsBufferAllocation = stackalloc byte[SetTestValue_ParamsSize]; nint ParamsBuffer = (nint) ParamsBufferAllocation; UStructExporter.CallInitializeStruct(SetTestValue_NativeFunction, ParamsBuffer); BlittableMarshaller.ToNative(IntPtr.Add(ParamsBuffer, SetTestValue_Value_Offset), 0, value); UObjectExporter.CallInvokeNativeFunction(NativeObject, SetTestValue_NativeFunction, ParamsBuffer); } } } [PreviousPropertieschevron-left](https://www.unrealsharp.com/unreal-framework/classes/properties) [NextC++ Properties with Getters/Setterschevron-right](https://www.unrealsharp.com/unreal-framework/classes/properties/c++-properties-with-getters-setters) Last updated 25 days ago --- # Classes | UnrealSharp * Be marked with the `[UClass]` attribute. * **Inherit from a valid** `UObject`**\-based type**, such as `AActor`, `UActorComponent`, `USceneComponent`, or any other Unreal class exposed through UnrealSharp. * Be declared as a `partial` **class**, so UnrealSharp can generate interop code from the source generator. Copy [UClass] public partial class AMyShowcaseClass : AActor { public override void BeginPlay() { base.BeginPlay(); } } [PreviousAdd C# To Existing Pluginchevron-left](https://www.unrealsharp.com/getting-started-and-fundamentals/c-plugins/add-c-to-existing-plugin) [NextPropertieschevron-right](https://www.unrealsharp.com/unreal-framework/classes/properties) Last updated 10 days ago --- # Enums | UnrealSharp To expose a C# enum to Unreal Engine, it must: * Use `byte` as its underlying type * Have the `[UEnum]` attribute This is a hard limitation by Unreal Engine for enums used in properties and function parameters. Copy [UEnum] public enum EMyEnum : byte { Value1 = 0, Value2 = 1, } [PreviousStructschevron-left](https://www.unrealsharp.com/unreal-framework/structs) [NextInterfaceschevron-right](https://www.unrealsharp.com/unreal-framework/interfaces) Last updated 25 days ago --- # Interfaces | UnrealSharp To create an interface in UnrealSharp, the interface must be prefixed with I, and use the UInterface attribute. Copy [UInterface] public interface IInteractable { [UFunction(FunctionFlags.BlueprintEvent)] public bool OnInteract(); [UFunction(FunctionFlags.BlueprintEvent)] public bool StopInteract(); } The UFunction for interface methods can only be defined in their interface. You can’t UFunction an implementation of the interface method. [PreviousEnumschevron-left](https://www.unrealsharp.com/unreal-framework/enums) [NextDelegateschevron-right](https://www.unrealsharp.com/unreal-framework/delegates) Last updated 25 days ago --- # Subsystems | UnrealSharp UnrealSharp supports any of the engine’s subsytem classes. These classes are great way to create singletons in Unreal Engine. They get automatically instanced and the engine will manage its lifetime. They don't support replication though. #### [hashtag](https://www.unrealsharp.com/unreal-framework/subsystems#subsystem-names-in-unrealsharp) Su~b~system names in UnrealSharp The only difference is that you need to inherit from the CS wrapper, due to the lack of reflection exposed functions in the engine’s subsystem classes. Copy // This WorldSubsystem supports Tick aswell. UTickableWorldSubsystem doesn't exist in UnrealSharp. UWorldSubsystem => UCSWorldSubsystem UGameInstanceSubsystem => UCSGameInstanceSubsystem UEngineSubsystem => UCSEngineSubsystem ULocalPlayerSubsystem => UCSLocalPlayerSubsystem #### [hashtag](https://www.unrealsharp.com/unreal-framework/subsystems#getting-subsystems) Getting Subsystems Getting the subsystems are really simple, you just do any of the following, depending on what type of subsystem you inherit from: Copy GetWorldSubsystem(); GetGameInstanceSubsystem(); GetLocalPlayerSubsystem(OwningPlayerController); GetEngineSubsystem(); #### [hashtag](https://www.unrealsharp.com/unreal-framework/subsystems#world-subsystem-example) World Subsystem Example [PreviousDelegateschevron-left](https://www.unrealsharp.com/unreal-framework/delegates) [NextMeta Datachevron-right](https://www.unrealsharp.com/unreal-framework/metadata) Last updated 25 days ago Copy [UClass] public partial class UMyWorldSubsystem : UCSWorldSubsystem { public override bool DoesSupportWorldType(ECSWorldType worldType) { return worldType == ECSWorldType.Game || worldType == ECSWorldType.PIE; } public override void Initialize(FSubsystemCollectionBaseRef collection) { } public override void OnWorldBeginPlay() { } } --- # Properties | UnrealSharp * Be marked with the `[UProperty]` attribute. * Be defined as C# properties with getters and/or setters. * Be declared as `partial`, allowing UnrealSharp to generate the required interop and reflection code. Getters and setters are fully usable and behave like normal C# properties, while still being visible to Unreal. Below is an example demonstrating common property types Copy [UClass] public partial class AMyShowcaseClass : AActor { // Declares a default component which is automatically created and assigned // when the actor is constructed. Marking it as RootComponent makes it the root. [UProperty(DefaultComponent = true, RootComponent = true)] public partial UStaticMeshComponent MyMesh { get; set; } // Exposes a map to the editor and Blueprint. // Note: TMap itself cannot currently be constructed with 'new' in C#. [UProperty(PropertyFlags.EditAnywhere | PropertyFlags.BlueprintReadWrite)] public partial TMap MyMap { get; set; } [UProperty(PropertyFlags.EditAnywhere | PropertyFlags.BlueprintReadWrite)] public partial TWeakObjectPtr MyWeakObject { get; set; } public override void BeginPlay() { base.BeginPlay(); PrintString("BeginPlay called!"); // Assuming the enginehas initialized MyMap for you, // you can use it like a normal map: MyMap.Add(1, "First Value"); MyMap.Add(2, "Second Value"); MyWeakObject = this; UpdateMapWithKey(2, "Updated Second Value"); } } At the moment: * **You cannot directly construct certain Unreal container types** like `TArray<>` and `TMap<>` in managed code using `new TArray<>()` or `new TMap<>()`. * For Unreal-exposed properties using `TArray` / `TMap`, the underlying instance is created by the engine / interop layer. You can read/write to them (e.g., `MyMap.Add(...)`), but not manually allocate them yourself. * If you need **purely managed collections** that you control entirely from C#, prefer: * `IList` for array-like data * `IDictionary` for maps [PreviousClasseschevron-left](https://www.unrealsharp.com/unreal-framework/classes) [NextC++ Functions As C# Propertieschevron-right](https://www.unrealsharp.com/unreal-framework/classes/properties/c++-functions-as-c-properties) Last updated 25 days ago --- # Structs | UnrealSharp To expose a C# struct to Unreal Engine, it must: * Be declared as `partial` * Have the `[UStruct]` attribute Copy [UStruct] public partial struct FMyStruct { [UProperty(PropertyFlags.BlueprintReadOnly)] public int MyInt { get; private set; } [UProperty(PropertyFlags.BlueprintReadOnly)] public float MyFloat; [UProperty(PropertyFlags.BlueprintReadOnly)] public string MyString; [UProperty(PropertyFlags.BlueprintReadOnly)] public bool MyBool; [UProperty(PropertyFlags.BlueprintReadOnly)] public UObject MyObject; [UProperty(PropertyFlags.BlueprintReadOnly)] public IList MyArray; [UProperty(PropertyFlags.BlueprintReadOnly)] public IDictionary MyMap; } Records also works: [PreviousHelper Methodschevron-left](https://www.unrealsharp.com/unreal-framework/classes/helper-methods) [NextEnumschevron-right](https://www.unrealsharp.com/unreal-framework/enums) Last updated 19 days ago Copy [UStruct] public partial record struct FMyDemoStruct([field: UProperty(PropertyFlags.EditAnywhere)] int MyInt, [field: UProperty(PropertyFlags.EditAnywhere)] string MyString) --- # Meta Data | UnrealSharp Meta Data is a way to add additional data to any reflected type in Unreal Engine in editor. UnrealSharp has exposed the most common metadata in Unreal Engine through attributes. Copy UPROPERTY(EditDefaultsOnly, meta = (Category = "MyCategory")) TObjectPtr MyObject; Becomes this in C#: Copy // Alternative 1 [UProperty(PropertyFlags.EditDefaultsOnly), Category("MyCategory")] public partial UMyObject MyObject { get; set; } // Alternative 2 [UProperty(PropertyFlags.EditDefaultsOnly), UMetaData("Category", "MyCategory")] public partial UMyObject MyObject { get; set; } So any meta data key you see in Unreal Engine documentation or C++ source code, there is likely an C# attribute with the same name. If they don't exist, you can do `UMetaData("Key", "Value")`, as shown above in alternative 2. #### [hashtag](https://www.unrealsharp.com/unreal-framework/metadata#custom-meta-data-attributes) Custom Meta Data Attributes You can also define your own metadata attributes that the source generator will pick up and add to the type in engine. To get started, add the `CustomMetaData` attribute to your custom attribute class. Here is the breakdown of how it works: * Key: The attribute name becomes the metadata key (the source generator automatically removes the "Attribute" part). * Value: The first argument in your constructor becomes the metadata value. In the example above, the source generator strips "Attribute" from the name, resulting in a metadata key of "Category" with the value you pass into the constructor. [PreviousSubsystemschevron-left](https://www.unrealsharp.com/unreal-framework/subsystems) [NextCollectionschevron-right](https://www.unrealsharp.com/data-and-asset-management/collections) Last updated 28 days ago Copy [AttributeUsage(AttributeTargets.All), CustomMetaData] public sealed class CategoryAttribute(string categoryName) : Attribute { } --- # Custom C# Getter / Setter | UnrealSharp `UProperty` also supports custom getters / setters, aslong as the property type is supported by `UProperty`. Custom getter / setter don't need any partial declaration. Copy private int _score; [UProperty(PropertyFlags.BlueprintReadOnly)] public int Score { get { return _score; } set { _score = value; if (_score == 10) { Win(); } } } [PreviousC++ Properties with Getters/Setterschevron-left](https://www.unrealsharp.com/unreal-framework/classes/properties/c++-properties-with-getters-setters) [NextFunctionschevron-right](https://www.unrealsharp.com/unreal-framework/classes/functions) Last updated 27 days ago --- # Functions | UnrealSharp ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/functions#blueprint-callable-functions) **Blueprint-Callable Functions** Use `BlueprintCallable` (or other call-related flags like `BlueprintPure`, etc.) to allow Blueprint graphs to invoke your C# method. Copy // Can be called from BP [UFunction(FunctionFlags.BlueprintCallable)] public void MyBPCallableFunction(IList myList) { } Notes: * Accepts normal managed types (`int`, `float`, `IList`, etc.) as long as they can be marshalled. * * * ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/functions#blueprint-overridable-functions-events) Blueprint-Overridable Functions (Events) To allow Blueprint subclasses to override a C# function, UnrealSharp uses a **partial method pair**: * A _declaration_ marked with `BlueprintEvent`. * An automatically-generated `*_Implementation` method stub you can override on the C# side. Copy // Declares a function that Blueprint subclasses may override. [UFunction(FunctionFlags.BlueprintEvent)] public partial void MyBPOverridableFunction(IList myList); // The default implementation on the C# side. public partial void MyBPOverridableFunction_Implementation(IList myList) { // Default behavior } [PreviousCustom C# Getter / Setterchevron-left](https://www.unrealsharp.com/unreal-framework/classes/properties/custom-c-getter-setter) [NextFlagschevron-right](https://www.unrealsharp.com/unreal-framework/classes/functions/specifiers) Last updated 22 days ago * [Blueprint-Callable Functions](https://www.unrealsharp.com/unreal-framework/classes/functions#blueprint-callable-functions) * [Blueprint-Overridable Functions (Events)](https://www.unrealsharp.com/unreal-framework/classes/functions#blueprint-overridable-functions-events) --- # Delegates | UnrealSharp [hashtag](https://www.unrealsharp.com/unreal-framework/delegates#delegate-declaration) Delegate Declaration ---------------------------------------------------------------------------------------------------------------- When exposing delegates to Unreal Engine, some additional steps are required compared to standard C#. Delegates exposed to Unreal Engine needs to have parameters that are supported by reflection. Copy // Delegates need the attribute to generate the correct glue for the type. // Multicast delegates. [UMultiDelegate] public delegate void FMyShowcaseMulticastDelegate(int a); // Single delegates. [USingleDelegate] public delegate void FMyShowcaseDelegate(int a); [hashtag](https://www.unrealsharp.com/unreal-framework/delegates#class-member-declaration) Class Member Declaration ------------------------------------------------------------------------------------------------------------------------ Delegates can be exposed as class members in the following ways: Copy [UClass] public class ADelegateShowcaseClass : AActor { [UProperty(PropertyFlags.BlueprintAssignable)] public partial TMulticastDelegate MyMulticastDelegate { get; set; } [UFunction(FunctionFlags.BlueprintCallable)] public void MyFunctionWithCallback(TDelegate singleDelegate) { } // Single delegates as properties can't be Blueprint exposed, but reflection exposed. Unreal Engine limitation. [UProperty] public partial TDelegate MySingleDelegate { get; set; } } [hashtag](https://www.unrealsharp.com/unreal-framework/delegates#delegate-api-example) Delegate API Example ---------------------------------------------------------------------------------------------------------------- Delegates exposed to Unreal Engine follow the same syntax as standard C# delegates, with some additional features. [PreviousInterfaceschevron-left](https://www.unrealsharp.com/unreal-framework/interfaces) [NextSubsystemschevron-right](https://www.unrealsharp.com/unreal-framework/subsystems) Last updated 22 days ago * [Delegate Declaration](https://www.unrealsharp.com/unreal-framework/delegates#delegate-declaration) * [Class Member Declaration](https://www.unrealsharp.com/unreal-framework/delegates#class-member-declaration) * [Delegate API Example](https://www.unrealsharp.com/unreal-framework/delegates#delegate-api-example) Copy public override void BeginPlay() { // Subscribe to the delegate with a callback MyMulticastDelegate += MyFunctionCallback; // Invoke the delegate MyMulticastDelegate.Invoke(1337); // Check if the delegate contains the callback if (MyMulticastDelegate.Contains(MyCallback)) { PrintString("Delegate contains MyCallback"); } // Unsubscribe from the delegate MyMulticastDelegate -= MyCallback; base.BeginPlay(); } // A callback to an Unreal Engine exposed delegate must be a UFunction. [UFunction] public void MyFunctionCallback(int a) { PrintString($"MyCallback invoked with {a}"); } --- # Default Actor Components | UnrealSharp #### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/default-actor-components#setting-a-root-component) Setting a Root Component Every actor needs a root component, which serves as the parent for all other components in the actor’s hierarchy. The root component defines the actor’s position, rotation, and scale in the world. To define a root component using UnrealSharp, you use the **\[UProperty\]** attribute with the DefaultComponent and RootComponent flags set to true: Copy [UProperty(DefaultComponent = true, RootComponent = true)] public partial USceneComponent MyRootComponent { get; set; } * **DefaultComponent**: This flag indicates that the property should be automatically instantiated as a component when the actor is created. * **RootComponent**: Setting this flag to true designates this component as the root component of the actor. #### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/default-actor-components#attaching-more-components) Attaching More Components Once the root component is set, you can begin attaching other components. A common requirement is to attach a visual representation to your actor, like a static mesh. To attach a component as a child of the root component, use the AttachmentComponent parameter to specify the parent component’s name: Copy [UProperty(DefaultComponent = true, AttachmentComponent = nameof(MyRootComponent))] public partial UStaticMeshComponent MyStaticMeshComponent { get; set; } You can also attach components to another component’s socket: Copy [UProperty(DefaultComponent = true, AttachmentComponent = nameof(MyRootComponent), AttachmentSocket = "MySocketName")] public partial USkeletalMeshComponent MySkeletalMeshComponent { get; set; } #### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/default-actor-components#overriding-native-components) Overriding Native Components UnrealSharp allows you to swap out default native components (like the standard Character Movement component) with your own custom class, by using the `OverrideComponent` attribute on a `AActor` class. [PreviousFlagschevron-left](https://www.unrealsharp.com/unreal-framework/classes/functions/specifiers) [NextHelper Methodschevron-right](https://www.unrealsharp.com/unreal-framework/classes/helper-methods) Last updated 28 days ago Copy [UClass] public partial class UMyMovementComponent : UCharacterMovementComponent { } [UClass] // 1. Your custom class. // 2. The name of the property that has the native component. // 3. Optional custom property name to fetch the overridden component directly without casting. [OverrideComponent(typeof(UMyMovementComponent), nameof(CharacterMovement), "MyMovementComponent")] public partial class AMyCharacter : ACharacter { public override void BeginPlay() { // Use the generated "MyMovementComponent" property directly! PrintString(MyMovementComponent.GetType().ToString(), 5); base.BeginPlay(); } } --- # Flags | UnrealSharp Function Flag Effect **BlueprintAuthorityOnly** This function will only execute from Blueprint code if running on a machine with network authority (a server, dedicated server, or single-player game). **BlueprintCallable** The function can be executed in a Blueprint or Level Blueprint graph. **BlueprintCosmetic** This function is cosmetic and will not run on dedicated servers. **BlueprintEvent** This function is designed to be overridden by a Blueprint, but also has a default C# implementation. **BlueprintPure** The function does not affect the owning object in any way and can be executed in a Blueprint or Level Blueprint graph. Copy [UFunction(FunctionFlags.BlueprintPure)] public int BlueprintPureFunction() { return 1; } [UFunction(FunctionFlags.BlueprintCallable)] public int BlueprintCallableFunction() { return 1; } ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2Fd1iv7db44yhgxn.cloudfront.net%2Fdocumentation%2Fimages%2F99304a15-d36b-4ef2-adc6-2fd2e0894c0a%2Fbpcallable.png&width=300&dpr=3&quality=100&sign=adbd8c72&sv=2) Pure functions do not cache their results, therefore you should be cautious when doing any non-trivial amount of work with a blueprint function. It is good practice to avoid outputting array properties in Blueprint pure functions. **Client** The function is only executed on the client that owns the Object on which the function is called. **Exec** The function can be executed from the in-game console. Exec commands only function when declared within certain Classes. **NetMulticast** The function is executed both locally on the server, and replicated to all clients, regardless of the Actor's `NetOwner`. **Reliable** The function is replicated over the network, and is guaranteed to arrive regardless of bandwidth or network errors. Only valid when used in conjunction with `Client` or `Server`. **Server** The function is only executed on the server. ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/functions/specifiers#metadataspecifiers) Metadata Specifiers [PreviousFunctionschevron-left](https://www.unrealsharp.com/unreal-framework/classes/functions) [NextDefault Actor Componentschevron-right](https://www.unrealsharp.com/unreal-framework/classes/default-actor-components) Last updated 28 days ago --- # Collections | UnrealSharp [TArraychevron-right](https://www.unrealsharp.com/data-and-asset-management/collections/tarray) [TNativeArraychevron-right](https://www.unrealsharp.com/data-and-asset-management/collections/tnativearray) [TSetchevron-right](https://www.unrealsharp.com/data-and-asset-management/collections/tset) [TMapchevron-right](https://www.unrealsharp.com/data-and-asset-management/collections/tmap) [PreviousMeta Datachevron-left](https://www.unrealsharp.com/unreal-framework/metadata) [NextTArraychevron-right](https://www.unrealsharp.com/data-and-asset-management/collections/tarray) Last updated 1 year ago --- # Primary Data Assets | UnrealSharp You can create a `UPrimaryDataAsset` in C# using `UCSPrimaryDataAsset`. Copy [UClass] public partial class UItemPrimaryDataAsset : UCSPrimaryDataAsset { public UItemPrimaryDataAsset() { AssetName = "Item"; } [UProperty(PropertyFlags.EditDefaultsOnly)] public partial FText ItemName { get; set; } } `AssetName` needs to match up with the type assigned in `AssetManager`settings in your project settings. [PreviousDeveloper Settingschevron-left](https://www.unrealsharp.com/data-and-asset-management/developer-settings) [NextLoading Primary Data Assetschevron-right](https://www.unrealsharp.com/data-and-asset-management/primary-data-assets/loading-assets) Last updated 1 month ago --- # Helper Methods | UnrealSharp [hashtag](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#methods-available-for-actor-classes) Methods Available for Actor Classes: ------------------------------------------------------------------------------------------------------------------------------------------------------------ ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#basic-spawn) Basic Spawn Copy AStaticMeshActor.Spawn(worldContextObject, MyActorClass); Spawns an instance of the specified class. ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#spawn-with-transform) Spawn with Transform Copy AStaticMeshActor.Spawn(worldContextObject, MyActorClass, GetActorTransform()); Spawns an instance of the specified class at a specific transform. ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#spawn-with-collision-handling) Spawn with Collision Handling Copy SpawnActorCollisionHandlingMethod method = SpawnActorCollisionHandlingMethod.AlwaysSpawn; AStaticMeshActor.Spawn(worldContextObject, MyActorClass, GetActorTransform(), method, instigator, owner); Spawns an instance of the specified class with specified collision handling, instigator, and owner. [hashtag](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#methods-available-for-actorcomponent-classes) Methods Available for ActorComponent Classes: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#retrieve-component) Retrieve Component Retrieves the StaticMeshComponent of the specified actor. ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#construct-new-components) Construct New Components Constructs new mesh components with specified owner, attachment settings, and transform. ### [hashtag](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#enabling-code-generation) Enabling Code Generation To use the code generation for your custom classes (it’s already enabled for engine classes), update your project file (csproj) to include the source generator. Add the following lines to your csproj file: [PreviousDefault Actor Componentschevron-left](https://www.unrealsharp.com/unreal-framework/classes/default-actor-components) [NextStructschevron-right](https://www.unrealsharp.com/unreal-framework/structs) Last updated 28 days ago * [Methods Available for Actor Classes:](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#methods-available-for-actor-classes) * [Basic Spawn](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#basic-spawn) * [Spawn with Transform](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#spawn-with-transform) * [Spawn with Collision Handling](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#spawn-with-collision-handling) * [Methods Available for ActorComponent Classes:](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#methods-available-for-actorcomponent-classes) * [Retrieve Component](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#retrieve-component) * [Construct New Components](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#construct-new-components) * [Enabling Code Generation](https://www.unrealsharp.com/unreal-framework/classes/helper-methods#enabling-code-generation) Copy UStaticMeshComponent? Mesh = UStaticMeshComponent.Get(actor); Copy UStaticMeshComponent MyNewMesh = UStaticMeshComponent.Construct(owner); USkeletalMeshComponent MyNewMesh2 = USkeletalMeshComponent.Construct(owner, manualAttachment, new Transform()); USplineMeshComponent MyNewMesh3 = USplineMeshComponent.Construct(owner, MyComponentClass, manualAttachment, new Transform()); Copy --- # TArray | UnrealSharp Example of setting up an array and adding to it. Copy [UClass] public partial class AMyShowcaseClass : AActor { [UProperty(PropertyFlags.EditAnywhere | PropertyFlags.BlueprintReadWrite)] public partial TArray Array { get; set; } public override void BeginPlay() { base.BeginPlay(); Array.Add(1); } } TArray can also be represented as an IList inside of a UFunction Copy [UFunction(FunctionFlags.BlueprintCallable)] public void TestList(IList myList) { PrintString($"List Count: {myList.Count}"); } [PreviousCollectionschevron-left](https://www.unrealsharp.com/data-and-asset-management/collections) [NextTNativeArraychevron-right](https://www.unrealsharp.com/data-and-asset-management/collections/tnativearray) Last updated 1 month ago --- # Replicated Properties | UnrealSharp Replicated properties are variables whose values are automatically synchronized across the network, from the server to all clients. UnrealSharp allows you to easily define which properties should be replicated and under what conditions. [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties#declaring-replicated-properties) Declaring Replicated Properties -------------------------------------------------------------------------------------------------------------------------------------------------------------- To declare a property as replicated, annotate it with the \[UProperty\] attribute and set the PropertyFlags.Replicated flag: Copy [UProperty(PropertyFlags.Replicated)] public partial int MyReplicatedInteger { get; set; } [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties#using-onrep-functions) Using OnRep Functions ------------------------------------------------------------------------------------------------------------------------------------------ For more control over replication, you can specify a callback function that the multiplayer system will call when a replicated property changes. This is particularly for updating game state or UI in response to value changes. Copy [UProperty(ReplicatedUsing = nameof(OnRep_MyReplicatedBool))] public partial bool MyReplicatedBool { get; set; } [UFunction] void OnRep_MyReplicatedBool() { PrintString($"MyReplicatedBool has been updated to {MyReplicatedBool}"); } [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties#onrep-function-with-old-value) OnRep Function with Old Value ---------------------------------------------------------------------------------------------------------------------------------------------------------- If you need to know the previous value of a property, you can define an OnRep function that takes the old value as a parameter: [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties#lifetime-conditions) Lifetime Conditions -------------------------------------------------------------------------------------------------------------------------------------- Sometimes, you might want to replicate a property only under specific conditions, such as only to the owning player. You can achieve this by specifying a LifetimeCondition: [PreviousMultiplayerchevron-left](https://www.unrealsharp.com/gameplay-systems/multiplayer) [NextRPCs (Remote Procedure Calls)chevron-right](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls) Last updated 28 days ago * [Declaring Replicated Properties](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties#declaring-replicated-properties) * [Using OnRep Functions](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties#using-onrep-functions) * [OnRep Function with Old Value](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties#onrep-function-with-old-value) * [Lifetime Conditions](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties#lifetime-conditions) Copy [UFunction] void OnRep_MyReplicatedBoolWithOldValue(bool oldValue) { PrintString($"MyReplicatedBool has been updated from {oldValue} to {MyReplicatedBool}"); } Copy [UProperty(PropertyFlags.Replicated, LifetimeCondition = LifetimeCondition.OwnerOnly)] public partial string MyReplicatedString { get; set; } --- # TNativeArray | UnrealSharp Copy [UClass] public partial class AActorTest : ACharacter { [UProperty(PropertyFlags.EditAnywhere)] public partial TNativeArray NativeArrayTest { get; set; } [UProperty(PropertyFlags.EditAnywhere)] public partial TNativeArray NativeArrayTest2 { get; set; } public override void BeginPlay() { base.BeginPlay(); Span test = [5, 6, 7, 8]; NativeArrayTest.CopyFrom(test); Span test2 = stackalloc int[NativeArrayTest.Length]; NativeArrayTest.CopyTo(test2); NativeArrayTest2.CopyFrom(test2); } } You can also use NativeArray without any marshalling costs TNativeArray can also be represented as an ReadOnlySpan inside of a UFunction [hashtag](https://www.unrealsharp.com/data-and-asset-management/collections/tnativearray#features) Supported Types ----------------------------------------------------------------------------------------------------------------------- Currently right now NativeArray only supports numerical primitive types [PreviousTArraychevron-left](https://www.unrealsharp.com/data-and-asset-management/collections/tarray) [NextTSetchevron-right](https://www.unrealsharp.com/data-and-asset-management/collections/tset) Last updated 1 month ago Copy public override void Tick(float deltaSeconds) { base.Tick(deltaSeconds); ref int MyNumber = ref NativeArrayTest.AsSpan()[0]; MyNumber++; } Copy [UFunction(FunctionFlags.BlueprintCallable)] public void TestSpanCall(ReadOnlySpan span) { PrintString($"Span Length: {span.Length}"); } --- # Loading Soft References | UnrealSharp Unreal has two ways to reference assets so they're not a hard reference. Both through `TSoftObjectPtr` and `TSoftClassPtr`, these must be loaded in order to use them. ### [hashtag](https://www.unrealsharp.com/data-and-asset-management/loading-soft-references#async-loading) Async Loading This API allows you to load soft references asynchronously. * If the reference is `null`, an exception is thrown. * If the asset is already loaded, it's returned immediately. * Otherwise, the asset is loaded in the background and returned once ready. **Load a single soft reference:** `var loadedReferences = await softReference.LoadAsync();` **Load a list of soft references:** `var loadedReferences = await softReferences.LoadAsync();` [PreviousLoading Primary Data Assetschevron-left](https://www.unrealsharp.com/data-and-asset-management/primary-data-assets/loading-assets) [NextMultiplayerchevron-right](https://www.unrealsharp.com/gameplay-systems/multiplayer) Last updated 8 months ago --- # TSet | UnrealSharp Example of using a TSet as a UProperty Copy [UClass] public partial class AMyShowcaseClass : AActor { [UProperty(PropertyFlags.EditAnywhere | PropertyFlags.BlueprintReadWrite)] public partial TSet MySet { get; set; } public override void BeginPlay() { base.BeginPlay(); MySet.Add(1); MySet.Add(2); } } TMap can also be represented as an ISet inside of a UFunction Copy [UFunction(FunctionFlags.BlueprintCallable)] public void TestSet(ISet MySet) { PrintString($"Set Count: {MySet.Count}"); } [PreviousTNativeArraychevron-left](https://www.unrealsharp.com/data-and-asset-management/collections/tnativearray) [NextTMapchevron-right](https://www.unrealsharp.com/data-and-asset-management/collections/tmap) Last updated 1 month ago --- # Multiplayer | UnrealSharp [Replicated Propertieschevron-right](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties) [RPCs (Remote Procedure Calls)chevron-right](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls) [Replicated UObjectschevron-right](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-uobjects) [PreviousLoading Soft Referenceschevron-left](https://www.unrealsharp.com/data-and-asset-management/loading-soft-references) [NextReplicated Propertieschevron-right](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties) Last updated 1 year ago --- # Async | UnrealSharp This plugin also supports the abilty to expose latent actions to Blueprint. To do so, just return a `Task` like you normally would. However, when you do the `await` statement, at the end, call the extension method `ConfigureWithUnrealContext()`. This makes sure that all parts of the operation will run on the correct thread. You can also use a cancellation token if you want. Simply add it as a parameter. The method signature must be public and supports returning `ValueTask`, `ValueTask`, `Task`, or `Task`, where `T` is any type that is supported as a UFunction parameter. Copy [UClass] public partial class AAsyncActor : AActor { // Cancellation token is optional. [UFunction(FunctionFlags.BlueprintCallable)] public async Task SlowAdd(int lhs, int rhs, CancellationToken cancellationToken) { PrintString($"Commencing the world's slowest addition..."); await Task.Delay(1000, cancellationToken).ConfigureWithUnrealContext(); if (cancellationToken.IsCancellationRequested || IsDestroyed) { return default; } int result = lhs + rhs; PrintString($"{lhs} + {rhs} = {result}!"); return result; } } The code above will generate a node like this in Blueprint: ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FIpxqodWQbDEHWjijuWFB%252Fimage.png%3Falt%3Dmedia%26token%3Dcdeed427-09cf-47a4-8432-158cd9866939&width=768&dpr=3&quality=100&sign=705350d6&sv=2) [PreviousTrace Channelschevron-left](https://www.unrealsharp.com/gameplay-systems/trace-channels) [NextCheats / Debug Commandschevron-right](https://www.unrealsharp.com/gameplay-systems/cheats-debug-commands) Last updated 13 days ago --- # Loading Primary Data Assets | UnrealSharp All types registered in `AssetManager` settings are accessible in C# through the static `AssetTypes` class. These bindings make it easy to locate and load all assets of a specific type: Copy UAssetManager assetManager = UAssetManager.Get(); // Optional list of asset bundles to load List bundles = new List(); // Load all primary assets of type ItemRecipe IList loadedItems = await assetManager.LoadPrimaryAssets(AssetTypes.ItemRecipe.PrimaryAssetList, bundles); To load specific assets, use the static `AssetIds` class or expose a `UProperty`of type `FPrimaryAssetId`and assign it in editor. Copy UAssetManager assetManager = UAssetManager.Get(); // Optional list of asset bundles to load List bundles = new List(); // Loads Item_Axe primary asset. UItem loadedItem = await assetManager.LoadPrimaryAsset(AssetIds.Item_Item_Axe, bundles); // Loads Item_Axe primary asset through assigned property. UItem loadedItem = await assetManager.LoadPrimaryAsset(AxeRecipeId, bundles); [PreviousPrimary Data Assetschevron-left](https://www.unrealsharp.com/data-and-asset-management/primary-data-assets) [NextLoading Soft Referenceschevron-right](https://www.unrealsharp.com/data-and-asset-management/loading-soft-references) Last updated 28 days ago --- # Static Variables | UnrealSharp Managing static variables in Unreal Engine can be tricky. Regular static variables have a global lifetime, meaning their values persist across the entire application runtime. While this may seem great, it can lead to issues. For instance, if you use regular static variables to store world-specific data, you might encounter problems such as: * **Memory Leaks:** Static variables won’t automatically release their references when a `UWorld` is destroyed, potentially causing garbage collection issues. * **Global Scope Conflicts:** Since regular static variables are shared across all worlds, their values can get overwritten easily ### [hashtag](https://www.unrealsharp.com/gameplay-systems/static-variables#static-variables-in-unrealsharp) Static Variables in UnrealSharp To enable these classes in your project you need to include this in your csproj: Copy ..\..\Plugins\UnrealSharp\Binaries\Managed\$(TargetFramework)\UnrealSharp.StaticVars.dll [hashtag](https://www.unrealsharp.com/gameplay-systems/static-variables#available-classes-that-manages-static-data) Available classes that manages static data ------------------------------------------------------------------------------------------------------------------------------------------------------------------- [FGameStaticVarchevron-right](https://www.unrealsharp.com/gameplay-systems/static-variables/fgamestaticvar-less-than-t-greater-than) [FWorldStaticVarchevron-right](https://www.unrealsharp.com/gameplay-systems/static-variables/fworldstaticvar-less-than-t-greater-than) [PreviousReplicated UObjectschevron-left](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-uobjects) [NextFWorldStaticVarchevron-right](https://www.unrealsharp.com/gameplay-systems/static-variables/fworldstaticvar-less-than-t-greater-than) Last updated 25 days ago * [Static Variables in UnrealSharp](https://www.unrealsharp.com/gameplay-systems/static-variables#static-variables-in-unrealsharp) * [Available classes that manages static data](https://www.unrealsharp.com/gameplay-systems/static-variables#available-classes-that-manages-static-data) --- # TMap | UnrealSharp Example of using a TMap as a UProperty Copy [UClass] public partial class AMyShowcaseClass : AActor { [UProperty(PropertyFlags.EditAnywhere | PropertyFlags.BlueprintReadWrite)] public partial TMap MyMap { get; set; } public override void BeginPlay() { base.BeginPlay(); MyMap.Add(1, "First Value"); MyMap.Add(2, "Second Value"); UpdateMapWithKey(2, "Updated Second Value"); } } TMap can also be represented as an IDictionary inside of a UFunction Copy [UFunction(FunctionFlags.BlueprintCallable)] public void TestDictionary(IDictionary MyDict) { PrintString($"Dictionary Key Count: {MyDict.Keys.Count}"); } [PreviousTSetchevron-left](https://www.unrealsharp.com/data-and-asset-management/collections/tset) [NextDeveloper Settingschevron-right](https://www.unrealsharp.com/data-and-asset-management/developer-settings) Last updated 13 days ago --- # Developer Settings | UnrealSharp Developer Settings is a class that shows up in **Project Settings** to configure values without needing to create a Blueprint. **Requirements:** * Create a class that derives from `UDeveloperSettings`. * Assign a config category to the class, for example:`[UClass(config: "Game")]`. * Any property you want to edit must be marked with `PropertyFlags.Config`. * Object references can't be saved to config. They need to be soft referenced through `TSoftObjectPtr<>` or `TSoftClassPtr<>`. Copy [UClass(config: "Game")] public partial class UMyDeveloperSettings : UDeveloperSettings { [UProperty(PropertyFlags.EditAnywhere | PropertyFlags.Config)] public partial float MyConfigFloat { get; set; } [UProperty(PropertyFlags.EditAnywhere | PropertyFlags.Config)] public partial TSoftObjectPtr MyConfigMaterial { get; set; } } If you now open the project settings, you can find your custom developer settings there. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FJMGYw6gO1rVjljAN6Jt1%252FDeveloperSettings.PNG%3Falt%3Dmedia%26token%3D4da405b1-0a17-4cd1-abee-c677d3c28c6f&width=768&dpr=3&quality=100&sign=4280506c&sv=2) How to get the values in C#: [PreviousTMapchevron-left](https://www.unrealsharp.com/data-and-asset-management/collections/tmap) [NextPrimary Data Assetschevron-right](https://www.unrealsharp.com/data-and-asset-management/primary-data-assets) Last updated 1 month ago Copy public override void BeginPlay() { UMyDeveloperSettings settings = GetDefault(); if (settings.MyConfigMaterial.IsValid) { // Do something with the material } } --- # Gameplay Tags | UnrealSharp All defined `FGameplayTags` in your project are available in code through the `GameplayTags`static class. Copy FGameplayTag myGameplayTag = GameplayTags.MyGameplayTag; FGameplayTag myGameplayTagMySubTag = GameplayTags.MyGameplayTag_MySubTag; The `GameplayTags` class updates in real time as you add more tags to your project. [PreviousFGameStaticVarchevron-left](https://www.unrealsharp.com/gameplay-systems/static-variables/fgamestaticvar-less-than-t-greater-than) [NextGameplay Tag Containerchevron-right](https://www.unrealsharp.com/gameplay-systems/gameplay-tags/gameplay-tag-container) Last updated 28 days ago --- # Trace Channels | UnrealSharp Working with collision channels in C# is not great, as the engine internally uses `ECollisionChannel` mapped to `ETraceTypeQuery` for BP-exposed tracing functions like `LineTraceByChannel` and others. By default, these mappings are not intuitive in C#, as they are just numeric IDs, with no info about the collision channel name. To bridge this gap, the `ETraceChannel` provide a way to work with more readable and user-defined channel names in C#. ### [hashtag](https://www.unrealsharp.com/gameplay-systems/trace-channels#etracechannel) ETraceChannel The `ETraceChannel` enum defines a set of collision channels, each of which maps to a corresponding entry in the project's collision settings. Copy public enum ETraceChannel { Visibility = 0, // Default engine-provided channel Camera = 1, // Default engine-provided channel MyOtherChannel = 2, // User-defined collision channel } circle-info **Note:** The entries in `ETraceChannel` will regenerate whenever new collision channels are added or existing ones are modified in the Unreal Editor. Removing entries requires an engine restart, as it's an engine bug that they keep the removed channel around. ### [hashtag](https://www.unrealsharp.com/gameplay-systems/trace-channels#etracechannel-to-etracetypequery) ETraceChannel to ETraceTypeQuery Here's how to use the `ETraceChannel` enum and the `ToQuery` to use it with `ETraceTypeQuery`: Copy ETraceTypeQuery traceChannel = ETraceChannel.Camera.ToQuery(); SystemLibrary.LineTraceByChannel(this, start, end, traceChannel, false, actors, EDrawDebugTrace.None, out FHitResult hit, true); [PreviousC# Created Gameplay Tagschevron-left](https://www.unrealsharp.com/gameplay-systems/gameplay-tags/c-created-gameplay-tags) [NextAsyncchevron-right](https://www.unrealsharp.com/gameplay-systems/async) Last updated 25 days ago * [ETraceChannel](https://www.unrealsharp.com/gameplay-systems/trace-channels#etracechannel) * [ETraceChannel to ETraceTypeQuery](https://www.unrealsharp.com/gameplay-systems/trace-channels#etracechannel-to-etracetypequery) --- # FGameStaticVar | UnrealSharp `FGameStaticVar` is a class designed to manage static variables that will persist during the whole game. In editor the value will reset on Play In Editor start/end and on hot reload. **Declaration and Usage** You can declare a game-static variable like this: Copy public static readonly FGameStaticVar MyStaticFloat = new(); To use it within your C# code: Copy public partial class AMyActor : AActor { public static readonly FGameStaticVar MyStaticFloat = new(); public AMyActor() { // Set the value to 70 for this session MyStaticFloat.Value = 70; } } [PreviousFWorldStaticVarchevron-left](https://www.unrealsharp.com/gameplay-systems/static-variables/fworldstaticvar-less-than-t-greater-than) [NextGameplay Tagschevron-right](https://www.unrealsharp.com/gameplay-systems/gameplay-tags) Last updated 28 days ago --- # RPCs (Remote Procedure Calls) | UnrealSharp circle-info _**If you want a RPC to be unreliable, just don’t declare FunctionFlags.Reliable**_ [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls#run-on-server) Run on Server -------------------------------------------------------------------------------------------------------------------------------- Use the **\[UFunction\]** attribute with FunctionFlags.RunOnServer to indicate that a method should be executed on the server: Copy [UFunction(FunctionFlags.RunOnServer | FunctionFlags.Reliable)] public partial void ServerFunction(); public partial void ServerFunction_Implementation(); { // Server-side code } [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls#run-on-owning-client) Run on Owning Client ---------------------------------------------------------------------------------------------------------------------------------------------- Similarly, to execute a function on the owning client, use FunctionFlags.RunOnClient: Copy [UFunction(FunctionFlags.RunOnClient | FunctionFlags.Reliable)] public partial void ClientFunction(); public partial void ClientFunction_Implementation(); { // Client-side code } [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls#multicast) Multicast ------------------------------------------------------------------------------------------------------------------------ For functions that should be executed on both the server and all clients, use FunctionFlags.Multicast: [PreviousReplicated Propertieschevron-left](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-properties) [NextReplicated UObjectschevron-right](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-uobjects) Last updated 19 days ago * [Run on Server](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls#run-on-server) * [Run on Owning Client](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls#run-on-owning-client) * [Multicast](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls#multicast) Copy [UFunction(FunctionFlags.Multicast | FunctionFlags.Reliable)] public partial void MulticastFunction(); public partial void MulticastFunction_Implementation(); { // Code executed on both server and clients } --- # C# Created Gameplay Tags | UnrealSharp #### [hashtag](https://www.unrealsharp.com/gameplay-systems/gameplay-tags/c-created-gameplay-tags#define-tags) Define Tags Create a static class to store your tags. Copy public static class IslandGenTags { public static readonly FGameplayTag IslandGen_Island = new FGameplayTag("IslandGen.Island", "Optional Comment"); } #### [hashtag](https://www.unrealsharp.com/gameplay-systems/gameplay-tags/c-created-gameplay-tags#tags-registration) Tags Registration triangle-exclamation Due to initialization timing, these tags are not found in the global `GameplayTags` static class. You must store the returned `FGameplayTag` in your own static field for later use. To ensure tags are available before the editor or other systems attempt to access them, register them early, ideally within your module's `StartupModule`. Copy public class FIslandGen : IModuleInterface { public void StartupModule() { // Runs the static constructor and registers the gameplay tags RuntimeHelpers.RunClassConstructor(typeof(IslandGenTags).TypeHandle); } public void ShutdownModule() { } } [PreviousGameplay Tag Containerchevron-left](https://www.unrealsharp.com/gameplay-systems/gameplay-tags/gameplay-tag-container) [NextTrace Channelschevron-right](https://www.unrealsharp.com/gameplay-systems/trace-channels) Last updated 29 days ago --- # FWorldStaticVar | UnrealSharp `FWorldStaticVar` is a class designed to manage static variables that are tied to the lifetime of a `UWorld`. This means the value is automatically cleaned up when the associated `UWorld` is destroyed, such as during level transitions. **Declaration and Usage** You can declare a world-static variable like this: Copy public static readonly FWorldStaticVar MyStaticFloat = new(); To use it within your C# code: Copy public partial class AMyActor : AActor { public static readonly FWorldStaticVar MyStaticFloat = new(); public AMyActor() { // Set the value to 70 in the current World MyStaticFloat.Value = 70; } } [PreviousStatic Variableschevron-left](https://www.unrealsharp.com/gameplay-systems/static-variables) [NextFGameStaticVarchevron-right](https://www.unrealsharp.com/gameplay-systems/static-variables/fgamestaticvar-less-than-t-greater-than) Last updated 28 days ago --- # Widgets | UnrealSharp [Create/Compose Widgetschevron-right](https://www.unrealsharp.com/ui/widgets/create-compose-widgets) [Show Widget On Screenchevron-right](https://www.unrealsharp.com/ui/widgets/show-widget-on-screen) [PreviousCheats / Debug Commandschevron-left](https://www.unrealsharp.com/gameplay-systems/cheats-debug-commands) [NextCreate/Compose Widgetschevron-right](https://www.unrealsharp.com/ui/widgets/create-compose-widgets) Last updated 25 days ago --- # Replicated UObjects | UnrealSharp To replicate UObjects you have to make a new `UObject`class inheriting from `UCSReplicatedObject`. Copy [UClass] public class UMyReplicatedUObject : UCSReplicatedObject { } This object can now replicate variables and send RPCs. To use your replicated UObject in Unreal's multiplayer system it needs to be registered through an `AActor` or `UActorComponent`. [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-uobjects#actor-example) **Actor Example** ---------------------------------------------------------------------------------------------------------------------------- Copy [UClass] public partial class AMyReplicatedActor : AActor { [UProperty(PropertyFlags.Replicated)] public partial UMyReplicatedUObject ReplicatedObject { get; set; } public override void BeginPlay() { base.BeginPlay(); if (HasAuthority()) { ReplicatedObject = NewObject(this); // Register the new replicated UObject AddReplicatedSubObject(ReplicatedObject); } } } [hashtag](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-uobjects#uactorcomponent-example) UActorComponent Example -------------------------------------------------------------------------------------------------------------------------------------------- [PreviousRPCs (Remote Procedure Calls)chevron-left](https://www.unrealsharp.com/gameplay-systems/multiplayer/rpcs-remote-procedure-calls) [NextStatic Variableschevron-right](https://www.unrealsharp.com/gameplay-systems/static-variables) Last updated 1 month ago * [Actor Example](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-uobjects#actor-example) * [UActorComponent Example](https://www.unrealsharp.com/gameplay-systems/multiplayer/replicated-uobjects#uactorcomponent-example) Copy [UClass] public partial class UMyReplicatedComponent : UActorComponent { [UProperty(PropertyFlags.Replicated)] public partial UMyReplicatedUObject ReplicatedObject { get; set; } public override void BeginPlay() { base.BeginPlay(); if (Owner.HasAuthority()) { ReplicatedObject = NewObject(this); // Register the new replicated UObject AddReplicatedSubObject(ReplicatedObject); } } } --- # Gameplay Tag Container | UnrealSharp `FGameplayTagContainer` is a wrapper around an array of `FGameplayTag`. UnrealSharp provides a intuitive API to work with them with C# features: #### [hashtag](https://www.unrealsharp.com/gameplay-systems/gameplay-tags/gameplay-tag-container#constructing-a-fgameplaytagcontainer) Constructing a `FGameplayTagContainer` 1. **Using a list of** `**FGameplayTag**`**:** Copy List tags = new List { GameplayTags.MyGameplayTag, GameplayTags.MyGameplayTag_MySubTag }; FGameplayTagContainer containerInitWithList = new FGameplayTagContainer(tags); 1. **Using Array Parameters:** Copy FGameplayTagContainer containerInitWithArrayParams = new FGameplayTagContainer( GameplayTags.MyGameplayTag, GameplayTags.MyGameplayTag_MySubTag ); #### [hashtag](https://www.unrealsharp.com/gameplay-systems/gameplay-tags/gameplay-tag-container#appending-tags) Appending Tags 1. **Appending a List of Tags:** Copy gameplayTagContainer.AppendTags(tags); 1. **Appending Individual Tags:** 1. **Appending Another Container:** [PreviousGameplay Tagschevron-left](https://www.unrealsharp.com/gameplay-systems/gameplay-tags) [NextC# Created Gameplay Tagschevron-right](https://www.unrealsharp.com/gameplay-systems/gameplay-tags/c-created-gameplay-tags) Last updated 28 days ago Copy gameplayTagContainer.AppendTags( GameplayTags.MyGameplayTag, GameplayTags.MyGameplayTag_MySubTag ); Copy gameplayTagContainer.AppendTags(containerInitWithList); --- # Create/Compose Widgets | UnrealSharp Make a class that inherits from `UUserWidget` (for layouts) or a specific widget like `UTextBlock` for extensions. Copy [UClass] public partial class UMyWidget : UUserWidget { } Now add the child widgets to compose your widget. The widgets you want to bind needs to have `UProperty` and `BindWidget` to work. Copy [UClass] public partial class UMyWidget : UUserWidget { [UProperty, BindWidget] public partial UImage MyImage { get; set; } [UProperty, BindWidget] public partial UTextBlock MyTextBlock { get; set; } } In the Unreal Editor, create a new Widget Blueprint. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252Fu8w83nmCHQLTHaV4FDrT%252Fimage.png%3Falt%3Dmedia%26token%3Db3082654-9dd1-44a8-aed6-e135648a89b2&width=768&dpr=3&quality=100&sign=a43e5800&sv=2) ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FvG3EKAkM3MBeLB52NWt8%252Fimage.png%3Falt%3Dmedia%26token%3Df6474d54-cd04-4ee1-9043-5e028d356f61&width=768&dpr=3&quality=100&sign=54186041&sv=2) When you have opened up the widget asset, you'll see compiler errors stating that the required widgets are missing. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252Fbn7rsFoXeUUaI7K3daJU%252Fimage.png%3Falt%3Dmedia%26token%3Dd6365b62-57d1-4f53-9b1b-095ebc245cf6&width=768&dpr=3&quality=100&sign=3ed97f54&sv=2) To resolve errors: * Drag a widget element you want to bind from the **Palette** window into your **Hierarchy** (as shown in the image below) * You must rename these spawned widgets to exactly match the property names in your C# code (in this case: `MyImage` and `MyTextBlock`). ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FpVKO5qs4ooWo2Gf2G9ge%252Fimage.png%3Falt%3Dmedia%26token%3Da8bba984-7820-499f-8005-f636ec17337e&width=768&dpr=3&quality=100&sign=ae7f6096&sv=2) Hit Compile in the editor. The errors will disappear as the C# properties successfully "bind" to the newly spawned widgets. [PreviousWidgetschevron-left](https://www.unrealsharp.com/ui/widgets) [NextShow Widget On Screenchevron-right](https://www.unrealsharp.com/ui/widgets/show-widget-on-screen) Last updated 28 days ago --- # Cheats / Debug Commands | UnrealSharp To add cheats or debug commands that can be executed from the in-game console, create a cheat manager extension class. Example: Copy [UClass] public partial class UMyCheatManagerExtension : UCSCheatManagerExtension { [UFunction(FunctionFlags.Exec)] public void KillAllEnemies() { // Your cheat logic here } } Any method marked with `FunctionFlags.Exec` will automatically be exposed as a console command. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252FaixuvybSMJENerY7XwKb%252Fimage.png%3Falt%3Dmedia%26token%3D1eb4f9bc-9aba-46a0-9c38-7641b2562148&width=768&dpr=3&quality=100&sign=1bd0ec6d&sv=2) [PreviousAsyncchevron-left](https://www.unrealsharp.com/gameplay-systems/async) [NextWidgetschevron-right](https://www.unrealsharp.com/ui/widgets) Last updated 11 days ago --- # Extension / Mixin Methods | UnrealSharp Extension methods are static methods that can be invoked on an existing class as if they were instance methods of that class. This is particularly useful when you want to add methods to existing classes (such as `Actor`) without modifying their original source code. [hashtag](https://www.unrealsharp.com/glue-generation/extension-methods#usage-requirements) Usage Requirements ------------------------------------------------------------------------------------------------------------------- To generate extension methods from C++ to C#, a C++ function needs to follow these: * **Static and Public:** Extension methods must be declared as `static` and `public` in your C++ class. * **Meta Attribute:** Use the `meta=(ExtensionMethod)` * **Parameter Requirements:** The first parameter must be the type you are extending (`AActor*` in the case of extending `AActor`). * **BlueprintCallable or ScriptMethod:** Ensure the method is marked with `BlueprintCallable` or `ScriptMethod` depending on your use case. * **BlueprintFunctionLibrary** Needs to be in a BlueprintFunctionLibrary. ### [hashtag](https://www.unrealsharp.com/glue-generation/extension-methods#example) Example Copy UCLASS() class UCSTestExtensions : public UBlueprintFunctionLibrary { GENERATED_BODY() public: // Example of an extension method that takes an int parameter // public static void ExtensionMethod1(this Actor actor, int value) UFUNCTION(meta=(ExtensionMethod, ScriptMethod)) static void ExtensionMethod1(AActor* Actor, int32 Value) {}; // Example of an extension method that takes a float parameter // public static void ExtensionMethod2(this Actor actor, float value) UFUNCTION(meta=(ExtensionMethod, ScriptMethod)) static void ExtensionMethod2(AActor* Actor, float Value) {}; }; And it’ll generate the following: And can be used like this: [PreviousShow Widget On Screenchevron-left](https://www.unrealsharp.com/ui/widgets/show-widget-on-screen) Last updated 1 month ago * [Usage Requirements](https://www.unrealsharp.com/glue-generation/extension-methods#usage-requirements) * [Example](https://www.unrealsharp.com/glue-generation/extension-methods#example) Copy public static class CSharpForUEExtensions { /// /// Example of an extension method that takes a float parameter /// public static void ExtensionMethod2(this Actor actor, float value) /// public static void ExtensionMethod2(this UnrealSharp.Engine.Actor actor, float value) { UnrealSharp.CSharpForUE.CSTestExtensions.ExtensionMethod2(actor, value); } /// /// Example of an extension method that takes an int parameter /// public static void ExtensionMethod1(this Actor actor, int value) /// public static void ExtensionMethod1(this UnrealSharp.Engine.Actor actor, int value) { UnrealSharp.CSharpForUE.CSTestExtensions.ExtensionMethod1(actor, value); } } Copy public override void BeginPlay() { MyActorReference.ExtensionMethod1(20); base.BeginPlay(); } --- # Show Widget On Screen | UnrealSharp To spawn a widget, your class needs a reference to the Widget Blueprint class. Use `TSubclassOf` to create a selectable dropdown in the Unreal Editor, to be able to choose your Widget Blueprint. Copy [UClass] public partial class AMyCharacter : ACharacter { [UProperty(PropertyFlags.EditDefaultsOnly)] protected partial TSubclassOf MyWidgetClass { get; set; } } Which creates this in your child BP class, now assign it with a widget blueprint you want to spawn. ![](https://www.unrealsharp.com/~gitbook/image?url=https%3A%2F%2F4179970252-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fb0wzkekwYXS1rYy7c988%252Fuploads%252F47BlvfXW5Lm8wHAwXk3j%252Fimage.png%3Falt%3Dmedia%26token%3D73a220df-1cf8-44fa-92d6-2209025ed99b&width=768&dpr=3&quality=100&sign=a0ecda95&sv=2) Now you can create the widget blueprint and show it: `AddToViewport` is the quickest way to get a widget on screen, it’s generally considered "quick and dirty". Highly recommend using built-in plugins like [CommonUIarrow-up-right](https://dev.epicgames.com/documentation/en-us/unreal-engine/overview-of-advanced-multiplatform-user-interfaces-with-common-ui-for-unreal-engine) to build more complex and scalable UI. It works with UnrealSharp right out of the box. [PreviousCreate/Compose Widgetschevron-left](https://www.unrealsharp.com/ui/widgets/create-compose-widgets) [NextExtension / Mixin Methodschevron-right](https://www.unrealsharp.com/glue-generation/extension-methods) Last updated 27 days ago Copy [UClass] public partial class AMyCharacter : ACharacter { [UProperty(PropertyFlags.EditDefaultsOnly)] protected partial TSubclassOf MyWidgetClass { get; set; } public override void BeginPlay() { // CreateWidget is available in any UObject class. UMyWidget myWidget = CreateWidget(MyWidgetClass); myWidget.AddToViewport(); // Custom initialization function that I created myWidget.InitializeFrom(this); } } ---