Network.Instantiate prefab with added parts

Hello, I’m having some problems with Network.Instantiate.

A player is able to customize their items and those items have gfx that can be loaded via children components with SpriteRenderers such as this.

GameObject Player = Object.Instantiate(NetworkManager.Instance.SpawnPlayer) as GameObject;

GameObject test = new GameObject();
test.transform.parent = Player.transform;
test.transform.name = "Hat";
test.AddComponent<SpriteRenderer>();
test.GetComponent<SpriteRenderer>().sprite = Resources.Load("Hat1") as Sprite;

Now this works perfectly fine for 1-player scenarios, problem is this is meant to be a multiplayer game. If I load add the extra items in this manner, they aren’t shown on the other clients when I Network.Instantiate the prefab (obviously, since the items were added after).

I can’t Network.Instantiate this new updated Player GameObject because Network.Instantiate wants a prefab, but if I save the prefab using PrefabUtility (only works in Editor), the prefab is permanently replaced.

How would I go about having a base-player prefab (just a body), adding items to it programmatically and then instantiating that new object across the network? Thanks in advance.


Edit: Thought of a potential solutions, but wondering if there is a simpler implementation.

Once each player finishes their Network.Instantiate, get the list of items the player has and use RPCs to attach those items to that player in every client’s list of Player GameObjects.

The way I would go about it is…

Since Instantiate doesn’t actually send the item itself, it just sends the data. The object must be present on all systems to work properly.

Easiest solution would be to make various prefabs of the same object, add your effects and whatnot… then call each one specifically.