예제 #1
0
 protected virtual void OnDestroy()
 {
     if (s_instance == this)
     {
         s_instance = null;
         s_inited   = false;
     }
 }
예제 #2
0
        protected override void Awake()
        {
            if (s_instance == null)
            {
                s_instance = this;

                if (_isDontDestroyOnLoad)
                {
                    DontDestroyOnLoad(this.gameObject);
                }

                s_inited = true;
            }
            else
            {
                //Debug.LogErrorFormat(gameObject, "Already created singleton object {0}", typeof(NetP2pUnity));
                Destroy(this);
                return;
            }

            _clientOption.IsServiceUdp          = true;
            _clientOption.UdpServerAddress      = ServerAddress;
            _clientOption.UdpServerPort         = UdpServerPort;
            _clientOption.PingInterval          = PingInterval;
            _clientOption.MtuInterval           = MtuInterval;
            _clientOption.RudpDisconnectTimeout = RudpDisconnectTimeout;

            base.Awake();

            _client.OnP2pReceived        += OnP2pReceive;
            _client.OnViewRequestReceived = OnViewRequestReceive;

            _views                 = new NetViews();
            _zeroDataWriter        = new NetDataWriter(false, 1);
            _readerForSendInternal = new NetDataReader();

            if (_clientOption.IsServiceUdp == false)
            {
                Debug.LogError("[NetP2pUnity] require [IsServiceUdp] option");
            }
        }