Custom Initiation Data
I'm trying to send and receive a string and and int of some Custom Initiation Data, but I can't seem to either send or receive either one. I have been trying for hours now but no luck, please help:
Send Script:
public string snakeName; public float minZ; void Start() { snakeName = PlayerPrefs.GetString("urName"); object[] myCustomInitData = new object[] { minZ, snakeName }; PhotonNetwork.Instantiate(playerPrefab.name, randomPoiition, Quaternion.identity, 0, myCustomInitData); }
Receive Script:
private PhotonView view; public int id; public string snakeName; public void OnPhotonInstantiate(PhotonMessageInfo info) { object[] instantiationData = info.photonView.InstantiationData; id = (int)instantiationData[0]; snakeName = (string)instantiationData[1]; this.gameObject.name = snakeName; }
0
Answers
-
Please use the formatting options that show up on the left side of the input area, while you type or select text. Hidden behind a click on the paragraph icon.
I think the photonView.InstantiationData will be cleared (to avoid a memory leak) and you should access it asap.
Implement OnPhotonInstantiate(PhotonMessageInfo info)
(also defined by interfaceIPunInstantiateMagicCallback
) and access it there.0