How to get the number of photonviews

Options
Is there a way to find the number of existing photonviews currently in game at any given time? In my game, players are able to craft many objects with photonviews on them and I would like to limit the number of objects to be the max number of photonviews.

Answers

  • Hi @Robyn,

    in the current version (1.86) you can use PhotonNetwork.networkingPeer.photonViewList to get a list of all registered PhotonView components. This is currently 'internal' but will be made 'private' in the future, means that you won't have access any longer after a certain update - unless you change the code yourself.

    Instead you can also use one of Unity's functions to get all objects of a specific type: FindObjectsOfType<PhotonView>().Length. This gives you the amount of all PhotonView components, that are currently in the scene.