Turning a GameObject instantiated with Unity’s Instantiate function into a networked object

Options

Hi! I’m having an issue with networking a GameObject that is instantiated during runtime using Unity’s own Instantiate function. Is it possible to network an object after it has been spawned with that function into the scene? Sadly I’m not able to switch over to PhotonNetwork.Instantiate for the objects i want to network since they are made in a script I don’t have write access to.

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @KrisMale,

    Thank you for choosing Photon!

    You can do something inspired by Manual Instantiation.
  • KrisMale
    Options
    @JohnTube, thanks for the reply.

    I'm looking at the example you sent, but it appears that it relies on prefabs. Our objects aren't spawned into the scene as prefabs, but generated during runtime. Is it possible to get around this and not rely on prefabs?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options

    Yes it's possible to not use prefabs and just use or add PhotonView.
    You can also look into custom IPrefabPool.