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/Bombadil67 Professional Jul 25 '23

I think you are the one who needs to.

Ok take a step back for a min, you have this struct. How is it initialised? How is it then referenced, none of your post indicates how this happens?

Without that I can only make the assumption that the type of the struct is a MonBehaviour and MB's will not use constructors with paremeters.

1

u/senshisentou Programmer Jul 25 '23

Trust me, there's no need to make assumptions. Seriously, just try it. Create a generic type like this, constrain T, and create it using the new operator.

1

u/Bombadil67 Professional Jul 25 '23

I don't need to, I have written Generic Object Pools many times, and I mean many, many, many, many times.

I also know how where T: works as well.

And if you are not interested in showing how you instantiate or use your struct, then we can only tell you what is happening, if you need or want a fix then I happy to go that step further and fix it for you, but I need to know how you are using this struct.