【问题标题】:Unity make rounded corner on radial circle bar?Unity在径向圆条上制作圆角?
【发布时间】:2019-03-27 18:24:20
【问题描述】:

好的,我正在使用这个脚本和一个成功地统一展开的图像:

// 每帧调用一次更新 无效更新(){

circle2.transform.position = new Vector3(Mathf.Sin(currentValue * 6.28f), Mathf.Cos(currentValue * 6.28f), 0f) * 1;

if (currentValue < 100) {
    currentValue += speed * Time.deltaTime;
    //ProgressIndicator.text = ((int)currentValue).ToString () + "%";
    //LoadingText.SetActive (true);
}

LoadingBar.fillAmount = currentValue / 100;

我正在尝试制作类似 Apple Watch 圆圈的东西,其中端盖是圆形的。为此,他们在这里说使用他们列出的 vector3 在笔画末端定位一个圆圈:

https://forum.unity.com/threads/ui-rounded-circular-bar.461067/

这不起作用。如何将圆定位在展开行程的末端/圆的一部分的任何位置?

【问题讨论】:

    标签: c# user-interface unity3d


    【解决方案1】:

    Sin 和 Cos 函数提供 范围内的值。在 GUI 上放置元素可能太少了。

    在下面的表达式的末尾,尝试用一些更大的值替换一个。

    Vector3(Mathf.Sin(currentValue * 6.28f), Mathf.Cos(currentValue * 6.28f), 0f) * /*replace this: */ 1;
    

    关键是把它调整到你的圆的半径。

    【讨论】:

      【解决方案2】:

      问题在于使用

      circle2.transform.position
      

      对于 UI 对象。这会在全局坐标中设置位置

      要放置 UI 对象,您可以使用 this

      【讨论】:

        【解决方案3】:

        希望这会有所帮助并可以清除它:

         currentLerpTimeScan += Time.deltaTime;
         if (currentLerpTimeScan > lerpTime)
         {
            currentLerpTimeScan = lerpTime;
         }
        
         float perc = currentLerpTimeScan / lerpTime;
         perc = Mathf.Sin(perc * Mathf.PI * 0.5f);
         RadialImageScan.fillAmount = Mathf.Lerp(startValueScan, endValueScan, perc);
        
         currentValue = RadialImageScan.fillAmount;
        
         ScanCircle.localPosition = 
         (new Vector2(Mathf.Sin(currentValue * 6.28f), 
         Mathf.Cos(currentValue * 6.28f)) * scanMultiplier) * -1; 
         // remove -1 if you wish this depends on ui setup
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-05-15
          • 1970-01-01
          • 2015-06-24
          • 1970-01-01
          • 1970-01-01
          • 2021-12-27
          • 2013-11-23
          相关资源
          最近更新 更多