コード例 #1
0
    public IEnumerator TakeScreenshot()
    {
        string imageName = Application.dataPath + screenshotCount + ".png";

        //Hide canvas
        ui.Hide(hideGameObject);

        //Wait until rendering is done
        yield return(new WaitForEndOfFrame());

        // Take the screenshot
        screenshotTexture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
        screenshotTexture.ReadPixels(new UnityEngine.Rect(0, 0, Screen.width, Screen.height), 0, 0, false);
        screenshotTexture.Apply();

        //Show canvas
        ui.Show(hideGameObject);

        // Create a sprite
        Sprite screenshotSprite = Sprite.Create(screenshotTexture, new UnityEngine.Rect(0, 0, Screen.width, Screen.height), new Vector2(0.5f, 0.5f));

        // Set the sprite to the screenshotPreview
        screenshotPreview.GetComponent <Image>().sprite = screenshotSprite;

        //Show the image
        ui.Show(screenshotPreview);
    }
コード例 #2
0
    public IEnumerator ReadQRCode()
    {
        while (true)
        {
            if (cameraInitialized)
            {
                image = CameraDevice.Instance.GetCameraImage(mPixelFormat);

                if (image == null)
                {
                    Debug.Log("No camera image found");
                }
                else
                {
                    result = barCodeReader.Decode(image.Pixels, image.BufferWidth, image.BufferHeight, RGBLuminanceSource.BitmapFormat.RGB24);

                    image = null;

                    if (result != null)
                    {
                        // QRCode detected.
                        QRVisible = true;

                        Debug.Log(i + " QR code: " + result.Text);
                        //Do something with the QR code.

                        GameObject instantiatedSucces = Instantiate(succes, GameObject.Find("Canvas Start").transform);

                        Manager.Instance.controllerUrl = result.Text;
                        Debug.Log("Manager's controllerUrl set: " + Manager.Instance.controllerUrl);

                        int    firstIndex  = 0;
                        int    secondIndex = result.Text.IndexOf("can");
                        int    thirdIndex  = result.Text.IndexOf("=") + 1;
                        string canvasUrl   = result.Text.Substring(firstIndex, secondIndex) + result.Text.Substring(thirdIndex);

                        Manager.Instance.canvasUrl = canvasUrl + "?raw";
                        Debug.Log("Manager's variable set: " + Manager.Instance.canvasUrl);
                        result = null;  // clear data
                        yield return(new WaitForSeconds(1));

                        Destroy(instantiatedSucces);

                        uiMethods.Show(GameObject.Find("Canvas full"));
                        uiMethods.Hide(GameObject.Find("Canvas Start"));

                        yield break;
                    }
                }
            }

            yield return(new WaitForSeconds(0.5f));
        }
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        featureMatcher = new FeatureMatcher();
        imageList      = new ImageList();


        ui = GameObject.Find("UIScripts").GetComponent <UIMethods>();
        ui.Hide(GameObject.Find("Panel"));
        InAppBrowserBridge bridge = GameObject.Find("InAppBrowserBridge").GetComponent <InAppBrowserBridge>();

        bridge.onJSCallback.AddListener(OnMessageFromJS);
    }
コード例 #4
0
    void Start()
    {
        Debug.Log("Start bliver kaldt igen");
        barCodeReader = new BarcodeReader();

        uiMethods = FindObjectOfType <UIMethods>();
        uiMethods.Hide(GameObject.Find("Canvas full"));
        uiMethods.Show(GameObject.Find("Canvas Start"));


        StartCoroutine(InitializeCamera());
    }
コード例 #5
0
 public void OnCloseButtonPressed()
 {
     uiMethods.Hide(GameObject.Find("ImageObject"));
 }