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
반응형
'게임엔진(GameEngine) > Unity3D' 카테고리의 다른 글
LayerMask.GetMask (0) | 2022.03.09 |
---|---|
OnPhotonInstantiate, STart OnPhotonSerializeView 순서 (0) | 2022.02.11 |
C# eventHandler 중복, Action 중복 방지 하기 (0) | 2022.02.05 |
SendMessage(.. SendMessageOptions.RequireReceiver) 수신자를 찾을수 없을때 경고) (0) | 2022.02.01 |
PlayerPrefs를 활용한 데이터 로드/저장 (0) | 2022.01.31 |