게임엔진(GameEngine)/Unity3D
PhotonNetwork.Instantiate with data
3DMP
2022. 2. 10. 06:21
Custom Instantiation Data
You can send some initial custom data when the instantiation call. Just make use of the last parameter in the PhotonNetwork.Instantiate* method.
This has two main advantages:
- save traffic by avoiding extra messages: we don't have to use a separate RPC or RaiseEvent call for synchronizing this kind of information
- timing: the data exchanged is available on the time of the prefab instantiation which could be useful to do some initialization
The instantiation data is an object array (object[]) of anything Photon can serialize.
Example:
Instantiate with custom data:
object[] myCustomInitData = GetInitData();
PhotonNetwork.Instantiate("MyPrefabName", new Vector3(0, 0, 0), Quaternion.identity, 0, myCustomInitData);
Receive custom data:
public void OnPhotonInstantiate(PhotonMessageInfo info)
{
object[] instantiationData = info.photonView.InstantiationData;
// ...
}
ref : https://doc.photonengine.com/en-us/pun/current/gameplay/instantiation
반응형