Custom Instantiation Data : Send GameObject or Components ?
Options
Jimanji
✭
Hello,
its not possible to send GameObject or Components with this technique ? :
its not possible to send GameObject or Components with this technique ? :
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; // ... }Thank you
0
Comments
-
Right. GameObject and Components are not serializable.
What you can do is create a script for the prefab to enable/disable components or subobjects on demand. Then send a bool[] which ones need to be active.1 -
Ok thank you, that help me.0
-
@DbzRock
int number = 12; string word = "hello"; object[] myCustomInitData = new object[] { number, hello }; PhotonNetwork.Instantiate(Path.Combine("Players", "Player" , transform.position, Quaternion.identity, 0, myCustomInitData); public class RandomCall : MonoBehaviourPun, IPunInstantiateMagicCallback { public void OnPhotonInstantiate(PhotonMessageInfo info) { object[] instantiationData = info.photonView.InstantiationData; int number = (int)instantiationData[0]; string word = (string)instantiationData[1]; } }
1