If Wings Engine needs to obtain instances of other classes, it needs to use getExtensionInstances or getExtensionInstance. For specific API documents, please refer to:
The following is a specific example to look at the communication method between two secondary development classes:
We have two buttons, one of which is a NumberText secondary development and the other is a Random secondary development. We need to get an instance of the Random class in the NumberText class. The code is as follows:
1 | class NumberText { |
1 | export class Random { |
NumberText is mounted on the text component, and Random is mounted on the random button. Then set the element setting item generated by the second opening of the text side to the random button:
After setting it up, you can see that the NumberText class on the text side has obtained the instance of the Random class mounted on the random button:
Of course, sometimes, it is possible that the same secondary development class is mounted on many elements, and you need to get instances of these classes at the same time. In this case, you can use the getChildren and getParent methods to get these instances.