I have a script A that adds another script B:
function Start () {
gameObject.AddComponent.<B>();
}
And then makes a general check for activity:
function Update () {
if (!IsActive()) {
// Code that says we are done...
}
}
The problem appears to be that having added B, the Update method of A is called before B has started. As a result, A immediately decides that there is no activity when, in fact, A still needs to wait for B to start and complete.
What is the best way to handle this kind of inter script coordination? Should I add B in a function invoked from A’s Start and call yield?