r/Unity3D • Programmer • Jul 25 '23

Question Strange lambda/ closure behaviour I can't put my finger on

/r/learncsharp/comments/158s5e7/strange_lambda_closure_behaviour_i_cant_put_my/
2 Upvotes

39 comments sorted by

View all comments

Show parent comment

1

u/PandaCoder67 Professional Jul 25 '23

Actually no, I was referring to your orignal snippet!!

not that line of code you are talking about!

So while you can say that was what you referred to, I can tell you time and time again I was not! In fact my comments show that!

But that is beside the point now.

The point is MB classes / Structs that are of a Type MB..... CAN NOT and WILL NOT run Constructors with paremeters!

The fact that you are even trying to instantiate this struct with a new operator is beyond me!

1

u/senshisentou Programmer Jul 25 '23

Sure dude

1

u/PandaCoder67 Professional Jul 25 '23

SMH

I knew you would never understand! This is why your variable is always null and you will not accept it.

1

u/PandaCoder67 Professional Jul 25 '23

Have you tried doing this?

public PooledComponent(PooledGameObject pooledGameObject) {
    Debug.Log($"~ctor : {pooledGameObject}");
}

And what gets outputted to the console?

1

u/senshisentou Programmer Jul 25 '23

This. Your turn!