胡佳骏 1 rok temu
rodzic
commit
4e2da6c8c9

+ 17 - 107
Assets/FrameWork/ProjectManager/XunJian/列表模块/列表模块.prefab

@@ -5683,79 +5683,6 @@ MonoBehaviour:
     m_PersistentCalls:
       m_Calls: []
   m_IsOn: 0
---- !u!1 &5033862211029755811
-GameObject:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  serializedVersion: 6
-  m_Component:
-  - component: {fileID: 790570110717618169}
-  - component: {fileID: 4826313538229715384}
-  - component: {fileID: 4117939919842230228}
-  m_Layer: 5
-  m_Name: xian
-  m_TagString: Untagged
-  m_Icon: {fileID: 0}
-  m_NavMeshLayer: 0
-  m_StaticEditorFlags: 0
-  m_IsActive: 0
---- !u!224 &790570110717618169
-RectTransform:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 5033862211029755811}
-  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
-  m_LocalPosition: {x: 0, y: 0, z: 0}
-  m_LocalScale: {x: 1, y: 1, z: 1}
-  m_ConstrainProportionsScale: 0
-  m_Children: []
-  m_Father: {fileID: 627361399737624296}
-  m_RootOrder: 0
-  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 1125.15, y: -68.850006}
-  m_SizeDelta: {x: 2250.3, y: 5}
-  m_Pivot: {x: 0.5, y: 0.5}
---- !u!222 &4826313538229715384
-CanvasRenderer:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 5033862211029755811}
-  m_CullTransparentMesh: 1
---- !u!114 &4117939919842230228
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 5033862211029755811}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  m_Material: {fileID: 0}
-  m_Color: {r: 1, g: 1, b: 1, a: 1}
-  m_RaycastTarget: 1
-  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
-  m_Maskable: 1
-  m_OnCullStateChanged:
-    m_PersistentCalls:
-      m_Calls: []
-  m_Texture: {fileID: 2800000, guid: d58dd8b82bc7b7b468a6bca9f2236c3f, type: 3}
-  m_UVRect:
-    serializedVersion: 2
-    x: 0
-    y: 0
-    width: 1
-    height: 1
 --- !u!1 &5049191459586096826
 GameObject:
   m_ObjectHideFlags: 0
@@ -8527,8 +8454,7 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 627361399737624296}
-  - component: {fileID: 1613631115797794176}
-  - component: {fileID: 220154421918169732}
+  - component: {fileID: 6956903071123826589}
   m_Layer: 5
   m_Name: Content
   m_TagString: Untagged
@@ -8547,8 +8473,7 @@ RectTransform:
   m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
-  m_Children:
-  - {fileID: 790570110717618169}
+  m_Children: []
   m_Father: {fileID: 9164797641204290648}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -8557,33 +8482,7 @@ RectTransform:
   m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0, y: 1}
---- !u!114 &1613631115797794176
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 8610976162778903711}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  m_Padding:
-    m_Left: 0
-    m_Right: 0
-    m_Top: 30
-    m_Bottom: 30
-  m_ChildAlignment: 0
-  m_Spacing: 15
-  m_ChildForceExpandWidth: 1
-  m_ChildForceExpandHeight: 1
-  m_ChildControlWidth: 0
-  m_ChildControlHeight: 0
-  m_ChildScaleWidth: 0
-  m_ChildScaleHeight: 0
-  m_ReverseArrangement: 0
---- !u!114 &220154421918169732
+--- !u!114 &6956903071123826589
 MonoBehaviour:
   m_ObjectHideFlags: 0
   m_CorrespondingSourceObject: {fileID: 0}
@@ -8592,11 +8491,22 @@ MonoBehaviour:
   m_GameObject: {fileID: 8610976162778903711}
   m_Enabled: 1
   m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
