Giter Site home page Giter Site logo

sleeptightansic / actorsingleton Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 36 KB

Small code plugin for Unreal 5 which adds inheritable Actor class that can be spawned only once within same World context.

License: MIT License

C# 3.93% C++ 96.07%
actor cpp plugin singleton ue5 ue5-plugin unreal-engine-5

actorsingleton's Introduction

ActorSingleton

Tiny UE5 plugin that adds AActorSingleton class.

Install like every other plugin, by cloning into project's Plugins directory.

For context see the information below or read the source code.

About

This plugin has been created for my personal use, but I decided to publish it, since it has proven to be somehow usefull.

Imagine the following case: you need an UObject that lives within UWorld, there can be only one spawned instance of said object and it must be accessible from the Editor's Level Viewport. Basically, something like "Singleton".

So what options do we have? Unreal Engine has few ways of creating singletons, the best out of them is creating a class derived from USubsytem. The one that suits most of our needs is UWorldSubsystem, but said class isn't spawnable and won't appear in the Level Viewport, so it doesn't fully fit our needs.

The other option would be creating an AActor. Actors are easily accessible from Level Viewport. However, how do we ensure that there is only one spawned instance of said Actor?...

...and this is why this plugin exists. It introduces AActorSingleton class. If you try to spawn multiple instances of said class, it will only allow to spawn the first instance and will automaticly destroy the rest.

Usage

Derive from AActorSingleton and make sure that ActorSingleton::IsFinalParent returns true for your class.

Whenever you try to spawn a duplicate instace, you will get a meaningfull error about it. If you try to do this by placing an Actor to the Level Viewport you will even get a clear popup message:

image

Tested on Linux with UE 5.3.2 and clang

actorsingleton's People

Contributors

sleeptightansic avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.