Ejemplo n.º 1
0
    void ChangeImageSize(float f)
    {
        RectTransform rectTransform = image.GetComponent <RectTransform>();
        Vector2       tempSize      = image.transform.parent.GetComponent <RectTransform>().rect.size;
        Vector2       size          = Vector2.one * tempSize.x;

        if (tempSize.y < tempSize.x)
        {
            size = Vector2.one * tempSize.y;
        }
        size -= Vector2.one * f;
        rectTransform.sizeDelta = size;
    }
Ejemplo n.º 2
0
    IEnumerator requesting()
    {
        StartCoroutine(_Refresh());
        var url = "http://maps.googleapis.com/maps/api/staticmap";
        var req = new WWW(url + "?" + qs);

        yield return(req);

        mapUI.GetComponent <RawImage> ().texture           = req.texture;
        GetComponent <MeshRenderer>().material.mainTexture = req.texture;
        Debug.Log(url + "?" + qs);
        qs = "";
    }
Ejemplo n.º 3
0
    public void OnGUI()
    {
        code = inputQR.gameObject.GetComponent <TMP_Text>().text;

        if (last_code != code)
        {
            Debug.Log(code);
            Texture2D myQR = generateQR(code);
            codeimage.GetComponent <RawImage>().texture = generateQR(code);
            SingletonManager.drillCode = code;
        }
        last_code = code;
    }
Ejemplo n.º 4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Hannah")
     {
         Speak.GetComponent <RawImage>().enabled = true;
         if (Input.GetButtonDown("Fire1") && Time.timeScale == 1)
         {
             Time.timeScale = 0;
             UI.GetComponent <Canvas>().enabled          = false;
             HannahChatC.GetComponent <Canvas>().enabled = true;
         }
     }
 }
Ejemplo n.º 5
0
    void UpdateProjectiles()
    {
        // Objects
        current = projectiles[currentInt];
        next    = projectiles[CycleScriptableList(currentInt + 1, projectiles)];
        last    = projectiles[CycleScriptableList(currentInt - 1, projectiles)];

        // Images
        tempDisplayProj.text = current.name;


        //currentImage.GetComponent<RawImage>().texture = current.
        //lastImage;
        //nextImage;



        if (current.name == "Ask")
        {
            preCurrent = preAsk;
            nextImage.GetComponent <RawImage>().texture    = Heart;
            currentImage.GetComponent <RawImage>().texture = Ask;
            lastImage.GetComponent <RawImage>().texture    = Ice;
        }
        else if (current.name == "Cold")
        {
            preCurrent = preIce;
            nextImage.GetComponent <RawImage>().texture    = Ask;
            currentImage.GetComponent <RawImage>().texture = Ice;
            lastImage.GetComponent <RawImage>().texture    = Heart;
        }
        else if (current.name == "Hug")
        {
            preCurrent = preHug;
            nextImage.GetComponent <RawImage>().texture    = Ice;
            currentImage.GetComponent <RawImage>().texture = Heart;
            lastImage.GetComponent <RawImage>().texture    = Ask;
        }
    }
Ejemplo n.º 6
0
 public override void LayOut()
 {
     Vector2 sizeCanvas = AppSceneBase.main.sizeCanvas;
     {
         RectTransform rectTransform = imageBg.GetComponent <RectTransform>();
         float         w_image       = rectTransform.rect.width;
         float         h_image       = rectTransform.rect.height;
         float         scale         = Common.GetMaxFitScale(w_image, h_image, sizeCanvas.x, sizeCanvas.y);
         imageBg.transform.localScale = new Vector3(scale, scale, 1.0f);
         //屏幕坐标 现在在屏幕中央
         imageBg.transform.position = new Vector2(Screen.width / 2, Screen.height / 2);
     }
 }
