Exemple #1
0
        public override void OnEnter(params object[] keys)
        {
            _webCam?.Open(CamWidth, CamHeight);

            if (_viewModel != null)
            {
                _viewModel.CamTexture = _webCam?.CamTexture;

                _viewModel.RecActive = false;

                _viewModel.ScannerActive = false;
            }

            MInput.OnSimpleTap += MInput_OnSimpleTap;
        }
Exemple #2
0
    private void OnGUI()
    {
        GUILayout.BeginVertical();

        _camIndex = GUILayout.TextField(_camIndex);

        if (GUILayout.Button("Open"))
        {
            int camIndex = 0;

            if (int.TryParse(_camIndex, out camIndex))
            {
                WebCamera webCam = WebCamera.Get(camIndex);

                webCam.Open(1280, 720);

                if (imgCamera != null)
                {
                    imgCamera.texture = webCam.CamTexture;
                }
            }
        }

        if (GUILayout.Button("Pause"))
        {
            int camIndex = 0;

            if (int.TryParse(_camIndex, out camIndex))
            {
                WebCamera.Get(camIndex).Pause();
            }
        }

        if (GUILayout.Button("Close"))
        {
            int camIndex = 0;

            if (int.TryParse(_camIndex, out camIndex))
            {
                WebCamera.Get(camIndex).Close();

                if (imgCamera != null)
                {
                    imgCamera.texture = null;
                }
            }
        }

        if (GUILayout.Button("Reconnect"))
        {
            int camIndex = 0;

            if (int.TryParse(_camIndex, out camIndex))
            {
                WebCamera.Get(camIndex).ReConnect(1280, 720);
            }
        }

        if (GUILayout.Button("Snapshot"))
        {
            int camIndex = 0;

            if (int.TryParse(_camIndex, out camIndex))
            {
                WebCamera.Get(camIndex).Snapshot((Texture2D tex) =>
                {
                    if (imgSnapshot != null)
                    {
                        imgSnapshot.texture = tex;
                    }
                });
            }
        }

        GUILayout.EndVertical();
    }