SpawnCube.csPUN2の記事: 目次
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
using Photon.Pun; using UnityEngine; /// <summary> /// /// Unity 2019.1.11f1 /// /// Pun: 2.4 /// /// Photon lib: 4.1.2.4 /// /// Prefab: Assets/Resources/Prefabs/Cube.prefab /// /// </summary> public class SpawnCube : MonoBehaviourPunCallbacks { // 部屋に入室した時 public override void OnJoinedRoom() { // ランダムな位置にキューブを生成 int x = Random.Range(-5, 6); int y = Random.Range(-4, 3); if (PhotonNetwork.InRoom) { PhotonNetwork.Instantiate("Prefabs/Cube", new Vector3(x, y, 0), Quaternion.identity); } } } |