[Mono-ue] What to do when API not available ?

Michael Hutchinson m.j.hutchinson at gmail.com
Sun Nov 9 01:00:22 UTC 2014


The C# binding uses the same type information and hooks that Blueprint
does, it's not a full C++ binding system.

Specifically in this case, only methods that are declared as
UFunctions of type BlueprintImplementableEvent or BlueprintNativeEvent
can be overridden. This is because when they are declared in C++, the
Unreal Header Tool (UHT) generates C++ glue/thunk methods allowing
overrides to be provided as function pointers. When you override those
methods in C#, MonoAssemblyProcess generates a static ctor that passes
the C# method to Unreal type system as the implementation for the
method.

Overriding arbitrary C++ methods without glue code is possible by
modifying the vtable (like CppSharp does) but definitely not easy
right now.

I'd advise using a simple C++ plugin. You can create an AGameMode
subclass that overrides the virtual functions you need and delegates
them to BlueprintImplementableEvent UFunctions. The binding system
will automatically expose those as virtual methods on the C# wrapper
for your AGameMode subclass.

You could also consider an engine patch to make those methods into
BlueprintImplementableEvents.

 - m

On 8 November 2014 18:48, Petter Hansson <me at petterhansson.se> wrote:
> Hello,
>
> what are my options if a particular Unreal API has not been exposed to C#? I
> need to do a lot of modification to my own game mode (i.e. derived from
> AGameMode), and just a few of its virtual functions have been exposed for
> ShooterGame. I presume I can somehow complete the bindings myself using
> MonoScriptGenerator, how would I go about that? Quick-fixing this particular
> issue via writing a C++ plugin is something I'd like to avoid (preferring a
> proper fix) as having a native component for what should be a managed
> library is somewhat counter-intuitive.
>
> I've been drafted to implement a C# networking lib to Unreal so my Unreal
> knowledge is not all that awesome. :) Getting it running inside Mono was
> easy, it's an entirely different matter fitting it into the Unreal engine
> framework...
>
> Thanks in advance for any help!
>
> --
> Petter Hansson
> MuchDifferent
> petter.hansson at muchdifferent.com
>
>
> _______________________________________________
> Mono-ue mailing list
> Mono-ue at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-ue
>



-- 
Michael Hutchinson ~ https://mhut.ch


More information about the Mono-ue mailing list