ObjectToInstantiate









How do I use Object To Instantiate
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: OnJoinInstantiate.cs Copy
13     public void OnJoinedRoom()
14     {
15         Vector3 pos = Vector3.zero;
16         pos.x += PhotonNetwork.player.ID;
17
18         if (!InstantiateSceneObjects)
19         {
20
21              newObj = PhotonNetwork.Instantiate(ObjectToInstantiate.name, pos, Quaternion.identity, 0, null);
22
23
24             // anything you do with newObj locally is not reflected on the other clients.
25             // you can add a script to the Prefab to do some instantiation in Awake() and you can call RPCs on newObj now.
26         }
27         else
28         {
29             newObj = PhotonNetwork.InstantiateSceneObject(ObjectToInstantiate.name, pos, Quaternion.identity, 0, null);
30             //PhotonView pv = newObj.GetComponent() as PhotonView;
31             //Debug.Log(pv.ownerId + " " + pv.viewID);
32         }
33     }

ObjectToInstantiate 131 lượt xem

Gõ tìm kiếm nhanh...