Ejemplo n.º 7
0
 public void ShadowCNormal()
 {
     ShadowColor.GetComponent <SkinnedMeshRenderer>().material = ShadowNormal;
     ShadowColor.GetComponent <SkinnedMeshRenderer>().enabled  = true;
     ShadowNormalCanvas.GetComponent <Canvas>().enabled        = true;
     ShadowButtons.GetComponent <Canvas>().enabled             = true;
     ShadowAreseneCanvas.GetComponent <Canvas>().enabled       = false;
     ShadowSophiaCanvas.GetComponent <Canvas>().enabled        = false;
     ShadowHollowCanvas.GetComponent <Canvas>().enabled        = false;
     ShadowBetaCanvas.GetComponent <Canvas>().enabled          = false;
     ShadowCheckNormal.GetComponent <RawImage>().enabled       = true;
     ShadowCheckAresne.GetComponent <RawImage>().enabled       = false;
     ShadowCheckSophia.GetComponent <RawImage>().enabled       = false;
     ShadowCheckHollow.GetComponent <RawImage>().enabled       = false;
     ShadowCheckBeta.GetComponent <RawImage>().enabled         = false;
     Robo.GetComponent <SkinnedMeshRenderer>().enabled         = false;
     RoboCanvas.GetComponent <Canvas>().enabled          = false;
     Sophia.GetComponent <SkinnedMeshRenderer>().enabled = false;
     SophiaCanvas.GetComponent <Canvas>().enabled        = false;
     Hollow.GetComponent <SkinnedMeshRenderer>().enabled = false;
     HollowCanvas.GetComponent <Canvas>().enabled        = false;
 }
Ejemplo n.º 8
0
    void Start()
    {
        if (cameraShot)
        {
            ratioFitter = cameraShot.GetComponent <AspectRatioFitter>();
        }

        hasCamera = imageSource != null && imageSource.HasCamera();

        hintMessage = hasCamera ? "Tap on the camera image to take a shot" : "No Camera Found";

        SetHintText(hintMessage);
    }
Ejemplo n.º 9
0
 void SetRightImages()
 {
     for (int i = 0; i < _rightImages.Count; i++)
     {
         RawImage      rawImage = Instantiate(rawImagePrefab, rightPanel) as RawImage;
         RectTransform rtf      = rawImage.GetComponent <RectTransform>();
         rtf.anchoredPosition = Vector2.zero;
         rtf.localScale       = new Vector3(1, 1, 1);
         rtf.SetAsFirstSibling();
         rawImage.texture = TextureResource.Instance.GetTexture(MagicWallManager.FileDir + _rightImages[i]);
         images.Add(rawImage);
     }
 }
    void Start()
    {
        if (cameraShot)
        {
            ratioFitter = cameraShot.GetComponent <AspectRatioFitter>();
        }

        hasCamera = webcamSource && webcamSource.HasCamera;

        hintMessage = hasCamera ? "Click on the camera image to make a shot" : "No camera found";

        SetHintText(hintMessage);
    }
    private void ApplyImageToGui(Texture2D image)
    {
        float aspectRatio = (float)image.width / (float)image.height;

        m_Image.GetComponent <AspectRatioFitter>().aspectRatio  = aspectRatio;
        m_Sprite.GetComponent <AspectRatioFitter>().aspectRatio = aspectRatio;

        //m_image is a UnityEngine.UI.RawImage
        m_Image.texture = image;

        //m_sprite is a UnityEngine.UI.Image
        m_Sprite.sprite = image.ToSprite();
    }
Ejemplo n.º 12
0
        /// <summary>
        /// Start is called before the first frame update
        /// </summary>
        void Start()
        {
            // Initialize Queues and AudioSource
            audioSource   = GetComponent <AudioSource>();
            dialogueNodes = new Queue <DialogueTree.DialogueNode>();

            // Initialize private fields with these settings
            currentPrintLetterDelay = printLetterDelay;
            currentSentenceDelay    = sentenceDelay;

            // Update speed of animations with current settings
            inputContinueDialogueImage.GetComponent <Animator>().speed     = inputContinueDialogueImageAnimationSpeed;
            inputContinueDialogueVRImage.GetComponent <Animator>().speed   = inputContinueDialogueImageAnimationSpeed;
            autoContinueDialogueRawImage.GetComponent <Animator>().speed   = autoContinueDialogueImageAnimationSpeed;
            autoContinueDialogueVRRawImage.GetComponent <Animator>().speed = autoContinueDialogueImageAnimationSpeed;

            // Used for testing
            if (playAtStart)
            {
                StartDialogue(dialogueTreeTest);
            }
        }
Ejemplo n.º 13
0
 //---------------------------------------------------------------------------------
 // Checks to see if the KeySlotted is true and that the LOWER button collider has been triggered to activate an animator
 //---------------------------------------------------------------------------------
 void OnTriggerEnter(Collider collision)
 {
     if (collision && KeySlotted)
     {
         Animator LiftAnimator = Lift.GetComponent <Animator>();
         LiftAnimator.enabled = true;
         RawImage Sign = LapseNotice.GetComponent <RawImage>();
         Sign.texture      = LapseResolve;
         ForkliftText.text = "Well done! \n\nThe lift has been lowered but caution should still be exercised when near heavy machinery.";
         UnresolvedTrail.SetActive(false);
         ResolvedTrail.SetActive(true);
     }
 }
Ejemplo n.º 14
0
    void Start()

    {
        //Pegando componente
        PegaImagem       = Imagem.GetComponent <RawImage>();
        CameraFotografia = gameObject.GetComponent <Camera>();
        TempVar          = PivorCamera.gameObject.GetComponent <MovimentoCamera3Pessoa>();
        InvokeRepeating("Bateria", 0, 1);
        PegaTransform           = UltimaFototirada.GetComponent <RectTransform>();
        tempControledeMensagens = Jogador.GetComponent <ControleDeMensagens>();
        ObturadorAnim           = Obj_Obturador.GetComponent <Animator>();
        AnimFundoBateria        = FundoBateria.GetComponent <Animator>();
    }
Ejemplo n.º 15
0
        void Awake()
        {
            Application.targetFrameRate = 30;

            _chessPatternPointCount = _chessPatternSize.x * _chessPatternSize.y;

            // Prepare OpenCV.
            _extrinsicsCalibrator     = new CameraExtrinsicsCalibrator();
            _prevChessCorners         = new Vector2[_chessPatternPointCount];
            _chessCornersRealModelMat = TrackingToolsHelper.CreateRealModelPatternPoints(_chessPatternSize, _chessTileSize, TrackingToolsHelper.PatternType.Chessboard);

            // Create objects.
            _chessPatternTransform            = GameObject.CreatePrimitive(PrimitiveType.Quad).transform;
            _chessPatternTransform.name       = "Chessboard";
            _chessPatternTransform.localScale = new Vector3((_chessPatternSize.x - 1) * _chessTileSize * 0.001f, (_chessPatternSize.y - 1) * _chessTileSize * 0.001f, 0);

            // Prepare world points.
            TrackingToolsHelper.UpdateWorldSpacePatternPoints(_chessPatternSize, _chessPatternTransform.localToWorldMatrix, TrackingToolsHelper.PatternType.Chessboard, Vector2.zero, ref _chessCornersWorldMat);

            // Prepare UI.
            TrackingToolsHelper.RenderPattern(_chessPatternSize, TrackingToolsHelper.PatternType.Chessboard, 1024, ref _chessPatternTexture, ref _patternRenderMaterial);
            _aspectFitter = _processedCameraImage.GetComponent <AspectRatioFitter>();
            if (!_aspectFitter)
            {
                _aspectFitter = _processedCameraImage.gameObject.AddComponent <AspectRatioFitter>();
            }
            _aspectFitter.aspectMode = AspectRatioFitter.AspectMode.FitInParent;
            Shader shader = Shader.Find(TrackingToolsConstants.previewShaderName);

            _previewMaterial = new Material(shader);
            _processedCameraImage.material = _previewMaterial;
            _processedCameraImage.color    = Color.white;
            _arImage = new GameObject("ARImage").AddComponent <RawImage>();
            _arImage.transform.SetParent(_processedCameraImage.transform);
            _arImage.rectTransform.FitParent();
            _arImage.gameObject.SetActive(false);
            Shader   unlitTextureShader = Shader.Find("Unlit/Texture");
            Material chessboardMaterial = new Material(unlitTextureShader);

            chessboardMaterial.mainTexture = _chessPatternTexture;
            _chessPatternTransform.GetComponent <Renderer>().material = chessboardMaterial;
            if (_sampleCountMeterFillImage)
            {
                _sampleCountMeterFillImage.fillAmount = 0;
            }
            _previewFlasher = new MaterialPropFlasher(_previewMaterial, "_Whiteout", TrackingToolsConstants.flashDuration);

            // Setup camera.
            _mainCamera.backgroundColor = Color.clear;
            _mainCamera.gameObject.SetActive(false);
        }
Ejemplo n.º 16
0
    void Start()
    {
        string path = Path.Combine(Application.streamingAssetsPath, fileName);

        network = NNRunner.Instance;

        WebCamDevice[] devices = WebCamTexture.devices;
        webcamTexture = new WebCamTexture(devices[0].name);

        GameObject videoScreen = GameObject.Find("VideoScreen");
        RawImage   screen      = videoScreen.GetComponent <RawImage>();
        var        sd          = screen.GetComponent <RectTransform>();

        screen.texture = webcamTexture;

        webcamTexture.Play();

        sd.sizeDelta = new Vector2(videoScreenWidth, (int)(videoScreenWidth * webcamTexture.height / webcamTexture.width));

        texture = new Texture2D(webcamTexture.width, webcamTexture.height);

        // Clip size
        videoWidth  = texture.width;
        videoHeight = texture.height;
        float padWidth  = (videoWidth < videoHeight) ? 0 : (videoHeight - videoWidth) / 2;
        float padHeight = (videoWidth < videoHeight) ? (videoWidth - videoHeight) / 2 : 0;

        if (clipScale == 0f)
        {
            clipScale = 0.001f;
        }
        var w = (videoWidth + padWidth * 2f) * clipScale;

        padWidth  += w;
        padHeight += w;
        clipRect   = new UnityEngine.Rect(-padWidth, -padHeight, videoWidth + padWidth * 2, videoHeight + padHeight * 2);

        /*
         * networkInputs = new Texture[1];
         * networkInputs[0] = webcamTexture;
         *
         * glDrawer.OnDraw += OnGLDraw;
         *
         * imageRotation.eulerAngles = new Vector3(0, 0, 180);
         *
         * Vector3 test = new Vector3(1, 0, 0);
         * Debug.Log(imageRotation * test);
         */

        results = new NetworkResult[(int)JointIndex.COUNT];
    }
Ejemplo n.º 17
0
    public int qrScoreValue = 1; //waarde per gescande QR code


    public override void Setup()
    {
        webcamTexture = new WebCamTexture(); //functie van unity. pakt data van webcam op device en maakt er een texture van
        rawimage      = GetComponentInChildren <RawImage>();
        //rawimage = this.GetComponentFromChild<RawImage>();
        rawimage.texture = webcamTexture;
        rawimage.GetComponent <RectTransform>().sizeDelta = new Vector2((Screen.width * 1.333f), Screen.width); //height en width (vector2). aan width voegt hij een constante toe om width&height goed te houden
        if (webcamTexture != null)                                                                              //start webcamtexture
        {
            webcamTexture.Play();
        }

        UIManager.Instance.activeMenu = Instantiate(UIManager.Instance.menu, UIManager.Instance.transform, false);
    }
    // Use this for initialization
    void Start()
    {
        RectTransform t1 = Vehicle.GetComponent <RectTransform>();

        t1.position = new Vector3(2000f
                                  , -100f
                                  , 0);
        RectTransform t2 = Vehicle2.GetComponent <RectTransform>();

        t2.position = new Vector3(2000f
                                  , 150f
                                  , 0);

        RectTransform t3 = Vehicle3.GetComponent <RectTransform>();

        t3.position = new Vector3(2000f
                                  , 450f
                                  , 0);

        is_stop = false;
        check   = true;
        rot     = 0;
    }
Ejemplo n.º 19
0
    public void HealthBar()
    {
        float percentHealth = health / maxHealth;
        //Debug.Log("percentHealth" + percentHealth);

        float healthLeft = barWidth * percentHealth;
        //Debug.Log("barWidth" + barWidth);
        RectTransform innerBar = bar.GetComponent <RectTransform>();

        //Debug.Log("inner Bar size Delta" + innerBar.sizeDelta.x);
        innerBar.sizeDelta = new Vector2(healthLeft, bar.rectTransform.sizeDelta.y);

        innerBar.anchoredPosition = new Vector2(healthLeft / 2 + 6, innerBar.anchoredPosition.y);
    }
Ejemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     splashscreen.GetComponent <RawImage>().material.mainTexture = splashscreenTexture;
     splashscreenTexture.Play();
     if (GameObject.Find("NetworkManager"))
     {
         SceneManager.UnloadScene("Deathmatch");
         NetworkManager manager = GameObject.Find("NetworkManager").GetComponent <NetworkManager>();
         manager.StopHost();
         Destroy(manager.gameObject);
     }
     infiltrationButton.interactable = false;
     gamemodePanel.SetActive(false);
 }
    // method to to tap in the right coords despite difference in scaling
    private void AddTap(Vector3 pos)
    {
        RectTransform rectTransform = _rawImage.GetComponent <RectTransform>();
        Camera        thisCamera    = Camera.main;

        Debug.Assert(thisCamera.name == "CenterEyeAnchor");
        Vector2 positionInRect = new Vector2();

        Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(thisCamera, pos);

        //Debug.Log("screen point: " + screenPoint);

        RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
                                                                screenPoint, thisCamera, out positionInRect);
        //Debug.Log("main camera is: " + Camera.main.name);

        // take care of the pivots and their effect on position
        positionInRect.x += rectTransform.pivot.x * rectTransform.rect.width;
        positionInRect.y += (rectTransform.pivot.y * rectTransform.rect.height);


        Debug.Assert(Math.Abs(rectTransform.pivot.y) > 0);
        // change coordinate system
        positionInRect.y += -rectTransform.rect.height;
        positionInRect.y  = Math.Abs(positionInRect.y);
        //Debug.Log(positionInRect);

        bool assumingPositionIsInWebView = true;

        // TODO: we're assuming the point is within the texture
        Debug.Assert(assumingPositionIsInWebView);

        // get the screen dimensions and divide them by the rectangle's screen dimensions for scaling
        float screenWidth  = _width;                             //rect.width;
        float screenHeight = _androidScreenHeight;               //rect.height;

        float xScale = screenWidth / rectTransform.rect.width;   // rectWidthInScreen;
        float yScale = screenHeight / rectTransform.rect.height; // rectHeightInScreen;

        Vector2 positionInWebView = new Vector2(positionInRect.x * xScale, positionInRect.y * yScale);

        Debug.Log("position in webview: " + positionInWebView);

//        Debug.Log("transformed pos:" + positionInWebView);
        // if we're within the bounds of the rectangle
        if (_ajc != null)
        {
            CallAjc("AddTap", new object[] { positionInWebView.x, positionInWebView.y });
        }
    }
Ejemplo n.º 22
0
    public void DisplayText(string Text)
    {
        if (isPrinting)
        {
            StopCoroutine(PrintCoroutine);
        }

        if (!isActive)
        {
            Toggle();
        }

        Selection.color = Color.clear;
        foreach (TextMeshProUGUI T in Choices)
        {
            T.text = "";
        }
        SelectionIndex = 0;
        Selection.GetComponent <RectTransform>().anchoredPosition = new Vector2(0f, Choices[0].GetComponent <RectTransform>().anchoredPosition.y);

        PrintCoroutine = PrintText(Text);
        StartCoroutine(PrintCoroutine);
    }
Ejemplo n.º 23
0
 private void FixedUpdate()
 {
     if (ChatDataHandler.Instance.IsStartChat)
     {
         if (SelfRawImage != null && SelfRawImage.transform.GetComponent <RectTransform>().rect.size != SelfRawImage.texture.texelSize)
         {
             SelfRawImage.GetComponent <AspectRatioFitter>().aspectRatio = (SelfRawImage.texture.width + 0.0f) / SelfRawImage.texture.height;
         }
         if (ChatPeerRawImage != null && ChatPeerRawImage.transform.GetComponent <RectTransform>().rect.size != ChatPeerRawImage.texture.texelSize)
         {
             ChatPeerRawImage.GetComponent <AspectRatioFitter>().aspectRatio = (ChatPeerRawImage.texture.width + 0.0f) / ChatPeerRawImage.texture.height;
         }
     }
 }
Ejemplo n.º 24
0
 void qrEncodeFinished(Texture2D tex)
 {
     if (tex != null && tex != null)
     {
         int   width  = tex.width;
         int   height = tex.height;
         float aspect = width * 1.0f / height;
         qrCodeImage.GetComponent <RectTransform> ().sizeDelta = new Vector2(170, 170.0f / aspect);
         qrCodeImage.texture = tex;
     }
     else
     {
     }
 }
Ejemplo n.º 25
0
    public void setupButtons(int x, int z, int width, int length, int index, Vector3 place)
    {
        Vector3[] mapCorners = new Vector3[4];
        mapImage.GetComponent <RectTransform>().GetWorldCorners(mapCorners);

        float Xposition = (x * 1f / width) * (mapCorners[3].x - mapCorners[0].x) + mapCorners[0].x;
        float Yposition = (z * 1f / length) * (mapCorners[1].y - mapCorners[0].y) + mapCorners[0].y;

        var rectTransform = dockPlacementButtons[index].GetComponent <RectTransform>();

        dockPlacementButtons[index].GetComponent <DockButton>().setPlacement(place);
        rectTransform.SetParent(transform.GetChild(2).GetComponent <RectTransform>());
        rectTransform.position = new Vector2(Xposition, Yposition);
    }
Ejemplo n.º 26
0
        public void SetInitialValues(KeyValuePair <ShapeDescriptor, Texture2D> textureEntry, ToggleGroup toggleGroup)
        {
            ShapeDescriptor = textureEntry.Key;

            label.text             = $"C: {ShapeDescriptor.Collection} B: {ShapeDescriptor.Bitmap}";
            texturePreview.texture = textureEntry.Value;
            texturePreview.GetComponent <AspectRatioFitter>().aspectRatio = (float)texturePreview.texture.width / (float)texturePreview.texture.height;

            var toggle = GetComponent <Toggle>();

            toggle.group = toggleGroup;

            usageIndicator.SetActive(MaterialGeneration_Geometry.GetTextureIsInUse(ShapeDescriptor));
        }
Ejemplo n.º 27
0
    void Start()
    {
        mess = GameObject.Find("fortuneText");
        if (cameraShot)
        {
            ratioFitter = cameraShot.GetComponent <AspectRatioFitter>();
        }

        hasCamera = imageSource != null && imageSource.HasCamera();

        hintMessage = hasCamera ? "Click on the camera image to make a shot" : "No camera found";

        SetHintText(hintMessage);
    }
Ejemplo n.º 28
0
        void Start()
        {
            RectTransform albumTransform = albumIcon.GetComponent <RectTransform>();
            Vector2       startSize      = albumTransform.sizeDelta;
            Vector2       targetSize     = startSize + new Vector2(5, 5);

            LTSeq seq = LeanTween.sequence();

            seq
            .append(LeanTween.size(albumTransform, targetSize, 2))
            .append(LeanTween.size(albumTransform, startSize, 2))
            .append(LeanTween.size(albumTransform, targetSize, 2))
            .append(LeanTween.size(albumTransform, startSize, 2));
        }
Ejemplo n.º 29
0
    private void SetImageDisplay()
    {
        RectTransform rectTransform =
            outputImage.GetComponent <RectTransform>();

        rectTransform.SetSizeWithCurrentAnchors(
            RectTransform.Axis.Vertical,
            rectTransform.rect.width *
            _tesseractDriver.GetHighlightedTexture().height /
            _tesseractDriver.GetHighlightedTexture().width);

        outputImage.texture =
            _tesseractDriver.GetHighlightedTexture();
    }
    public void OnPointerClick(PointerEventData eventData)
    {
        Destroy(ParkInfo, 0.5f);
        Destroy(Button, 0.5f);
        Destroy(text1, 0.5f);
        Destroy(text2, 0.5f);
        Destroy(Park, 0.5f);
        RawImage rim = InfoMini.GetComponent <RawImage>();
        RawImage mp  = MiniPark.GetComponent <RawImage>();

        rim.enabled = true;
        mp.enabled  = true;
        game_start  = true;
    }