How do you update the transform parents on the client side when the player spawns?

I’m playing around with Unity’s networking from v5.1, and I’ve run into a problem with 2D where I need to spawn the characters under the canvas. This works on the server side, but is not working correctly on the client side. On the client side, the character transforms never have their parent set. From what I can tell, the client never actually runs the code below for some reason. I can’t seem to find which method to override for the client side of things. My current spawning code test looks like this:

public class NetworkManagerTwoD : NetworkManager
{
    public Transform CanvasParent = null;

public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        // Instantiate the player
        GameObject player = Instantiate(playerPrefab);

        // Set the parent to be the canvas.  WorldPositionStays should be false so that it retains correct size relative to the canvas.
        player.transform.SetParent(CanvasParent, false);        

        // Get the RectTransform component of the instantiated tile.
        RectTransform rectTransform = player.GetComponent<RectTransform>();

        // Set the position to be the calculated value.
        rectTransform.anchoredPosition = Vector2.zero;

        // Let the network manager do its magic.
        NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
    }
}

The players can move around just fine, but since the client doesn’t have the objects in the correct canvas (just in the hierarchy unparented) they can’t see the players walking around. Any idea what concept I am missing here?

You are missing the client code. You are telling the server to parent the object, but not the client.
Put a script on your player prefab that sets its own parent on Start()

Thank you very much for the response, Carpe Denius. I was actually thinking this could be a solution, but I thought maybe the client had some sort of OnPlayerSpawn method for itself I wasn’t finding. I will just program the objects to manage their own parents then. Thanks again!

All NetworkBehaviours get
“OnStartClient” and
“OnStartLocalPlayer” or you could register your own message and register a messagehandler with NetworkClient.RegisterHandler(myNetworkMessageIntegerValue, MyOwnMessageHandler);

But I think the parenting on start is just easier and doesn’t need networking at all.