Last active
August 29, 2015 14:10
-
-
Save soyliquid/59ce4459481dab56f224 to your computer and use it in GitHub Desktop.
[Unity][Photon]自動でロビーにJoin→固定のルームにJoinする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class NetworkManager : Photon.MonoBehaviour { | |
public static NetworkManager Instance { | |
get { return _instance; } | |
} | |
private static NetworkManager _instance; | |
public GameObject Player; | |
void Awake(){ | |
_instance = this; | |
DontDestroyOnLoad(this); | |
} | |
// Use this for initialization | |
void Start () { | |
JoinLobby(); | |
} | |
void JoinLobby() { | |
Debug.Log( | |
"PhotonNetwork.sendRate=" + PhotonNetwork.sendRate + @"\r\n" + | |
"PhotonNetwork.sendRateOnSerialize=" + PhotonNetwork.sendRateOnSerialize | |
); | |
// 通信頻度を上げる | |
PhotonNetwork.sendRate = 30; | |
PhotonNetwork.sendRateOnSerialize = 30; | |
PhotonNetwork.ConnectUsingSettings("0.1"); | |
} | |
void OnJoinedLobby() { | |
Debug.Log("OnJoinedLobby"); | |
PhotonNetwork.JoinOrCreateRoom("DEFAULT", new RoomOptions(), TypedLobby.Default); | |
} | |
void OnJoinedRoom() { | |
Debug.Log("OnJoinedRoom"); | |
PhotonNetwork.Instantiate(Player.name, Vector3.zero, Quaternion.identity, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment