1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      UGUI繪制動態(tài)曲線

      本文實(shí)例為大家分享了UGUI繪制動態(tài)曲線的具體代碼,供大家參考,具體內(nèi)容如下

      為深圳等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及深圳網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為網(wǎng)站設(shè)計制作、網(wǎng)站建設(shè)、深圳網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

      前言

      等有空再補(bǔ)詳細(xì)說明,先上代碼。看官自行閱讀

      代碼

      UICurveData 類,用于存放點(diǎn)數(shù)據(jù)的基礎(chǔ)結(jié)構(gòu)。

      public class UICurveData
      {
       #region [Fields]
       public List Postion = new List();
       public Color Ccolor;
       public float Thickness = 1;
       #endregion
      
       #region [PublicTools]
       public void Addpos(float varX, float varY)
       {
        Addpos(new Vector2(varX, varY));
       }
       public void Addpos(Vector2 varV2)
       {
        Postion.Add(varV2);
       }
       #endregion
      
      }

      UICurve 負(fù)責(zé)構(gòu)建頂點(diǎn)數(shù)據(jù),mesh。

      public class UICurve : MaskableGraphic
      {
       #region [Fields]
       private Dictionary mCurveData = new Dictionary();
       #endregion
      
       #region [Inherit]
       protected override void OnPopulateMesh(VertexHelper varVerHeler)
       {
        varVerHeler.Clear();
      
        foreach (var tempKvp in mCurveData)
        {
         var tempUICurveData = tempKvp.Value;
         if (tempUICurveData.Postion.Count < 2)
         {
          continue;
         }
         for (int i = 1; i < tempUICurveData.Postion.Count; i++)
         {
          UIVertex[] verts = new UIVertex[4];
      
          float x1 = tempUICurveData.Postion[i - 1].x;
          float y1 = tempUICurveData.Postion[i - 1].y;
          float x2 = tempUICurveData.Postion[i].x;
          float y2 = tempUICurveData.Postion[i].y;
      
          float xd = (y2 - y1) / Mathf.Sqrt(Mathf.Pow(x2 - x1, 2) * Mathf.Pow(y2 - y1, 2)) * tempKvp.Value.Thickness / 2;
          float yd = (x2 - x1) / Mathf.Sqrt(Mathf.Pow(x2 - x1, 2) * Mathf.Pow(y2 - y1, 2)) * tempKvp.Value.Thickness / 2;
      
          int idx = 0;
          verts[idx].position = new Vector3(tempUICurveData.Postion[i - 1].x - xd, tempUICurveData.Postion[i - 1].y + yd);
          verts[idx].color = tempUICurveData.Ccolor;
          verts[idx].uv0 = Vector2.zero;
      
          idx++;
          verts[idx].position = new Vector3(tempUICurveData.Postion[i].x - xd, tempUICurveData.Postion[i].y + yd);
          verts[idx].color = tempUICurveData.Ccolor;
          verts[idx].uv0 = Vector2.zero;
      
          idx++;
          verts[idx].position = new Vector3(tempUICurveData.Postion[i].x + xd, tempUICurveData.Postion[i].y - yd);
          verts[idx].color = tempUICurveData.Ccolor;
          verts[idx].uv0 = Vector2.zero;
      
          idx++;
          verts[idx].position = new Vector3(tempUICurveData.Postion[i - 1].x + xd, tempUICurveData.Postion[i - 1].y - yd);
          verts[idx].color = tempUICurveData.Ccolor;
          verts[idx].uv0 = Vector2.zero;
      
          varVerHeler.AddUIVertexQuad(verts);
         }
        }
      
       }
       #endregion
      
       #region [PublicTools]
       public void AddCurveData(int varID, UICurveData varCurveData)
       {
        mCurveData.Add(varID, varCurveData);
        SetAllDirty();
       }
       public void Clear()
       {
        mCurveData.Clear();
        SetAllDirty();
       }
       public void RemovePointIDs(params int[] varRemovepoints)
       {
        List tempL = new List();
        tempL.AddRange(varRemovepoints);
        RemovePointIDs(tempL);
       }
       public void RemovePointIDs(List varRemovePoints)
       {
        foreach (var i in varRemovePoints)
        {
         if (!mCurveData.ContainsKey(i)) continue;
         mCurveData.Remove(i);
        }
        SetAllDirty();
       }
       #endregion
      }

      測試使用

      public class TestCurve : MonoBehaviour
      {
       void Start()
       {
        var tempCurve = this.gameObject.AddComponent();
        UICurveData tempcd = new UICurveData();
        tempcd.Ccolor = Color.yellow;
        tempcd.Thickness = 2;
        for (int i = 0; i < 360; i++)
        {
         tempcd.Addpos(i * 2,(float)Mathf.Cos(i));
        }
        tempCurve.AddCurveData(1,tempcd);
       }
      }

      將該腳本掛在 Canvas 上,運(yùn)行會看到

      UGUI繪制動態(tài)曲線

      以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。


      分享題目:UGUI繪制動態(tài)曲線
      網(wǎng)址分享:http://www.ef60e0e.cn/article/gpghhi.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        宁河县| 噶尔县| 莲花县| 扶沟县| 江永县| 九寨沟县| 南平市| 宁夏| 墨玉县| 连云港市| 右玉县| 彰武县| 育儿| 灵山县| 图木舒克市| 华安县| 阿巴嘎旗| 阿坝县| 始兴县| 宁德市| 山东| 兴海县| 满城县| 绥宁县| 河东区| 海林市| 赣州市| 汨罗市| 玉环县| 凤庆县| 焦作市| 平陆县| 丽水市| 常德市| 香格里拉县| 平度市| 彝良县| 盐边县| 嘉禾县| 茶陵县| 星子县|