コード例 #1
0
    private void Awake()
    {
        if (Instance != null)
        {
            Destroy(this);
        }
        else
        {
            Instance = this;
            DontDestroyOnLoad(this);

            Initiate();
        }
    }
コード例 #2
0
    //create the network channel and have get a reference to the custom event stream
    void Start()
    {
        CES = CustomEventStream.Instance;
        CES.CreateChannel(DefaultNetworkOutChannel);
        CES.CreateChannel(DefaultNetworkInChannel);
        CES.Subscribe(NetEventHandler, DefaultNetworkInChannel);

        Debug.Log("trying hosting");
        NetworkConnectionError nce = Host();

        if (nce == NetworkConnectionError.CreateSocketOrThreadFailure)
        {
            Debug.Log(nce);
            Debug.Log("host failed; assuming already exists. connecting");
            Connect(DefaultIp);
        }
        else
        {
            Debug.Log("success");
        }
    }