public void ShowDeviceList()
    {
        ShowFirstScrollView();
        BeginHorCentered();
        GUILayout.Label("<size=20><b>Discovered devices: " + broadcastingDevices.Count.ToString() + "</b></size>");
        EndHorCentered();

        foreach (var item in broadcastingDevices)
        {
            BeginHorCentered();
            if (GUILayout.Button(item.Key, GUILayout.Width(150)))
            {
                connectedDeviceName = item.Key;
                connectedDeviceIP   = item.Value;
                myState             = MyState.ReadyForConnection;
                ConnectionSettings.SaveSettings(connectedDeviceName, connectedDeviceIP);
                if (Application.isPlaying)
                {
                    ConnectionController.CreateConnectionOnPlay();
                }
            }
            EndHorCentered();
        }

        EndFirstScrollView();

        BeginHorCentered();

        if (broadcastingDevices.Count != 0)
        {
            if (GUILayout.Button("Refresh", GUILayout.Width(70)))
            {
                broadcastingDevices.Clear();
                DiscoverDevices();
            }
        }
        else
        {
            GUILayout.Label("<i>Searching for devices...</i>");
        }
        EndHorCentered();


        GUILayout.EndVertical();
    }
Esempio n. 2
0
    protected override void Awake()
    {
        base.Awake();

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            this.enabled = false;
        }
        else
        {
            if (Camera.main.GetComponent <ScreenCapture>() == null)
            {
                screenCapture = Camera.main.gameObject.AddComponent <ScreenCapture>();
            }
            else
            {
                screenCapture = Camera.main.GetComponent <ScreenCapture>();
            }
            StartCoroutine(ProcessDataPerFrame());
        }
        Instance = this;

        /*
         * if(Instance == null){
         *      Instance = this;
         *      DontDestroyOnLoad(gameObject);
         * }
         * else if(Instance != this){
         *      DestroyImmediate(this.gameObject);
         *      return;
         * }
         */
        settings = WirelessSettings.GetSettings();
        receivedData.Clear();
        Input.gyro.enabled = true;

        if (ConnectionController.MyConnectionState == ConnectionController.ConnectionState.NotConnected)
        {
            ConnectionController.CreateConnectionOnPlay();
            ConnectionController.onDataRead += ProcessData;
        }
    }