+  m_Script: {fileID: 11500000, guid: 15e5c8fd25cbf5c4b889b2de07e11e22, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  m_HorizontalFit: 0
-  m_VerticalFit: 2
+  cell_x: 2267
+  cell_y: 200
+  minIndex: 0
+  maxCount: 0
+  arrangeType: 1
+  ConstraintCount: 0
+  mScroll: {fileID: 3517939022194484626}
+  leftOffset: 0
+  rightOffset: 0
+  topOffset: 0
+  bottomOffset: 0
+  XSpacing: 0
+  YSpacing: 0
 --- !u!1 &8622215101529422092
 GameObject:
   m_ObjectHideFlags: 0

+ 56 - 2
Assets/HotUpdate/Scripts/Scripts/Project/XunJian/XunJianDataManager.cs

@@ -16,9 +16,15 @@ public class XunJianDataManager : Singleton<XunJianDataManager>
 
     public int page = 1;
 
-    public void GetXunJianList(Action<List<XunJianListData>> callback)
+    public void GetXunJianList(Action<List<XunJianListData>> callback,int count)
     {
-       WindowsManager.Instance.StartCoroutine(testBack(callback));
+        WindowsManager.Instance.StartCoroutine(getList(callback, count));
+
+    }
+
+    public void GetXunJianCount(Action<int> callback)
+    {
+        WindowsManager.Instance.StartCoroutine(getListCount(callback));
 
     }
 
@@ -383,6 +389,54 @@ public class XunJianDataManager : Singleton<XunJianDataManager>
 
         return listWall;
     }
