[Plugin] klawr C# script plugin dev thread

Ok i set it from tool bar but not worked . Setting x64 from properties fixed it. Thanks. But i still have problem with compiling 4.10.

The other thing seems to me like a broken file. I’d try to get it fresh from github (the CorePrivatePCH.h).
Or try a complete rebuild, maybe something went wrong while writing the file.

I tryed to compile this 6+ hours. and now i compiled. Now i tried to create klawr .cs file and editor crashed again.
i copied dll files to myproject/binaries/win64

Find the problem

Edit: added .net to path now problem is

Edit no: 42233

and

Hi ihavenick,

I didnt have this problem yet.

As for the 2nd and last error message, i’d try to change to x64 in your MyProject4Scripts.csproj. Should eliminate the mismatch error/warning message.

What is Edit 42233? What did try to do?

Ok, thanks. Its working now. Finally.
Changing csproj from properties fixed and now its working.

There are few bugs remaining , like building blueprint with" klawr c# call" inside it, crashing engine.
and right clicking to klawr c#call not showing function like yours.

And cant get this code working


 public override void TickComponent(float deltaTime)
        {
            long instanceID = 0;
            UObjectHandle nativeComponent = new UObjectHandle();
            TestActor ta = new TestActor(instanceID, nativeComponent);
            counter++;
            var vect = ta.GetActorScale3D();
            vect.X += delta;
           vect.Z -= delta;
            vect.Y += delta;
            ta.SetActorScale3D(vect);
            if (((delta > 0.0f) && (vect.X > 1.5f)) || ((delta < 0.0f) && (vect.X < 0.5f)))
           {
              delta = -delta;
          }
        }

Hi ihavenick,

The example above was not quite right, my bad.

Here’s an updated one:



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

**        // This will bring a Actor property into the blueprint
        // You will have to set it before you want to access it in the TickComponent method, best practice would be to add a null check in TickComponent
        [UPROPERTY]
        public AActor TestActor {get;set;}

        // As for functions, decorate them with the UFUNCTION attribute. Then they (and their parameters will be accessible in the Klawr c# call node
        [UFUNCTION]
        pubilc string TestMyStringFunction(string part1, string part2, int counter)
        {
              return part1 + " " + counter + " " + part2;
        }**
        

        private float delta = 0.01f;

        private int counter = 0;

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

		[UPROPERTY()]
		public string StringTester {get;set;}
    }

Plan is to make the UFUNCTION and UPROPERTY attributes like the ones in UE4, so meta tags can be passed along too. But thats in the future.

Maybe i can make another video where i show more of what i’ve done yet. I just dont find the time :slight_smile:
**
PS: UObjects can not be passed as method parameters yet, as well as arrays. UObjects just wont be sent to c# script, arrays might crash.**
PPS: return values might not be sent back correctly :slight_smile: working on it
PPS2: fixed in editorNode branch

Updated Klawr, changes are on the develop branch:

  • Changed transfer of class/property/method information to JSON (now much easier to expand)
  • Meta tags can be supplied in the UPROPERTYAttribute decorations
  • Removed obsolete functions from the CLR interface
  • Fix for a bug preventing a c++ project to be created

I tested it now , (compiling take 2 hour)

Its working great !!
But mine old projects crashing now .(no crash log)

There is a another bug, if you look directly to klawr component attached actor, fps dropping.

You talking about the Actor you use in the TickComponent method (from my example)?
Yes. It is constantly changing its size, not something you want to do in every tick.

2 hrs… did you rebuild the whole engine?

i have two batch files http://pastebin.com/wfZkAiWW
if you change the paths you can use them too.

it reduces my build time to ~2mins

Usage:
first start clearKlawr.bat
it deletes the generated files then pauses.
while it pauses, do a full rebuild (Shift-F6) of the Klawr project
After that is done, resume the clearKlawr.bat

Then do a build of UE4 (no rebuild, just hit F6)
it regenerates the needed dll’s

After this step, call the copyKlawr.bat which will copy the newly created dll’s into your favorite project folder

I hope this helps

Update:

  • UObjects can now be passed as parameters and as function return values
  • Fixed some issues in the function call node

Yep it build some things from start ( Visual studio says 500 jobs)
ok thank you , i will start it testing now.

(P.s. = is it safe to use ue4 with klawr to use in your projects ?. I have 2 seperete 4.10 versions , 1 .vanilla , 2. with klawr . I scared to use 4.10 with klawr in mine project ,because sometimes it crashes projects)

Strange thing happend.
I updated klawr and tested your spring function and its returned
[TestActor_C_0] and nothing on screen. (result pin connected to printscreen)

Answering your question about usage in production: It should still be considered as experimental work, so i wouldn’t use it in production.

This is fantastic. Well done.

Nice… still waiting patiently for some talented Maverick to implement Python.

Isn’t python GPL?

Thanks.
But there is still a lot to do (and even more to learn for me to do it properly)

This looks really good. As a newcomer, should i be using your branch, or the main Enlight project?

Also, I’m a c# dev. Is there any way I can help out? I know a decent amount of C++ too.

My fork would be more advanced, since enlight has other projects going on now. Using the Develop branch is recommended.