示例#1
0
 public void EditClick()
 {
     UpdateProfileBtn.SetActive(true);
     EditBtn.SetActive(false);
     firstNameInput.enabled     = true;
     lastNameInput.enabled      = true;
     usertNameInput.enabled     = true;
     childClassInput.enabled    = true;
     childClassdropdown.enabled = true;
     StudyARBtn.SetActive(false);
     ARDrawingBtn.SetActive(false);
     DownloadingBtn.SetActive(false);
     UserRawImage.GetComponentInParent <Button> ().enabled = true;
 }
示例#2
0
    public static Vector2 SizeToParent(RawImage image, float padding = 0)
    {
        float w = 0, h = 0;
        var   parent         = image.GetComponentInParent <RectTransform>();
        var   imageTransform = image.GetComponent <RectTransform>();

        // check if there is something to do
        if (image.texture != null)
        {
            if (!parent)
            {
                return(imageTransform.sizeDelta);
            }                                                 //if we don't have a parent, just return our current width;
            padding = 1 - padding;
            float ratio  = image.texture.width / (float)image.texture.height;
            var   bounds = new Rect(0, 0, parent.rect.width, parent.rect.height);
            if (Mathf.RoundToInt(imageTransform.eulerAngles.z) % 180 == 90)
            {
                //Invert the bounds if the image is rotated
                bounds.size = new Vector2(bounds.height, bounds.width);
            }
            //Size by height first
            h = bounds.height * padding;
            w = h * ratio;
            if (w > bounds.width * padding)   //If it doesn't fit, fallback to width;
            {
                w = bounds.width * padding;
                h = w / ratio;
            }
        }
        imageTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, w);
        imageTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, h);
        return(imageTransform.sizeDelta);
    }
示例#3
0
    private void Start()
    {
        var canvas = image.GetComponentInParent <Canvas>();

        canvas.renderMode  = RenderMode.ScreenSpaceCamera;
        canvas.worldCamera = Camera.main;

        scaler             = image.GetComponentInParent <CanvasScaler>();
        scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;

        receiver = new Receiver();
        receiver.Start();

        sender = new Sender();
        sender.Start();
    }
示例#4
0
    // Use this for initialization
    protected override void Start()
    {
        if (TargetTexture)
        {
            TargetTexture.texture = Crosshair;

            _parentCanvas = TargetTexture.GetComponentInParent <Canvas> ();
        }
    }
示例#5
0
    IEnumerator LoadImageUnityWebRequestv2Coroutine(ImageAttributes imageAttributes, RawImage rawImage)
    {
        UnityWebRequest request = UnityWebRequestTexture.GetTexture(@imageAttributes.path);

        yield return(request.SendWebRequest());

        if (request.isNetworkError || request.isHttpError)
        {
            ErrorLogger.LogErrorInFile(request.error);
        }
        else
        {
            rawImage.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;

            var imageContainerSizeDelta = rawImage.GetComponentInParent <RectTransform>().sizeDelta;
            imageContainerSizeDelta.x = rawImage.mainTexture.width / imageContainerSizeDelta.x;
            imageContainerSizeDelta.y = rawImage.mainTexture.height / imageContainerSizeDelta.y;

            var largerRatio = imageContainerSizeDelta.x;
            if (imageContainerSizeDelta.x < imageContainerSizeDelta.y)
            {
                largerRatio = imageContainerSizeDelta.y;
            }

            rawImage.rectTransform.sizeDelta = new Vector2(
                rawImage.mainTexture.width * imageAttributes.scale.x / largerRatio,
                rawImage.mainTexture.height * imageAttributes.scale.y / largerRatio
                );

            rawImage.rectTransform.localPosition = imageAttributes.position;

            if (imageAttributes.rotation != new Vector3(0, 0, 0))
            {
                rawImage.rectTransform.Rotate(imageAttributes.rotation);
            }

            if (imageAttributes.color != new Color(1, 1, 1, 1))
            {
                rawImage.color = imageAttributes.color;
            }


            rawImage.gameObject.SetActive(true);
        }
    }
示例#6
0
    public void SetCameraProperties()
    {
        displayImage = GameObject.FindGameObjectWithTag("DISPLAY_IMAGE").GetComponent <RawImage>();
        imageParent  = displayImage.GetComponentInParent <RectTransform>();
        imageFitter  = displayImage.GetComponent <AspectRatioFitter>();

        // Get the device's cameras and create WebCamTextures with them
        frontCameraDevice = WebCamTexture.devices.Last();
        backCameraDevice  = WebCamTexture.devices.First();

        frontCameraTexture = new WebCamTexture(frontCameraDevice.name, 1024, 768);
        backCameraTexture  = new WebCamTexture(backCameraDevice.name, 1024, 768);

        // Set camera filter modes for a smoother looking image
        frontCameraTexture.filterMode = FilterMode.Trilinear;
        backCameraTexture.filterMode  = FilterMode.Trilinear;

        // subscribe to camera events
        //EventCamManager.current.onNatCamConnect += SetCamera(Cameras.Back);
    }
        private IEnumerator Start()
        {
            parent         = resultImage.GetComponentInParent <RectTransform>();
            imageTransform = resultImage.GetComponent <RectTransform> ();

            yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam));

            if (Application.HasUserAuthorization(UserAuthorization.WebCam))
            {
                if (!InitializeCameras())
                {
                    Debug.LogError("The app can't continue");
                }
                canContinue = true;
                OnDeviceReady?.Invoke();
            }
            else
            {
                Debug.Log("webcam not found");
            }
        }