nverenik / UnrealDI

Dependency Injection container for Unreal Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnrealDI

MIT license

Dependency Injection container for Unreal Engine. Container will take care of objects creation and their lifetime.

This implementation works on top of UObjects and UInterfaces.

Getting started

First, you need to setup your container and register some types into it:

// create builder object
FContainerBuilder Builder;

// register type UMyService as implementation of IMyService interface
Builder.RegisterType<UMyService>().As<IMyService>();

// create container itself
UObjectContainer* Container = Builder.Build();

After that you can ask it to resolve some instances:

TScriptInterface<IMyService> MyService = Container->Resolve<IMyService>();

Supported versions

UnrealDI was tested to work with Unreal versions 4.25, 4.26 and 4.27.

Repository structure

This repository contains two plugins:

  • UnrealDI — contains DI functionality to be used in game.
  • UnrealDITests — contains Tests for main plugin and not intended for shipping.

Installation

  1. Download latest release
  2. Copy UnrealDI folder into Plugins inside your project.

Acknowledgment

UnrealDI is heavily inspired by Hypodermic, but designed with Unreal Engine specifics in mind.

About

Dependency Injection container for Unreal Engine

License:MIT License


Languages

Language:C++ 98.2%Language:C# 1.5%Language:C 0.3%