Magic Nodes

Yes you can use

TSubclassOf<someClass> myClassPin

as input to pass a BP class to c++ code.

Thank you for the fast response!

That’s true about the TSubClassOf! But, what if I want to pass an instance of the Blueprint class, in order to access functions/variables defined in the Blueprint class?

I’m guessing that it can be only be done only with reflection, right?

Yes, BP object can only be accessed from C++ if you use the reflection system.
I want to create a default API for that, I just too chaotic situation right now and can never start it.

@FrancescoDeso Also, I believe ‘scripting’ is a better option for that.
I am investigating, studying, learning a viable avenue to make it happen instead of go full c++ there. I hope what I’m researching works well with that, still got no concrete results :slight_smile:
https://forums.unrealengine.com/core/image/gif;base64

Yet again, thank you for the fast response! :slight_smile:

Yeah, it’s true, what I wanted to do was kind of a “hack”. Basically I had a UMG widget with a list and wanted to make a C++ “script” to fill it with stuff in a few lines of code, instead of making LOTS of boilerplate spaghetti blueprint nodes. I wanted to skip the bae C++ class, but apparently there is no way to avoid it!

Seeing your work, I’m sure you’ll find very clever solutions for these kind of problems in the future :slight_smile: Let me tell you again that your plugin is amazing!

Interesting case study… a custom C# compiler running (compiled) code on MagicNodes within the Unreal Editor :stuck_out_tongue:
To run the node as an async task just have to give C# class a little ‘Async’ attribute
(can run C# scripts as normal UFunctions or Async threads):

What is this wizardy :O? Could we try?

I am working on a compiler to make it understand Unreal Blueprint’s variables and generate input pins on the node from a C# class.
For now it’s not safe to use it on any project.

After 2 trillion crashes… I got a C# compiler working within Unreal Editor, with error reports, compiler failures and etc:


and… C# properties declared on class generate pins on blueprint node + default values! :smiley:

There’s a lot of things that are still a mystery though… very experimental thing, this “hello world” trial was almost impossible LOL

This is truly remarkable! Being able to write C# scripts in a way this well integrated with the Unreal system would allow to prototype quite fast!

Can’t wait to see more :smiley:

The best part is the almost instantly compiled code, with SSD I get around 2 seconds to recompile the C# dll, generate pins and etc.

The two major problems I have with this is:

  1. AOT compilation, I have no idea how that would work within Unreal. Mobiles and Consoles do not allow JIT code.

  2. Marshalling user-created blueprint structs that C# don’t know anything about. This is a real hard problem.

Yes exactly, it would be an all round “mid layer” scripting language!

I don’t know how much you could do about point 1… and neither for point 2 to be honest!

I had no idea what I was getting myself into… Until I had to do this with Slate code:

Somebody kill me please! :o
Finally got it working… without input latency…

hint: FString::ParseIntoArray | Unreal Engine Documentation

It’s a trap! Don’t do it!! Stay away from that thing LOL

Implemented C# runtime exceptions.
We can throw exceptions from CS code and Unreal will report the error, while #WITH_EDITOR, both on message panel and as message bubble on the Node where the exception occurred while playing PIE, bringing graph focus to the node:

Implemented C# compiler on an async thread… but now Blueprint graph is randomly crashing complaining about tasks before ticking;
Something I have to investigate later how to workaround … :

Does this mean that C# Support is coming to Magic node in the near future?

That’s the idea.
But not NetCore though; at least until dotNET6 (the compiler uses libraries that can’t be used on dotNET5 yet).

But C# interop is so complicated that I don’t know if this is ever going to be ready for production or if Mobile is ever going to be supported.

The dirty crash on Graph Tick() was fixed.
Epic did a few changes on Unreal 4.26 that forced me to take a slightly different path from what I was doing on 4.25…

I am dropping another screenshot here for posterity, because this is the craziest ■■■■ I have ever done :stuck_out_tongue:

This is taking a very long time to make it right… But I’m slowly putting together a custom reflection system for C# code completion;
I am building entirely from scrash in C++ because I can’t really make the built-in Intellisense of Visual Studio to work from within Unreal’s Editor.

Code completion systems are really complex stuff, I wish I could just skip it, but it’s important to have it (for most people, some actually disable code completion lol).
Anyway, process is slow, but this custom C# analyzer built in Unreal C++ is almost working, now missing are function signature hints and “field info” of items found by reflection while typing.

The real trick in the end is how to make it smooth, no Editor hangs ever. I am performing a lot of caching trickery to avoid slowdowns.

Also another reason why this stupid thing is so hard is because I cannot load script assembly (C# DLLs) before entering PIE mode, or the VM locks the DLL and node compilation then would fail on the node, making C# DLLs fail to overwrite old code. Lot’s of annoying little details that must be addressed, but things are showing progress… I call this IntelliNONsense, all rights reserved, patent pending :stuck_out_tongue:

So, I got a clean implementation of C# reflection integrated to Unreal Editor. (restarted from scratch three times)

This is not as great as IntelliSense for C# in Visual Studio, because can’t manage VS Project files from this, but it’s good enough to at least peek some info and not code in the dark when typing in a CS Node:

It’s sad that reflection does not store any user comments from CS files, Visual Studio actually stores them into some XML files, so without a full MSBuild setup to manage VS Projects (which is too heavy just to type simple code in a node) comments cannot appear in reflection bubbles.

For now I’m done with this and will next weekend begin to implement actual GameFramework code in C#, but first I have to add a bridge between C# and Unreal’s Console Commands, as well as an avenue to invoke Unreal’s “Process Event” method which allows to call by name functions directly into the Blueprint’s Virtual Machine.
Will see how that goes.