Client callback after syncvars have been set

I have some server-side code that instantiates a prefab, sets some properties on it, and then spawns it on the network. On the client, I would like to run some logic to initialize some client-only components of this object. I would have expected that I could do this from OnStartClient(), but that appears to get called before the object’s SyncVars have been replicated. Here is a simplified example of what I’m trying to do:

class MyComponent : NetworkBehaviour
{
  [SyncVar]
  public GameObject MyObj;

  [SyncVar]
  public int MyInt;
}

...

// Some code running on the server...
GameObject somePrefabReference;

GameObject foo = Instantiate(somePrefabReference);
foo.GetComponent<MyComponent>().MyObj = this;
foo.GetComponent<MyComponent>().MyInt = 42;
NetworkServer.Spawn(foo);

...

// Some component on the object spawned above...
public override void OnStartClient()
{
  var myObj = GetComponent<MyComponent>().MyObj;
  var myInt = GetComponent<MyComponent>().MyInt;
  DoSomeComplicatedLogic(myObj, myInt);
}

Unfortunately, it appears that at the time OnStartClient() is called, the properties of MyComponent have not been replicated yet, so myObj is null. It seems reasonable that OnStartClient might be expected to run before the object has finished spawning/syncing, but if that were the case, I’d expect there to be another callback I can use to run some logic after all of the variables have been replicated. Where is the proper place for me to call DoSomeComplicatedLogic() such that I can be sure all of the variables have already been replicated.

I can’t put this logic inside a sync var hook for any of the properties in MyComponent, because the logic needs to wait to run until all of the SyncVars have been replicated and I don’t know which order they’ll be synced in. Also, it’s initialization logic and I don’t necessarily want it to run if the value of that SyncVar changes later on.

Thanks for any help!

Actually, it looks like I was wrong. SyncVars do get replicated before OnStartClient is called, but every component is initialized in the order that it appears on the object. So, for example if I have an object…

Foo
- FirstComponent
- SecondComponent

var foo = Instantiate(FooPrefab);
foo.GetComponent<FirstComponent>().SomeInt = 42;
foo.GetComponent<SecondComponent>().SomeString = "Hello world";

class FirstComponent
{
  public override void OnStartClient()
  {
    // This prints an empty string because foo SecondComponent hasn't been replicated yet
    Debug.Log(GetComponent<SecondComponent>().SomeString);
  }
}

class SecondComponent
{
  public override void OnStartClient()
  {
    // This correctly prints 42 because FirstComponent has already been replicated
    Debug.Log(GetComponent<FirstComponent>().SomeInt);
  }
}

This makes sense now that I understand what’s going on. I just kind of wish this had been documented somewhere.