Sphere









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

Featured Snippets


File name: PickupDemoGui.cs Copy
15     public void OnGUI()
16     {
17         if (!PhotonNetwork.inRoom)
18         {
19             return;
20         }
21
22
23         if (this.ShowScores)
24         {
25             GUILayout.Label("Your Score: " + PhotonNetwork.player.GetScore());
26         }
27
28
29         if (this.ShowDropButton)
30         {
31             foreach (PickupItem item in PickupItem.DisabledPickupItems)
32             {
33                 if (item.PickupIsMine && item.SecondsBeforeRespawn <= 0)
34                 {
35                     if (GUILayout.Button("Drop " + item.name))
36                     {
37                         item.Drop(); // drops the item at the place where it originates
38                     }
39
40                     GameObject playerCharGo = PhotonNetwork.player.TagObject as GameObject;
41                     if (playerCharGo != null && GUILayout.Button("Drop here " + item.name))
42                     {
43                         // drop the item at some other place. next to the user's character would be fine...
44                         Vector3 random = Random.insideUnitSphere;
45                         random.y = 0;
46                         random = random.normalized;
47                         Vector3 itempos = playerCharGo.transform.position + this.DropOffset * random;
48
49                         item.Drop(itempos);
50                     }
51                 }
52             }
53         }
54
55
56         if (this.ShowTeams)
57         {
58             foreach (var teamName in PunTeams.PlayersPerTeam.Keys)
59             {
60                 GUILayout.Label("Team: " + teamName.ToString());
61                 List teamPlayers = PunTeams.PlayersPerTeam[teamName];
62                 foreach (PhotonPlayer player in teamPlayers)
63                 {
64                     GUILayout.Label(" " + player.ToStringFull() + " Score: " + player.GetScore());
65                 }
66             }
67
68             if (GUILayout.Button("to red"))
69             {
70                 PhotonNetwork.player.SetTeam(PunTeams.Team.red);
71             }
72             if (GUILayout.Button("to blue"))
73             {
74                 PhotonNetwork.player.SetTeam(PunTeams.Team.blue);
75             }
76         }
77     }
File name: GizmoType.cs Copy
15         public static void Draw( Vector3 center, GizmoType type, Color color, float size )
16         {
17             Gizmos.color = color;
18
19             switch( type )
20             {
21             case GizmoType.Cube:
22                 Gizmos.DrawCube( center, Vector3.one * size );
23                 break;
24             case GizmoType.Sphere:
25                 Gizmos.DrawSphere( center, size * 0.5f );
26                 break;
27             case GizmoType.WireCube:
28                 Gizmos.DrawWireCube( center, Vector3.one * size );
29                 break;
30             case GizmoType.WireSphere:
31                 Gizmos.DrawWireSphere( center, size * 0.5f );
32                 break;
33             }
34         }
File name: OnJoinedInstantiate.cs Copy
10     public void OnJoinedRoom()
11     {
12         if (this.PrefabsToInstantiate != null)
13         {
14             foreach (GameObject o in this.PrefabsToInstantiate)
15             {
16                 Debug.Log("Instantiating: " + o.name);
17
18                 Vector3 spawnPos = Vector3.up;
19                 if (this.SpawnPosition != null)
20                 {
21                     spawnPos = this.SpawnPosition.position;
22                 }
23
24                 Vector3 random = Random.insideUnitSphere;
25                 random.y = 0;
26                 random = random.normalized;
27                 Vector3 itempos = spawnPos + this.PositionOffset * random;
28
29                 PhotonNetwork.Instantiate(o.name, itempos, Quaternion.identity, 0);
30             }
31         }
32     }

Sphere 110 lượt xem

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