InputToEvent
How do I use Input To Event
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: ClickAndDrag.cs
Copy
11 void Update ()
12 {
13 if (!photonView.isMine)
14 {
15 return;
16 }
17
18 InputToEvent input = Camera.main.GetComponent
19 if (input == null) return;
20 if (!following)
21 {
22 if (input.Dragging)
23 {
24 camOnPress = this.transform.position;
25 following = true;
26 }
27 else
28 {
29 return;
30 }
31 }
32 else
33 {
34 if (input.Dragging)
35 {
36 Vector3 target = camOnPress - (new Vector3(input.DragVector.x, 0, input.DragVector.y) * factor);
37 this.transform.position = Vector3.Lerp(this.transform.position, target, Time.deltaTime*.5f);
38 }
39 else
40 {
41 camOnPress = Vector3.zero;
42 following = false;
43 }
44 }
45 }
File name: InstantiateCube.cs
Copy
12 void OnClick()
13 {
14 if (PhotonNetwork.connectionStateDetailed != PeerState.Joined)
15 {
16 // only use PhotonNetwork.Instantiate while in a room.
17 return;
18 }
19
20 switch (InstantiateType)
21 {
22 case 0:
23 PhotonNetwork.Instantiate(Prefab.name, this.transform.position + 3*Vector3.up, Quaternion.identity, 0);
24 break;
25 case 1:
26 PhotonNetwork.InstantiateSceneObject(Prefab.name, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity, 0, null);
27 break;
28 }
29 }
File name: ManualPhotonViewAllocator.cs
Copy
23 public void InstantiateRpc(int viewID)
24 {
25 GameObject go = GameObject.Instantiate(Prefab, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity) as GameObject;
26 go.GetPhotonView().viewID = viewID;
27
28 OnClickDestroy ocd = go.GetComponent
29 ocd.DestroyByRpc = true;
30 }
File name: OnClickInstantiate.cs
Copy
12 void OnClick()
13 {
14 if (PhotonNetwork.connectionStateDetailed != PeerState.Joined)
15 {
16 // only use PhotonNetwork.Instantiate while in a room.
17 return;
18 }
19
20 switch (InstantiateType)
21 {
22 case 0:
23 PhotonNetwork.Instantiate(Prefab.name, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity, 0);
24 break;
25 case 1:
26 PhotonNetwork.InstantiateSceneObject(Prefab.name, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity, 0, null);
27 break;
28 }
29 }
File name: PointedAtGameObjectInfo.cs
Copy
7 void OnGUI()
8 {
9 if (InputToEvent.goPointedAt != null)
10 {
11 PhotonView pv = InputToEvent.goPointedAt.GetPhotonView();
12 if (pv != null)
13 {
14 GUI.Label(new Rect(Input.mousePosition.x + 5, Screen.height - Input.mousePosition.y - 15, 300, 30), string.Format("ViewID {0} InstID {1} Lvl {2} {3}", pv.viewID, pv.instantiationId, pv.prefix, (pv.isSceneView) ? "scene" : (pv.isMine) ? "mine" : "owner: " + pv.ownerId));
15 }
16 }
17 }
Download file with original file name:InputToEvent
InputToEvent 139 lượt xem
Gõ tìm kiếm nhanh...