Delegate recreated every frame if created inside update

This is specially annoying if delegate is a pin.

We have two options to avoid that, assign delegate creation on “Create” or create delegate inside of cache, might anyone else have suggestions here.

Delegate Creation.vl (8.7 KB)

1 Like

It’s an interesting observation. But is it a problem? Apparently nothing inside the delegate is called until Invoke is used.

We found some workaround that is kinda works nice:
Consider this C# code:

public delegate YGSize DDDD(object? context, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode);

Now a little wrapper:

Produces:

Our observations revealed few points:

  1. Delegate has named inputs
  2. Content of delegate is changeable without recreation, however if you add remove nodes you need to trigger recreate.

So far I guess will stay on this method.

Unrelated but, are you able to rename a delegate? I’m not able to.

Here, I’m in an application patch and trying to do this:

Plane delegates like that are Func’s or Action’s so anonymous so there is no name, you can assign an Input in the patch, or pad to be a delegate signature, then it will take it name from name of that input

1 Like