Can I create a PhotonView component from script?

Options
Imagine you have a prefab, but it doesn't have a PhotonView.
You want to add it trough script, how do you do it?
Manual Instantiation talks about the Player prefab, wich already have one.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2020
    Options
    Hi @G44Gonzalo,

    Thank you for choosing Photon!

    You can.
    Do everything as in Manual Instantiation, replace Instantiate call with AddComponent<PhotonView>().
    Of course the receiving end of the custom manual instantiation event needs to be able to identify the GameObject to which the PhotonView should be added. So either it can guess it somehow (static or can be calculated using other params) or send a Photon serializable "reference" to it in the custom manual instantiation event payload.