void Start()
    {
        //start the service, this will not be done instantly because of the wireless connection.
        WirelessInputController.StartWebcamService((WirelessWebcamDevice[] fetchedDevices) => {
            //code here will be executed when we have received out webcam devices, so, let's assign one
            WirelessInputController.currentWebcamDevice = fetchedDevices[(int)currentCamera];
            //note, assigning is enough. It'll automatically fire up the webcam and data will be send to you

            //and create the texture of course
            tex = new Texture2D(1, 1);
        });
    }
Exemple #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;
        }
    }