In GDScript, I defined a signal a in A that has no parameters (which is important!). In B, I connect signal a to my event b (i: int), and I can easily bind the built-in properties in B, such as (A.a. connect (b. bind (count)))
But in C #, I don't know how to bind properties like this. Because I cannot set the parameter in signal a, once set, I must carry this parameter when sending the signal. However, I want my parameter to be obtained from B instead of being carried by A when sending the signal. What should I do?
The difference in bind() between GDScript and C#
Asked Answered
I am connecting under foreach, for example:
foreach(int i in arr){
A aIn = AScene.Instantiate() as A;
aIn.a += b;
}
b(int i){}
I don't know how to bind different i to method b
I have fallen into a misunderstanding. The solution to this problem is actually very simple, which is to use nested methods like the following:
A.a += () => {b(i);};
I hope this answer can also help you who are also troubled!
© 2022 - 2024 — McMap. All rights reserved.