using ExitGames.Client.Photon; using UnityEngine; using System.Collections; public class SetupAndConnect : MonoBehaviour, IPhotonPeerListener { private PhotonPeer peer; void Start () { peer = new PhotonPeer(this, ConnectionProtocol.Udp); #if UNITY_EDITOR || (!UNITY_IPHONE && !UNITY_ANDROID && !UNITY_PS3) Debug.Log("Using C# Socket"); peer.SocketImplementation = typeof(SocketUdp); #elif !UNITY_EDITOR && UNITY_PS3 Debug.Log("Using class SocketUdpNativeDllImport"); peer.SocketImplementation = typeof(SocketUdpNativeDllImport); #elif !UNITY_EDITOR && UNITY_ANDROID Debug.Log("Using class SocketUdpNativeDynamic"); peer.SocketImplementation = typeof(SocketUdpNativeDynamic); #elif !UNITY_EDITOR && UNITY_IPHONE Debug.Log("Using class SocketUdpNativeStatic"); peer.SocketImplementation = typeof(SocketUdpNativeStatic); #endif peer.Connect("127.0.0.1:5055", "yourapp"); } void OnApplicationQuit() { if (peer != null) peer.Disconnect(); } void Update () { this.peer.Service(); } public void DebugReturn(DebugLevel level, string message) { Debug.Log(message); } public void OnOperationResponse(OperationResponse operationResponse) { Debug.Log("Op Response: " + operationResponse.OperationCode); } public void OnStatusChanged(StatusCode statusCode) { Debug.Log(statusCode); } public void OnEvent(EventData eventData) { Debug.Log("Ev: " + eventData.Code); } }