[Plugin] klawr C# script plugin dev thread

Hey all,

having reached a certain point in further developing the klawr plugin (a fork of enlights great work), i thought i make a thread to keep you updated and answer questions.

klawr is a plugin to use C# as ‘script’ language (not entirely correct, since its compiled into a dll) to use in UE4 (4.8.1-4.8.3 at least, until epic does some harsh changes in UFUNCTION/UPROPERTY, it should work with later versions too).

Whats works now:

  • Write C# classes and expose them to Blueprints (adding a KlawrScriptComponent to an actor)
  • Read/Write C# class properties (exposed by the UPROPERTY attribute)
  • Call Blueprint exposed c++ functions from C#


  • Works currently only on Win64 (plan is to port to CoreCLR when they fixed some showstoppers)
  • Only Blueprint exposed functions can be called from C# (not that many are exposed)

Next step:

  • Make C# methods callable from blueprints DONE

For installation and usage please read the in the repository. You won’t have problems if you follow the instructions.
When you add a KlawrScriptComponent for the first time in a project and nothing happens, just restart the editor. It will load properly afterwards.

I’ll keep this post updated

  • Algorithman

Edit: 4.10.1 works just fine too

Great work!

Fantastic. I hope you get to Make C# methods callable from blueprints.

I think I will be giving it a shot then.

I can already call them, just the Blueprint intregration is tricky.

Is there a reference or example on how to create a proper UEdGraph/custom K2Node somewhere?

PS: your post is not very readably in the UEDark style :slight_smile:

Finally got the first part of the custom node running.


  • the node shows up :cool: (actually was the hard part)
  • switching of the C# classes exposed functions via the context menu

Still to do:

  • code the actual call to the C# method (with the parameters) DONE
  • adjust return node to C# methods return parameter DONE
  • apply meta data from the UPROPERTY attribute in C# to the input parameters of the node DONE
  • reconnect pins after recompile (where possible)
    and probably 5 other things i didn’t think of now.

And to get Rama his glory: Thanks, without your Read/Write Config variables node, i wouldn’t be so far now :slight_smile:

  • Algorithman

This shows how to create your own blueprint nodes:

Thanks for the link, found this one already, but this simple example didn’t help, since its a morphing node. I went with a more complex one of Rama, the ConfigReadWrite Node as a starting point.

I think i’m done with the node at the end of the week. Need to refine the internal wiring and create the call function to pass the parameters on.

  • Algorithman

I got this working in 4.9 but i cant get code working. Can you send me a sample code ?

Sorry for the late response, work keeps me quite busy these days, dont have much time for playin with UE (workin overtime , thx alot boss :mad:)
I hope i can get more updates soon.

Code for the C# side? Just create a new script (refer to and then write whatever you want in the generated .cs file. It’s quite easy.

(since i don’t know which version you use, i’ll give you my easy test case)

  • Create a actor (cube or something) named TestActor
  • Create your Klawr script component and put it into the world
  • Edit your script

using Klawr.ClrHost.Interfaces;
using Klawr.ClrHost.Managed.SafeHandles;
using Klawr.UnrealEngine;
using Klawr.ClrHost.Managed.Attributes;

namespace Klawr4_9
    public class TestNewKlawr : UKlawrScriptComponent
        public TestNewKlawr(long instanceID, UObjectHandle nativeComponent)
            : base(instanceID, nativeComponent)

        private float delta = 0.01f;

        private int counter = 0;

        public override void TickComponent(float deltaTime)
            var vect = TestActor.GetActorScale3D();
            vect.X += delta;
            vect.Z -= delta;
            vect.Y += delta;
            if (((delta>0.0f) && (vect.X > 1.5f))||((delta<0.0f) && (vect.X<0.5f)))
                delta = -delta;

		public string StringTester {get;set;}

This should give you some idea how to approach it. If you have more questions/suggestions, plz let me know :slight_smile:

Thank you for answer.

Opps i used enlight’s version , maybe thats why mine codes not working.
Soo this plugins copies and converts ue4’s functions to c# ?

Edit: Your version crashing when creating .cs file. Let me try to restart from scrach. (master branch)

Hmm, master branch should work. Are you on 4.9?

Yes 4.9 master branch

4.8 not worked too. (both master branchs)

I think last time i commited i was on 4.9.3

when its trying to save and compile new .cs ue4 crashing (4.9 and 4.8)

Shall i try to send you logs and dumb ?

Just to be sure, you did copy over the klawr dll’s to your project folder? (thats not happening automatically)
And can you give me the commit id’s of ue4 and klawr you use please?

I didnt copied but theres klawr folder at myproject/binaries/win64

Ue4 4.8

Tried 4.10 Release already?
Latest commit on my EditorNode branch should work fine, a bit much debug output yet though.

yes i saw that i am trying to build now but i getting error.

and building klawr on VS2015 giving errors soo i commended out some lines

edit: clrhost.cpp ln144 col5

Hi ihavenick

i know this problem.
You need to change the CS project (Klawr.ClrHost.Managed) to x64. Yours probably is set to mixed now.
These static asserts have to be met, else COM will not work.