+
+
+    IEnumerator getListCount(Action<int> callback)
+    {
+
+        JsonData jsonData = new JsonData();
+        jsonData["page"] = page++;
+        jsonData["limit"] = 10;
+        Debug.Log(jsonData.ToJson());
+        yield return WindowsManager.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpEdustryAction.InspectionList, jsonData.ToJson(), (string msg) =>
+        {
+            try
+            {
+                JObject jObject = JObject.Parse(msg);
+                int listConunt = int.Parse(jObject["data"]["count"].ToString());
+                callback.Invoke(listConunt);
+
+            }
+            catch
+            {
+
+                callback.Invoke(0);
+            }
+        }));
+    }
+
+    int getMaxCount = 10;
+    IEnumerator getList(Action<List<XunJianListData>> callback,int count)
+    {
+        xjDataList.Clear();
+        for (int i = 1; i < (count/ getMaxCount) +2; i++)
+        {
+            JsonData jsonData = new JsonData();
+            jsonData["page"] = i;
+            jsonData["limit"] = getMaxCount;
+            Debug.Log(jsonData.ToJson());
+            yield return WindowsManager.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpEdustryAction.InspectionList, jsonData.ToJson(), (string msg) =>
+            {
+                Debug.Log("msg===>"+ msg);
+                JObject jObject = JObject.Parse(msg);
+                int listConunt = int.Parse(jObject["data"]["count"].ToString());
+                List<XunJianData> data = JsonConvert.DeserializeObject<List<XunJianData>>(jObject["data"]["list"].ToString());
+                xjDataList.AddRange(XunJianDataParetListData(data));
+                callback.Invoke(xjDataList);
+            }));
+        }
+
+    }
     IEnumerator testBack(Action<List<XunJianListData>> callback)
     {
         // 加入分页查询

+ 0 - 59
Assets/HotUpdate/Scripts/Scripts/Project/XunJianLieBiaoRefresh.cs

@@ -7,64 +7,5 @@ using static XunJianDataManager;
 
 public class XunJianLieBiaoRefresh : ScrollRect
 {
-    //高度 往下拉是负数   往上拉是正数
-    float f = -30f;
-    //是否刷新
-    bool isRef = false;
-    //是否处于拖动
-    bool isDrag = false;
-    //显示、隐藏刷新字段
-    //public Callback<bool> callback1;
-    //如果满足刷新条件 执行的方法
-   // public Callback callback2;
-
-    protected override void Awake()
-    {
-        base.Awake();
-        onValueChanged.AddListener(ScrollValueChanged);
-    }
-
-    /// <summary>
-    /// 当ScrollRect被拖动时
-    /// </summary>
-    /// <param name="vector">被拖动的距离与Content的大小比例</param>
-    void ScrollValueChanged(Vector2 vector)
-    {
-        //如果不拖动 当然不执行之下的代码
-        if (!isDrag)
-            return;
-        //这个就是Content
-        RectTransform rect = GetComponentInChildren<ContentSizeFitter>().GetComponent<RectTransform>();
-        //如果拖动的距离大于给定的值
-        if (f > rect.rect.height * vector.y)
-        {
-            isRef = true;
-          
-        }
-        else
-        {
-            isRef = false;
-           
-        }
-    }
-
-    public override void OnBeginDrag(PointerEventData eventData)
-    {
-        base.OnBeginDrag(eventData);
-        isDrag = true;
-    }
-
-    public override void OnEndDrag(PointerEventData eventData)
-    {
-        base.OnEndDrag(eventData);
-
-        if (isRef)
-        {
-            XunJianLieBiaoWindow.Instance.RefreshLieBiao();
-
-        }
-        isRef = false;
-        isDrag = false;
-    }
 
 }

+ 59 - 98
Assets/HotUpdate/Scripts/Scripts/Project/XunJianLieBiaoWindow.cs

@@ -8,131 +8,92 @@ using static XunJianDataManager;
 
 public class XunJianLieBiaoWindow : WindowSingleton<XunJianLieBiaoWindow>
 {
-
+   
     public TMP_Dropdown chooseArea;
     public TMP_Dropdown choosePeople;
     public GameObject parentGo;
     public List<GameObject> itemList;
-    protected override void OnStart()
+    UIScrollScript uiScroll;
+    int MaxLiebiao=10;
+    void refList()
     {
-        base.OnStart();
-        RemoveAll();
-        XunJianDataManager.Instance.page = 1;
         GameObject liebiao = WindowsManager.Instance.GetPrefab(WindowConfig.windowType.XunJian, "liebiao");
-        XunJianDataManager.Instance.GetXunJianList((List<XunJianListData> data) => {
-            for (int i = 0; i < data.Count; i++)
+        XunJianDataManager.Instance.GetXunJianCount((int data) => {
+            for (int i = 0; i < MaxLiebiao; i++)
             {
                 GameObject itemGo = GameObject.Instantiate(liebiao, parentGo.transform);
-                XunJianLieBiaoItem item = itemGo.GetComponent<XunJianLieBiaoItem>();
-                item.updateData(data[i]);
                 itemList.Add(itemGo);
             }
-            chooseArea.options = new List<TMP_Dropdown.OptionData>();
-            foreach (var it in XunJianDataManager.Instance.areaList.Keys)
+            uiScroll.Init();
+            uiScroll.InitList(0, data);
+            XunJianDataManager.Instance.GetXunJianList((List<XunJianListData> data) =>
             {
-                TMP_Dropdown.OptionData Ddata = new TMP_Dropdown.OptionData();
-                Ddata.text = it;
-                chooseArea.options.Add(Ddata);
-            }
-            choosePeople.options = new List<TMP_Dropdown.OptionData>();
-            foreach (var it in XunJianDataManager.Instance.peopleList.Keys)
-            {
-                TMP_Dropdown.OptionData Ddata = new TMP_Dropdown.OptionData();
-                Ddata.text = it;
-                choosePeople.options.Add(Ddata);
-            }
-            TMP_Dropdown.OptionData Ddata2 = new TMP_Dropdown.OptionData();
-            Ddata2.text = "全部地区";
-            chooseArea.options.Add(Ddata2);
-            chooseArea.value = chooseArea.options.Count - 1;
-            TMP_Dropdown.OptionData Ddata3 = new TMP_Dropdown.OptionData();
-            Ddata3.text = "全部人员";
-            choosePeople.options.Add(Ddata3);
-            choosePeople.value = choosePeople.options.Count - 1;
+                for (int i = 0; i < MaxLiebiao; i++)
+                {
+                    XunJianLieBiaoItem item = itemList[i].GetComponent<XunJianLieBiaoItem>();
+                    item.updateData(data[i]);
+                }
+                /*
+                chooseArea.options = new List<TMP_Dropdown.OptionData>();
+                foreach (var it in XunJianDataManager.Instance.areaList.Keys)
+                {
+                    TMP_Dropdown.OptionData Ddata = new TMP_Dropdown.OptionData();
+                    Ddata.text = it;
+                    chooseArea.options.Add(Ddata);
+                }
+                choosePeople.options = new List<TMP_Dropdown.OptionData>();
+                foreach (var it in XunJianDataManager.Instance.peopleList.Keys)
+                {
+                    TMP_Dropdown.OptionData Ddata = new TMP_Dropdown.OptionData();
+                    Ddata.text = it;
+                    choosePeople.options.Add(Ddata);
+                }
+                TMP_Dropdown.OptionData Ddata2 = new TMP_Dropdown.OptionData();
+                Ddata2.text = "全部地区";
+                chooseArea.options.Add(Ddata2);
+                chooseArea.value = chooseArea.options.Count - 1;
+                TMP_Dropdown.OptionData Ddata3 = new TMP_Dropdown.OptionData();
+                Ddata3.text = "全部人员";
+                choosePeople.options.Add(Ddata3);
+                choosePeople.value = choosePeople.options.Count - 1;
 
-            chooseArea.onValueChanged.AddListener(areaChange);
-            choosePeople.onValueChanged.AddListener(peopleChange);
-        });
-    }
+                chooseArea.onValueChanged.AddListener(areaChange);
+                choosePeople.onValueChanged.AddListener(peopleChange);*/
 
-    public void RefreshLieBiao()
-    {
-        if (XunJianDataManager.Instance.page == -1)
-            return;
 
-        GameObject liebiao = WindowsManager.Instance.GetPrefab(WindowConfig.windowType.XunJian, "liebiao");
-        XunJianDataManager.Instance.GetXunJianList((List<XunJianListData> data) => {
-            for (int i = 0; i < data.Count; i++)
-            {
-                GameObject itemGo = GameObject.Instantiate(liebiao, parentGo.transform);
-                XunJianLieBiaoItem item = itemGo.GetComponent<XunJianLieBiaoItem>();
-                item.updateData(data[i]);
-                itemList.Add(itemGo);
-            }
-           // chooseArea.options = new List<TMP_Dropdown.OptionData>();
-            foreach (var it in XunJianDataManager.Instance.areaList.Keys)
-            {
-                TMP_Dropdown.OptionData Ddata = new TMP_Dropdown.OptionData();
-                Ddata.text = it;
-                chooseArea.options.Add(Ddata);
-            }
-            //choosePeople.options = new List<TMP_Dropdown.OptionData>();
-            foreach (var it in XunJianDataManager.Instance.peopleList.Keys)
-            {
-                TMP_Dropdown.OptionData Ddata = new TMP_Dropdown.OptionData();
-                Ddata.text = it;
-                choosePeople.options.Add(Ddata);
-            }
-            TMP_Dropdown.OptionData Ddata2 = new TMP_Dropdown.OptionData();
-            Ddata2.text = "全部地区";
-            chooseArea.options.Add(Ddata2);
-            chooseArea.value = chooseArea.options.Count - 1;
-            TMP_Dropdown.OptionData Ddata3 = new TMP_Dropdown.OptionData();
-            Ddata3.text = "全部人员";
-            choosePeople.options.Add(Ddata3);
-            choosePeople.value = choosePeople.options.Count - 1;
+            }, data);
 
-            //chooseArea.onValueChanged.AddListener(areaChange);
-            //choosePeople.onValueChanged.AddListener(peopleChange);
-        });
+        }
+        );
     }
 
-    private void peopleChange(int arg0)
+    protected override void OnStart()
     {
+        base.OnStart();
+        uiScroll = parentGo.GetComponent<UIScrollScript>();
         RemoveAll();
+        refList();
+        uiScroll.onUpdateItem += ContentUpdateItem;
+        /*
+        XunJianDataManager.Instance.page = 1;
         GameObject liebiao = WindowsManager.Instance.GetPrefab(WindowConfig.windowType.XunJian, "liebiao");
-        XunJianDataManager.Instance.GetPeopleList(choosePeople.options[arg0].text, (List<XunJianListData> data) => {
-            
-            for (int i = 0; i < data.Count; i++)
-            {
-                GameObject itemGo = GameObject.Instantiate(liebiao, parentGo.transform);
-                XunJianLieBiaoItem item = itemGo.GetComponent<XunJianLieBiaoItem>();
-                item.updateData(data[i]);
-                itemList.Add(itemGo);
-            }
-
-
-        });
+        XunJianDataManager.Instance.GetXunJianList((List<XunJianListData> data) => {
+          
+        });*/
     }
 
-    private void areaChange(int arg0)
+    private void ContentUpdateItem(GameObject item, int wrapIndex, int realIndex)
     {
-        RemoveAll();
-        GameObject liebiao = WindowsManager.Instance.GetPrefab(WindowConfig.windowType.XunJian, "liebiao");
-        XunJianDataManager.Instance.GetAreaList(chooseArea.options[arg0].text, (List<XunJianListData> data) => {
-           
-            for (int i = 0; i < data.Count; i++)
-            {
-                GameObject itemGo = GameObject.Instantiate(liebiao, parentGo.transform);
-                XunJianLieBiaoItem item = itemGo.GetComponent<XunJianLieBiaoItem>();
-                item.updateData(data[i]);
-                itemList.Add(itemGo);
-            }
 
+        if (realIndex >= 0&& XunJianDataManager.Instance.xjDataList.Count> realIndex)
+        {
+            XunJianLieBiaoItem xitem = item.GetComponent<XunJianLieBiaoItem>();
+            xitem.updateData(XunJianDataManager.Instance.xjDataList[realIndex]);
 
-        });
+        }
     }
 
+
     public void showRtc()
     {
         ShowInfoTipManager.Instance.showTip("暂未开放,敬请期待");

+ 479 - 0
Assets/HotUpdate/Tools/UIScrollScript.cs

@@ -0,0 +1,479 @@
+using UnityEngine;
+using System.Collections;
+using UnityEngine.UI;
+using System.Collections.Generic;
+
+
+/// <summary>  
+/// 设置Item内容的委托  
+/// </summary>  
+/// <param name="item">Item对象</param>  
+/// <param name="wrapIndex">Item在Grid中的序号</param>  
+/// <param name="realIndex">当前Item在List中的序号</param>  
+public delegate void OnUpdateItem(GameObject item, int wrapIndex, int realIndex);
+
+/// <summary>  
+/// 已显示了所有item的委托
+/// </summary>   
+public delegate void OnEatUpItem();
+
+
+///注意:当横排滚动时,不能使用横向拉伸布局,不然会有一些额外的多余尺寸问题
+///      同理,当竖排滚动时,不能使用纵向拉伸布局
+
+
+/// <summary>  
+/// 排列方式枚举  
+/// </summary>  
+public enum ArrangeType
+{
+    Horizontal = 0,//水平排列  
+    Vertical = 1,//垂直排列  
+}
+
+public class UIScrollScript : MonoBehaviour
+{
+    /// <summary>  
+    /// Item的宽
+    /// </summary>  
+    public int cell_x = 100;
+    /// <summary>
+    /// Item的高
+    /// </summary>
+    public int cell_y = 100;
+
+    /// <summary>  
+    /// Item最小索引
+    /// </summary>  
+    public int minIndex = 0;
+
+    /// <summary>  
+    /// Item最大数量
+    /// </summary>  
+    public int maxCount = 0;
+
+    /// <summary>  
+    /// 排列方式  
+    /// </summary>  
+    public ArrangeType arrangeType = ArrangeType.Horizontal;
+
+    /// <summary>  
+    /// 行列的个数  
+    /// </summary>  
+    public int ConstraintCount = 0;
+
+    /// <summary>  
+    /// 当前RectTransform对象  
+    /// </summary>  
+    RectTransform mRTrans;
+
+    /// <summary>  
+    /// ScrollRect组件
+    /// </summary>  
+    public ScrollRect mScroll;
+
+    /// <summary>
+    /// Pivot为中心点的坐标
+    /// </summary>
+    Vector2 pivotChildFactor = new Vector2(0.5f, 0.5f);
+
+    /// <summary>  
+    /// 滚动方向  
+    /// </summary>  
+    bool mHorizontal;
+
+    /// <summary>  
+    /// 子物体集合
+    /// </summary>  
+    List<Transform> ChildList = new List<Transform>();
+
+    /// <summary>  
+    /// 初始化时区域的长度或者高度的一半
+    /// </summary>  
+    private float extents = 0;
+
+
+    /// <summary>
+    /// SrollRect的尺寸
+    /// </summary>
+    Vector2 SR_size = Vector2.zero;
+
+
+    /// <summary>
+    /// SrollRect的尺寸  
+    /// </summary>
+    Vector3[] conners = new Vector3[4];
+
+    /// <summary>
+    /// ScrollRect的初始位置
+    /// </summary>
+    Vector2 startPos;
+
+    /// <summary>  
+    /// 设置Item的委托  
+    /// </summary>  
+    public OnUpdateItem onUpdateItem;
+
+    public OnEatUpItem onEatUpItem;
+
+
+    private bool isHandEatup = false;
+
+
+    [SerializeField] private float leftOffset = 0;
+    [SerializeField] private float rightOffset = 0;
+    [SerializeField] private float topOffset = 0;
+    [SerializeField] private float bottomOffset = 0;
+
+    /// <summary>
+    /// 一行中元素的间距
+    /// </summary>
+    [SerializeField] private float XSpacing = 0;
+
+    /// <summary>
+    /// 一列中元素的间距
+    /// </summary>
+    [SerializeField] private float YSpacing = 0;
+
+
+
+    /// <summary>
+    /// 初始化赋值(目前只会执行一次)
+    /// </summary>
+    public void Init()
+    {
+        mRTrans = transform.GetComponent<RectTransform>();
+        mHorizontal = mScroll.horizontal;
+
+        SR_size = mScroll.transform.GetComponent<RectTransform>().rect.size;
+
+        //四角坐标  横着数  
+        conners[0] = new Vector3(-SR_size.x / 2f, SR_size.y / 2f, 0);
+        conners[1] = new Vector3(SR_size.x / 2f, SR_size.y / 2f, 0);
+        conners[2] = new Vector3(-SR_size.x / 2f, -SR_size.y / 2f, 0);
+        conners[3] = new Vector3(SR_size.x / 2f, -SR_size.y / 2f, 0);
+
+
+        //将四角坐标转化为绝对的坐标值
+        for (int i = 0; i < 4; i++)
+        {
+            Vector3 temp = mScroll.transform.TransformPoint(conners[i]);
+            conners[i].x = temp.x;
+            conners[i].y = temp.y;
+        }
+
+        mRTrans.pivot = new Vector2(0, 1);//设置mRTrans的中心在左上角  
+        mScroll.onValueChanged.AddListener(delegate { WrapContent(); });//添加滚动事件回调  
+        startPos = this.transform.localPosition;
+    }
+
+
+    /// <summary>  
+    /// ScrollRect复位(比如:重新进入该页面时)
+    /// </summary>  
+    public void ResetPosition()
+    {
+        this.transform.localPosition = startPos;
+    }
+
+
+
+    [ContextMenu("ResetToInit")]
+    public void ResetToInit()
+    {
+        ResetPosition();
+        Init();
+        InitList(minIndex, maxCount);
+    }
+
+
+
+    /// <summary>  
+    /// 初始化mChild链表  
+    /// </summary>  
+    /// 
+    public void InitList(int minIndex, int maxIndex)
+    {
+        isHandEatup = false;
+        this.minIndex = minIndex;
+        this.maxCount = maxIndex;
+
+        //如果横排数量为0,则设置默认为1,避免手误
+        if (ConstraintCount <= 0)
+        {
+            ConstraintCount = 1;
+        }
+
+        //如果最小索引大于了最大索引,则让他俩相等,避免手误
+        if (this.minIndex > this.maxCount)
+        {
+            this.minIndex = this.maxCount;
+        }
+
+        //Init();
+
+        ChildList.Clear();
+        for (int i = 0; i < transform.childCount; i++)
+        {
+            ChildList.Add(this.transform.GetChild(i));
+        }
+
+        for (int j = 0; j < ChildList.Count; j++)
+        {
+            Transform temp = ChildList[j];
+            RectTransform trf = temp as RectTransform;
+            trf.anchorMax = new Vector2(0, 1);
+            trf.anchorMin = new Vector2(0, 1);
+            trf.pivot = pivotChildFactor;
+            trf.anchoredPosition3D = Vector3.zero;
+        }
+        ResetChildPosition();
+    }
+
+
+    /// <summary>
+    /// 更新最大索引数
+    /// </summary>
+    /// <param name="minIndex"></param>
+    /// <param name="maxIndex"></param>
+    public void UpdateCount(int minIndex, int maxIndex)
+    {
+        this.minIndex = minIndex;
+        this.maxCount = maxIndex;
+        isHandEatup = false;
+    }
+
+
+    void ResetChildPosition()
+    {
+        ///行数       列数
+        int rows = 1, cols = 1;
+
+        //初始位置
+        Vector2 startAxis = new Vector2((cell_x / 2f) + leftOffset, (-cell_y / 2f) - topOffset);
+
+        if (arrangeType == ArrangeType.Horizontal)
+        {
+            rows = ConstraintCount;
+            cols = (int)Mathf.Ceil((float)ChildList.Count / rows);
+            //(所有子物体宽度的总和 + 所有间距的总和 + 左偏移量 + 右偏移量)/2
+            extents = ((cols * cell_x) + (XSpacing * (cols - 1) + leftOffset + rightOffset)) * 0.5f;
+        }
+        else if (arrangeType == ArrangeType.Vertical)
+        {
+            cols = ConstraintCount;
+            rows = (int)Mathf.Ceil((float)ChildList.Count / (float)cols);
+            //(所有子物体高度的总和 + 所有间距的总和 + 上偏移量 + 下偏移量)/2
+            extents = ((rows * cell_y) + (YSpacing * (rows - 1) + topOffset + bottomOffset)) * 0.5f;
+        }
+
+
+        ///初始为所有子物体排列布局
+        for (int i = 0; i < ChildList.Count; i++)
+        {
+            Transform temp = ChildList[i];
+            RectTransform trf = temp as RectTransform;
+            trf.anchorMax = new Vector2(0, 1);
+            trf.anchorMin = new Vector2(0, 1);
+            trf.pivot = pivotChildFactor;
+            trf.anchoredPosition3D = Vector3.zero;
+
+            int x = 0, y = 0;//行列号  
+            Vector2 pos = Vector2.zero;
+            if (arrangeType == ArrangeType.Vertical)
+            {
+                x = i / cols; //(行号:0 -1 - 2 - 3 - 4...)
+                y = i % cols;//(列号:0 - 1 - 0 - 1...)
+                pos = new Vector2((startAxis.x + y * cell_x) + y * XSpacing, (startAxis.y - x * cell_y) - (x * YSpacing));
+            }
+
+            else if (arrangeType == ArrangeType.Horizontal)
+            {
+                x = i % rows;//行号:0 - 1 - 0 - 1...
+                y = i / rows;//列号:0 -1 - 2 - 3 - 4...
+                pos = new Vector2((startAxis.x + y * cell_x) + y * XSpacing, (startAxis.y - x * cell_y) - (x * YSpacing));
+            }
+
+            temp.localPosition = pos;
+            if (minIndex == maxCount || (i >= minIndex && i < maxCount))
+            {
+                temp.gameObject.SetActive(true);
+                UpdateRectsize(pos);//更新panel的尺寸  
+                UpdateItem(temp, i, i);
+                temp.name = i.ToString();
+            }
+            else
+            {
+                temp.gameObject.SetActive(false);
+            }
+        }
+    }
+
+
+    /// <summary>  
+    /// 更新Content的尺寸  
+    /// </summary>  
+    /// <param name="pos"></param>  
+    void UpdateRectsize(Vector2 pos)
+    {
+        if (arrangeType == ArrangeType.Horizontal)
+        {
+            mRTrans.sizeDelta = new Vector2(pos.x + cell_x * 0.5f + rightOffset, ConstraintCount * cell_y + (ConstraintCount - 1) * YSpacing + topOffset + bottomOffset);
+        }
+        else
+        {
+            mRTrans.sizeDelta = new Vector2(ConstraintCount * cell_x + (ConstraintCount - 1) * XSpacing + leftOffset + rightOffset
+                , -pos.y + cell_y * 0.5f + bottomOffset);
+        }
+    }
+
+
+
+
+    /// <summary>
+    /// ScrollRect的回调  
+    /// </summary>
+    public void WrapContent(bool isRefresh = false)
+    {
+        for (int i = 0; i < ChildList.Count; i++)
+        {
+            Transform temp = ChildList[i];
+            bool isRefreshRect = false;
+            Vector2 pos = GetChildPos(temp, out isRefreshRect);
+            int realIndex = GetRealIndex(pos);
+
+            if (minIndex == maxCount || (realIndex >= minIndex && realIndex < maxCount))
+            {
+                temp.gameObject.SetActive(true);
+                if (isRefreshRect)
+                {
+                    //Debug.Log("是否需要刷新");
+                    UpdateRectsize(pos);
+                }
+
+                temp.localPosition = pos;
+                if (temp.name != realIndex.ToString())
+                {
+                    //设置Item内容  
+                    UpdateItem(temp, i, realIndex);
+                    temp.name = realIndex.ToString();
+                }
+                else if (temp.name == realIndex.ToString() && isRefresh)
+                {
+                    //设置Item内容  
+                    UpdateItem(temp, i, realIndex);
+                    temp.name = realIndex.ToString();
+                }
+            }
+            else if (realIndex >= maxCount)
+            {
+                if (!isHandEatup)
+                {
+                    Debug.Log("WrapContent===>数据已用完");
+                    //通知所有要显示的数据已用完
+                    if (onEatUpItem != null)
+                    {
+                        onEatUpItem();
+                    }
+                    isHandEatup = true;
+                }
+                return;
+            }
+        }
+    }
+
+
+
+    /// <summary>
+    /// 获取子物体的位置
+    /// </summary>
+    /// <param name="temp"></param>
+    /// <param name="isRefreshRect"></param>
+    /// <returns></returns>
+    Vector2 GetChildPos(Transform temp, out bool isRefreshRect)
+    {
+        isRefreshRect = false;
+        Vector3[] conner_local = new Vector3[4];
+        for (int i = 0; i < 4; i++)
+        {
+            conner_local[i] = this.transform.InverseTransformPoint(conners[i]);
+        }
+        //计算ScrollRect的中心坐标 相对于this的坐标  
+        Vector2 center = (conner_local[3] + conner_local[0]) / 2f;
+        Vector2 pos = Vector2.zero;
+        if (mHorizontal)
+        {
+            float distance = temp.localPosition.x - center.x;
+            pos = temp.localPosition;
+            if (distance < -extents)
+            {
+                isRefreshRect = true;
+                pos.x += extents * 2f - leftOffset - rightOffset + XSpacing;
+            }
+            else if (distance > extents)
+            {
+                pos.x -= extents * 2f - leftOffset - rightOffset + XSpacing;
+            }
+        }
+        else
+        {
+            if (temp != null)
+            {
+                float distance = temp.localPosition.y - center.y;
+                pos = temp.localPosition;
+                if (distance < -extents)
+                {
+                    pos.y += extents * 2f - bottomOffset - topOffset + YSpacing;
+                }
+                else if (distance > extents)
+                {
+                    isRefreshRect = true;
+                    pos.y -= extents * 2f - bottomOffset - topOffset + YSpacing;
+                }
+            }
+        }
+        return pos;
+    }
+
+
+
+    /// <summary>
+    /// 计算realIndex
+    /// </summary>
+    /// <param name="pos"></param>
+    /// <returns></returns>
+    private int GetRealIndex(Vector2 pos)
+    {
+        int x = (int)Mathf.Ceil((-pos.y - topOffset + YSpacing) / (cell_y + YSpacing)) - 1;
+        int y = (int)Mathf.Ceil((pos.x - leftOffset + XSpacing) / (cell_x + XSpacing)) - 1;
+
+        //int x = (int)Mathf.Ceil(-pos.y / cell_y) - 1;//行号  
+        //int y = (int)Mathf.Ceil(pos.x / cell_x) - 1;//列号  
+        int realIndex;
+        if (arrangeType == ArrangeType.Vertical)
+        {
+            realIndex = x * ConstraintCount + y;
+        }
+        else
+        {
+            realIndex = x + ConstraintCount * y;
+        }
+
+        return realIndex;
+    }
+
+
+    /// <summary>
+    /// 通知更新Item的数据
+    /// </summary>
+    /// <param name="item"></param>
+    /// <param name="index"></param>
+    /// <param name="realIndex"></param>
+    void UpdateItem(Transform item, int index, int realIndex)
+    {
+        if (onUpdateItem != null)
+        {
+            onUpdateItem(item.gameObject, index, realIndex);
+        }
+    }
+}

+ 11 - 0
Assets/HotUpdate/Tools/UIScrollScript.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 15e5c8fd25cbf5c4b889b2de07e11e22
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 8
Assets/StreamingAssets/TrackingProfiles.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: e21314d15ba4f8549958899eada01c01
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: