Beispiel #1
0
 public void setValue(float value)
 {
     this._value = Mathf.Min(maxValue, Mathf.Max(minValue, value));
     mask.GetComponent <RectTransform>().sizeDelta = new Vector2(_width * getPercentage(), _height);
     mask.gameObject.SetActive(_value != 0);
     if (label)
     {
         label.text = (this._value / maxValue * 100).ToString("0.0") + "%";
     }
 }
Beispiel #2
0
        void setClip()
        {
            Vector3[] wc = new Vector3[4];
            mask.GetComponent <RectTransform>().GetWorldCorners(wc);              // 计算world space中的点坐标
            var clipRect = new Vector4(wc[0].x, wc[0].y, wc[2].x, wc[2].y);       // 选取左下角和右上角

            mt.SetVector("_ClipRect", clipRect);                                  // 设置裁剪区域
            mt.SetFloat("_UseClipRect", 1.0f);                                    // 开启裁剪
        }
Beispiel #3
0
 public void setValue(float value)
 {
     this._value = Mathf.Min(maxValue, Mathf.Max(minValue, value));
     mask.GetComponent <RectTransform>().sizeDelta = new Vector2(
         GetComponent <RectTransform>().rect.width *getPercentage(),
         GetComponent <RectTransform>().rect.height);
     mask.gameObject.SetActive(_value != 0);
     if (label)
     {
         if (style == ProgressLabStyle.Normal)
         {
             label.text = (this._value / maxValue * 100).ToString("0.0") + "%";
         }
         else if (style == ProgressLabStyle.Value)
         {
             label.text = string.Format("{0}/{1}", this._value, maxValue);
         }
     }
 }
Beispiel #4
0
 private void Update()
 {
     if (mask != null)
     {
         Vector3[] wc = new Vector3[4];
         mask.GetComponent <RectTransform>().GetWorldCorners(wc);                       // 计算world space中的点坐标
         var clipRect = new Vector4(wc[0].x, wc[0].y, wc[2].x, wc[2].y);                // 选取左下角和右上角
         Shader.SetGlobalVector("_ClipRect", clipRect);                                 // 设置裁剪区域
     }
 }
Beispiel #5
0
    /*---------------------------*
    * Load Method
    *---------------------------*/
    //WebCamTextureの初期化
    private void initWebCamTexture()
    {
        if (rawImage)
        {
            if (!rectMask)
            {
                //RectMask2Dの初期化
                initRectMask2D();
            }

            //Webカメラの取得
            if (WebCamTexture.devices.Length > 0)
            {
                //Webカメラ情報の取得
                WebCamDevice webCamDevice = WebCamTexture.devices[0];

                //WebCamTextureの作成
                RectTransform maskTransform = rectMask.GetComponent <RectTransform>();
                webCamTexture = new WebCamTexture(webCamDevice.name, (int)maskTransform.sizeDelta.x, (int)maskTransform.sizeDelta.y);

                //WebCamTextureをrawImageで表示する
                rawImage.material.mainTexture = webCamTexture;

                //WebCamTextureの撮影開始
                webCamTexture.Play();

                StartCoroutine("waitWebCamFrame");
            }
            else
            {
                Debug.LogError("Webカメラが認識できません");
            }
        }
        else
        {
            Debug.LogError("RawImageが指定されていません");
        }
    }
Beispiel #6
0
    void EnsureCanvasChildHookRectTransform()
    {
        if (canvasChildHookRT == null)
        {
            RectMask2D constrainedPanelMask = GetComponentInParent <RectMask2D>();

            if (constrainedPanelMask != null)
            {
                canvasChildHookRT = constrainedPanelMask.GetComponent <RectTransform>();
                return;
            }

            canvasChildHookRT = GetComponentInParent <Canvas>()?.GetComponent <RectTransform>();
        }
    }