SlideList.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. using SC.XR.Unity;
  2. using SC.XR.Unity.Module_InputSystem;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.EventSystems;
  8. public class SlideList : BaseList, IDragHandler, IPointerEnterHandler, IPointerExitHandler, IPointerUpHandler, IPointerDownHandler
  9. {
  10. [HideInInspector]
  11. private List<Vector3> posList;
  12. public float rowSpacing;
  13. public float columnSpacing;
  14. [HideInInspector]
  15. private int maxRow;
  16. [HideInInspector]
  17. private int maxColumn;
  18. [HideInInspector]
  19. private float maxRowSpacing;
  20. [HideInInspector]
  21. private float maxColumnSpacing;
  22. [HideInInspector]
  23. private int startItem = 0;
  24. [HideInInspector]
  25. private int endItem = 0;
  26. public SCSlider3D slider3D;
  27. public bool isSlideX=false;
  28. public override void initList(List<BaseConfig> configs)
  29. {
  30. startItem = 0;
  31. endItem = Row * Column;
  32. posList = new List<Vector3>();
  33. base.initList(configs);
  34. for (int i = 0; i < Views.Count; i++)
  35. {
  36. Views[i].transform.localPosition = new Vector3(((i) % Row) * rowSpacing, -((i) / Row) * columnSpacing, 0);
  37. posList.Add(Views[i].transform.localPosition);
  38. }
  39. maxRow = (Views.Count - 1) / Row + 1;
  40. maxColumn = (Views.Count - 1) / Column + 1;
  41. maxRowSpacing = ((maxColumn - 1) * rowSpacing + (rowSpacing / 2));
  42. maxColumnSpacing = ((maxRow - 1) * columnSpacing + (columnSpacing / 2));
  43. // StartCoroutine(moveCoroutine());
  44. slider3D.onValueChanged.AddListener(valueChanged);
  45. }
  46. private void valueChanged(float arg0)
  47. {
  48. setProgress(arg0);
  49. }
  50. bool checkColumnMax(int i, int r)
  51. {
  52. if ((((i) / this.Row) + 1) == r)
  53. {
  54. return true;
  55. }
  56. else
  57. {
  58. return false;
  59. }
  60. }
  61. List<Vector3> v3;
  62. void MoveItem(float f, bool ischange = true)
  63. {
  64. if (isSlideX)
  65. {
  66. if (Mathf.Abs(f) > rowSpacing)
  67. {
  68. if (f > 0)
  69. {
  70. f = rowSpacing * 0.9f;
  71. }
  72. else
  73. {
  74. f = -rowSpacing * 0.9f;
  75. }
  76. }
  77. }
  78. else
  79. {
  80. if (Mathf.Abs(f) > columnSpacing)
  81. {
  82. if (f > 0)
  83. {
  84. f = columnSpacing * 0.9f;
  85. }
  86. else
  87. {
  88. f = -columnSpacing * 0.9f;
  89. }
  90. }
  91. }
  92. v3 = new List<Vector3>();
  93. for (int j = 0; j < Views.Count; j++)
  94. {
  95. v3.Add(Views[j].transform.localPosition);
  96. }
  97. bool isDown = false;
  98. bool isUp = false;
  99. List<int> listIndex = new List<int>(); ;
  100. float downf = 0;
  101. float upf = 0;
  102. // bool isshow =
  103. for (int i = 0; i < Views.Count; i++)
  104. {
  105. if (isSlideX)
  106. {
  107. Views[i].transform.localPosition = new Vector3(Views[i].transform.localPosition.x - f, Views[i].transform.localPosition.y , Views[i].transform.localPosition.z);
  108. }else
  109. {
  110. Views[i].transform.localPosition = new Vector3(Views[i].transform.localPosition.x, Views[i].transform.localPosition.y - f, Views[i].transform.localPosition.z);
  111. }
  112. int type = checkBorder(i);
  113. switch (type)
  114. {
  115. //下边界
  116. case 1:
  117. if (isSlideX)
  118. {
  119. isDown = true;
  120. Views[i].gameObject.SetActive(false);
  121. Views[i].isShow = false;
  122. // upf = Views[i].transform.localPosition.x + rowSpacing / 2f;
  123. showPretRow(i);
  124. }
  125. else
  126. {
  127. isDown = true;
  128. Views[i].gameObject.SetActive(false);
  129. Views[i].isShow = false;
  130. // upf = Views[i].transform.localPosition.y - columnSpacing / 2f;
  131. showPretRow(i);
  132. }
  133. break;
  134. //上边界
  135. case 2:
  136. if (isSlideX)
  137. {
  138. isUp = true;
  139. Views[i].gameObject.SetActive(false);
  140. Views[i].isShow = false;
  141. // downf = -Views[i].transform.localPosition.x + maxRowSpacing;
  142. showNextRow(i);
  143. }
  144. else
  145. {
  146. isUp = true;
  147. Views[i].gameObject.SetActive(false);
  148. Views[i].isShow = false;
  149. // downf = -Views[i].transform.localPosition.y - maxColumnSpacing;
  150. showNextRow(i);
  151. }
  152. break;
  153. case 0:
  154. // showItem(i);
  155. Views[i].isShow = true;
  156. Views[i].gameObject.SetActive(true);
  157. break;
  158. }
  159. }
  160. // Debug.Log("移动"+f);
  161. if (isDown)
  162. {
  163. if (isSlideX)
  164. {
  165. changeList(false, Column);
  166. changeRCount(rCount - 1);
  167. MoveItem(downf);
  168. }else
  169. {
  170. changeList(false, Row);
  171. changeRCount(rCount - 1);
  172. MoveItem(downf);
  173. }
  174. }
  175. else if (isUp)
  176. {
  177. if (isSlideX)
  178. {
  179. changeList(true, Column);
  180. changeRCount(rCount + 1);
  181. MoveItem(upf);
  182. }
  183. else
  184. {
  185. changeList(true, Row);
  186. changeRCount(rCount + 1);
  187. MoveItem(upf);
  188. }
  189. }
  190. if (isSlideX)
  191. {
  192. showItems(startItem + Column * rCount, endItem + Column * rCount);
  193. }else
  194. {
  195. showItems(startItem + Row * rCount, endItem + Row * rCount);
  196. }
  197. }
  198. void changeList(bool isADD, int chaRow)
  199. {
  200. if(isSlideX)
  201. {
  202. if (isADD)
  203. {
  204. List<int> addIndexA = new List<int>();
  205. List<int> addIndexB = new List<int>();
  206. List<BaseView> bv = new List<BaseView>();
  207. for (int i = 0; i < Views.Count; i++)
  208. {
  209. if (i % Row == 0)
  210. {
  211. addIndexB.Add(i);
  212. }
  213. else
  214. {
  215. bv.Add(Views[i]);
  216. }
  217. }
  218. // Debug.Log("更换前的位置");
  219. for (int i = 0; i < Views.Count; i++)
  220. {
  221. // Debug.Log("View==》" + i + "==>" + Views[i].Index);
  222. }
  223. List<BaseView> bv3 = new List<BaseView>();
  224. for (int i = 0; i < chaRow; i++)
  225. {
  226. bv3.Add(Views[addIndexB[i]]);
  227. }
  228. int b3Ct = 0;
  229. for (int i = 0; i < Views.Count; i++)
  230. {
  231. if (i % Row == (Row-1))
  232. {
  233. bv.Insert(i , bv3[b3Ct]);
  234. b3Ct++;
  235. }
  236. }
  237. Views = bv;
  238. // Debug.Log("更换后的位置");
  239. for (int i = 0; i < Views.Count; i++)
  240. {
  241. // Debug.Log("View==》" + i + "==>" + Views[i].Index);
  242. }
  243. }
  244. else
  245. {
  246. List<int> addIndexA = new List<int>();
  247. List<BaseView> bv = new List<BaseView>();
  248. for (int i = 0; i < Views.Count; i++)
  249. {
  250. if (i % Row == (Row-1))
  251. {
  252. addIndexA.Add(i);
  253. }else
  254. {
  255. bv.Add(Views[i]);
  256. }
  257. }
  258. // Debug.Log("更换前的位置");
  259. for (int i = 0; i < Views.Count; i++)
  260. {
  261. // Debug.Log("View==》" + i + "==>" + Views[i].Index);
  262. }
  263. List<BaseView> bv2 = new List<BaseView>();
  264. List<BaseView> bv3 = new List<BaseView>();
  265. for (int i = 0; i < chaRow; i++)
  266. {
  267. bv2.Add(Views[addIndexA[i]]);
  268. }
  269. int b3Ct = 0;
  270. for (int i = 0; i < Views.Count; i++)
  271. {
  272. if (i % Row == 0)
  273. {
  274. bv.Insert(i , bv2[b3Ct]);
  275. b3Ct++;
  276. }
  277. }
  278. Views = bv;
  279. // Debug.Log("更换后的位置");
  280. for (int i = 0; i < Views.Count; i++)
  281. {
  282. // Debug.Log("View==》"+i+"==>"+Views[i].Index);
  283. }
  284. }
  285. }else
  286. {
  287. if (isADD)
  288. {
  289. for (int i = 0; i < chaRow; i++)
  290. {
  291. Views.Add(Views[i]);
  292. }
  293. for (int i = 0; i < chaRow; i++)
  294. {
  295. Views.RemoveAt(0);
  296. }
  297. }
  298. else
  299. {
  300. for (int i = 0; i < chaRow; i++)
  301. {
  302. Views.Insert(i, Views[Views.Count - chaRow + i]);
  303. }
  304. for (int i = 0; i < chaRow; i++)
  305. {
  306. Views.RemoveAt(Views.Count - 1);
  307. }
  308. }
  309. }
  310. }
  311. int RowCount = 0;
  312. //显示下一行
  313. void showNextRow(int i)
  314. {
  315. if (isSlideX)
  316. {
  317. int zuxiao = 0;
  318. float max = -999999;
  319. for (int j = 0; j < Views.Count; j++)
  320. {
  321. if (max < v3[j].x)
  322. {
  323. max = v3[j].x;
  324. zuxiao = j;
  325. }
  326. }
  327. // Debug.Log(i + "移动到最大的" + zuxiao + "坐标==》" + (max + rowSpacing));
  328. Views[i].transform.localPosition = new Vector3(max + rowSpacing, Views[i].transform.localPosition.y, Views[i].transform.localPosition.z);
  329. }
  330. else
  331. {
  332. float max = 999999;
  333. for (int j = 0; j < Views.Count; j++)
  334. {
  335. if (max > v3[j].y)
  336. {
  337. max = v3[j].y;
  338. }
  339. }
  340. Views[i].transform.localPosition = new Vector3(Views[i].transform.localPosition.x, max - columnSpacing, Views[i].transform.localPosition.z);
  341. }
  342. }
  343. //显示上一行
  344. void showPretRow(int i)
  345. {
  346. if (isSlideX)
  347. {
  348. int zuxiao=0;
  349. float min = 999999;
  350. for (int j = 0; j < Views.Count; j++)
  351. {
  352. if (min > v3[j].x)
  353. {
  354. min = v3[j].x;
  355. zuxiao = j;
  356. }
  357. }
  358. // Debug.Log(i+"移动到最小的"+ zuxiao+"坐标==》"+ (min + rowSpacing));
  359. // min= 0 + (0 - v3[0].y)+ columnSpacing;
  360. Views[i].transform.localPosition = new Vector3(min - rowSpacing, Views[i].transform.localPosition.y, Views[i].transform.localPosition.z);
  361. }
  362. else
  363. {
  364. float min = -999999;
  365. for (int j = 0; j < Views.Count; j++)
  366. {
  367. if (min < v3[j].y)
  368. {
  369. min = v3[j].y;
  370. }
  371. }
  372. // min= 0 + (0 - v3[0].y)+ columnSpacing;
  373. Views[i].transform.localPosition = new Vector3(Views[i].transform.localPosition.x, min + columnSpacing, Views[i].transform.localPosition.z);
  374. }
  375. }
  376. //判断是否超出边界
  377. int checkBorder(int i)
  378. {
  379. if (isSlideX)
  380. {
  381. if (Views[i].transform.localPosition.x > maxRowSpacing)
  382. {
  383. // Debug.Log(i + "x坐标=1=》" + Views[i].transform.localPosition.x);
  384. return 1;
  385. }
  386. else if (Views[i].transform.localPosition.x < -(rowSpacing / 2f))
  387. {
  388. // Debug.Log(i+"x坐标=2=》"+ Views[i].transform.localPosition.x);
  389. return 2;
  390. }
  391. else
  392. {
  393. return 0;
  394. }
  395. }
  396. else
  397. {
  398. if (-Views[i].transform.localPosition.y > maxColumnSpacing)
  399. {
  400. return 1;
  401. }
  402. else if (Views[i].transform.localPosition.y > (columnSpacing / 2f))
  403. {
  404. return 2;
  405. }
  406. else
  407. {
  408. return 0;
  409. }
  410. }
  411. }
  412. private Vector3 startPos;
  413. private Vector3 startItemPos;
  414. private float TimeDrag = 0;
  415. private Vector3 DragPos;
  416. private float dragFloat;
  417. private float jiasudu;
  418. private float speedTime = 0;
  419. private bool isJiasudu = false;
  420. private float oldNum = 0;
  421. public virtual void OnDrag(PointerEventData eventData)
  422. {
  423. SCPointEventData sCPointEventData = eventData as SCPointEventData;
  424. float num = 0;
  425. Vector3 pos3D = this.transform.TransformPoint(sCPointEventData.Position3D) / this.transform.localScale.x;
  426. if (isSlideX)
  427. {
  428. Vector3 a= GSXRManager.Instance.leftCamera.WorldToScreenPoint(startScreenV3);
  429. Vector3 b = GSXRManager.Instance.leftCamera.WorldToScreenPoint(sCPointEventData.Position3D);
  430. // pos3D = sCPointEventData.Position3D / this.transform.localScale.x;
  431. num = (startPos.x - pos3D.x);
  432. num = Vector3.Cross(this.transform.forward, pos3D).y - oldNum;
  433. num = (a - b).x;
  434. oldNum = Vector3.Cross(this.transform.forward, pos3D).y;
  435. }
  436. else
  437. {
  438. num = (startPos.y - pos3D.y) * 5;
  439. }
  440. //Debug.Log("num====>"+num);
  441. startPos = pos3D;
  442. startScreenV3 = sCPointEventData.Position3D;
  443. TimeDrag = TimeDrag + Time.deltaTime;
  444. if (TimeDrag > 1f)
  445. {
  446. DragPos = pos3D;
  447. TimeDrag = 0;
  448. }
  449. int hz = ((maxRowItemCount - Column));
  450. float cdz = columnSpacing * hz;
  451. float Prog = 0;
  452. if (isSlideX)
  453. {
  454. Prog = getValue() + (num / hz)/100;
  455. } else
  456. {
  457. Prog = getValue() + (num / hz) * 2;
  458. }
  459. if (Prog > 0)
  460. {
  461. if (isSlideX)
  462. {
  463. changeValue(Prog);
  464. }
  465. else
  466. {
  467. changeValue(Prog);
  468. }
  469. }
  470. speedTime = speedTime + Time.deltaTime;
  471. if (speedTime > 0.3f)
  472. {
  473. speedTime = 0;
  474. jiasudu = 0;
  475. }
  476. else
  477. {
  478. if (isSlideX)
  479. {
  480. jiasudu = jiasudu + (num / hz) /100;
  481. }else
  482. {
  483. jiasudu = jiasudu + (num / hz) * 2;
  484. }
  485. }
  486. //float a = float.Parse(num.ToString("F2"));
  487. // Debug.Log("");
  488. // if((num / 2))
  489. }
  490. private Vector3 startScreenV3;
  491. public virtual void OnPointerDown(PointerEventData eventData)
  492. {
  493. SCPointEventData sCPointEventData = eventData as SCPointEventData;
  494. startPos = this.transform.TransformPoint(sCPointEventData.Position3D)/this.transform.localScale.x;
  495. startScreenV3 = sCPointEventData.Position3D;
  496. startItemPos = this.transform.localPosition;
  497. DragPos = sCPointEventData.Position3D;
  498. // MoveItem(1f);
  499. }
  500. public virtual void OnPointerEnter(PointerEventData eventData)
  501. {
  502. }
  503. public virtual void OnPointerExit(PointerEventData eventData)
  504. {
  505. }
  506. public virtual void OnPointerUp(PointerEventData eventData)
  507. {
  508. SCPointEventData sCPointEventData = eventData as SCPointEventData;
  509. if(isSlideX)
  510. {
  511. dragFloat = (DragPos.x - this.transform.TransformPoint(sCPointEventData.Position3D).x);
  512. }
  513. else
  514. {
  515. dragFloat = (DragPos.y - this.transform.TransformPoint(sCPointEventData.Position3D).y);
  516. }
  517. if (jiasudu != 0)
  518. isJiasudu = true;
  519. // MoveUpEnd();
  520. }
  521. void changeRCount(int count)
  522. {
  523. rCount = count;
  524. }
  525. public virtual void Update()
  526. {
  527. if (isJiasudu)
  528. {
  529. speedTime = speedTime + Time.deltaTime;
  530. if (speedTime > 2)
  531. {
  532. speedTime = 0;
  533. isJiasudu = false;
  534. // fixedItems();
  535. }
  536. jiasudu = jiasudu / 1.05f;
  537. // if (Mathf.Abs(-jiasudu / 2) <= 0.1f)
  538. // {
  539. // speedTime = 0;
  540. // isJiasudu = false;
  541. // fixedItems();
  542. // }
  543. changeValue((jiasudu+getValue()));
  544. // MoveItem(-jiasudu / 3);
  545. }
  546. }
  547. private void changeMaxRowItemCount()
  548. {
  549. maxRowItemCount = ((this.configs.Count - 1) / Row + 1);
  550. }
  551. private void changeMaxColumnItemCount()
  552. {
  553. maxColumItemCount = ((this.configs.Count-1) / Column + 1);
  554. }
  555. public override void updateConfig(List<BaseConfig> c)
  556. {
  557. if(isSlideX)
  558. {
  559. if (this.configs.Count < c.Count)
  560. {
  561. configs = new List<BaseConfig>();
  562. c.ForEach(i => configs.Add(i));
  563. changeMaxColumnItemCount();
  564. if (((Row * Column) > (Row * maxColumItemCount)))
  565. {
  566. changeValue(0);
  567. setProgress(0);
  568. }
  569. else
  570. {
  571. changeValue(1);
  572. setProgress(1);
  573. }
  574. }
  575. else if (Row * rCount > (Row * maxColumItemCount - Row * Column + 1) && (Row * Column < Row * maxColumItemCount))
  576. {
  577. configs = new List<BaseConfig>();
  578. c.ForEach(i => configs.Add(i));
  579. changeMaxColumnItemCount();
  580. changeValue(1);
  581. setProgress(1);
  582. }
  583. else
  584. {
  585. configs = new List<BaseConfig>();
  586. c.ForEach(i => configs.Add(i));
  587. changeMaxColumnItemCount();
  588. showItems(startItem + Column * rCount, endItem + Column * rCount, true);
  589. }
  590. }
  591. else
  592. {
  593. if (this.configs.Count < c.Count)
  594. {
  595. configs = new List<BaseConfig>();
  596. c.ForEach(i => configs.Add(i));
  597. changeMaxRowItemCount();
  598. if (((Row * Column) > (Row * maxRowItemCount)))
  599. {
  600. changeValue(0);
  601. setProgress(0);
  602. }
  603. else
  604. {
  605. changeValue(1);
  606. setProgress(1);
  607. }
  608. }
  609. else if (Row * rCount > (Row * maxRowItemCount - Row * Column + 1) && (Row * Column < Row * maxRowItemCount))
  610. {
  611. configs = new List<BaseConfig>();
  612. c.ForEach(i => configs.Add(i));
  613. changeMaxRowItemCount();
  614. changeValue(1);
  615. setProgress(1);
  616. }
  617. else
  618. {
  619. configs = new List<BaseConfig>();
  620. c.ForEach(i => configs.Add(i));
  621. changeMaxRowItemCount();
  622. showItems(startItem + Row * rCount, endItem + Row * rCount, true);
  623. }
  624. }
  625. }
  626. private bool checkRCount(int r)
  627. {
  628. return r == rCount;
  629. }
  630. public virtual float getProgress()
  631. {
  632. if (isSlideX)
  633. {
  634. int hm = ((rCount));
  635. int hz = ((maxColumItemCount - Row));
  636. float cdm = (rowSpacing) * hm + (0 - Views[0].transform.localPosition.x);
  637. float cdz = rowSpacing * hz;
  638. if (cdz == 0)
  639. {
  640. return -1;
  641. }
  642. float proNum = cdm / cdz;
  643. return proNum;
  644. }else
  645. {
  646. int hm = ((rCount));
  647. int hz = ((maxRowItemCount - Column));
  648. float cdm = (columnSpacing) * hm - (0 - Views[0].transform.localPosition.y);
  649. float cdz = columnSpacing * hz;
  650. if (cdz == 0)
  651. {
  652. return -1;
  653. }
  654. float proNum = cdm / cdz;
  655. return proNum;
  656. }
  657. }
  658. // private float
  659. public virtual void setProgress(float proNum)
  660. {
  661. if (isSlideX)
  662. {
  663. float p = getProgress();
  664. int hz = ((maxColumItemCount - Row));
  665. float cdz = rowSpacing * hz;
  666. int hm = ((rCount));
  667. float cdm = (rowSpacing) * hm + (0 - Views[0].transform.localPosition.x);
  668. float xNum = cdm;
  669. float fNum = cdz * proNum;
  670. if ((Math.Abs(fNum - xNum)) < rowSpacing)
  671. {
  672. MoveItem((fNum - xNum), false);
  673. cdm = (rowSpacing) * hm + (0 - Views[0].transform.localPosition.x);
  674. }
  675. else
  676. {
  677. //fNum = hz * proNum;
  678. int iNum = (int)(fNum / rowSpacing);
  679. float a = (fNum / rowSpacing);
  680. float b = (a-iNum) * rowSpacing;
  681. int Rc = rCount;
  682. if (!checkRCount(iNum))
  683. {
  684. showItems(startItem + iNum, endItem + iNum, true);
  685. changeRCount(iNum);
  686. }
  687. hm = (Column * (rCount));
  688. fNum = cdz * proNum;
  689. cdm = (rowSpacing) * hm + (0 - Views[0].transform.localPosition.x);
  690. xNum = cdm;
  691. MoveItem((b), false);
  692. }
  693. }
  694. else
  695. {
  696. float p = getProgress();
  697. int hz = ((maxRowItemCount - Column));
  698. float cdz = columnSpacing * hz;
  699. int hm = ((rCount));
  700. float cdm = (columnSpacing) * hm - (0 - Views[0].transform.localPosition.y);
  701. float xNum = cdm;
  702. float fNum = cdz * proNum;
  703. /*
  704. Debug.Log("预期比值==》" + ((fNum - xNum) + xNum) / cdz);
  705. Debug.Log("总长度==》" + cdz);
  706. Debug.Log("现有比值==》" + p);
  707. Debug.Log("将要变的比值==》" + proNum);
  708. Debug.Log("将要变的长度==》" + fNum);
  709. Debug.Log("现有的长度==》" + xNum);
  710. Debug.Log("需要移动==》" + (fNum - xNum));*/
  711. if ((Math.Abs(fNum - xNum)) < columnSpacing)
  712. {
  713. MoveItem(-(fNum - xNum), false);
  714. cdm = (columnSpacing) * hm - (0 - Views[0].transform.localPosition.y);/*
  715. Debug.Log("更改后的需要移动==》" + (fNum - cdm));
  716. Debug.Log("更改后的现有长度==》" + cdm);
  717. Debug.Log("更改后的比值==》" + getProgress());*/
  718. }
  719. else
  720. {
  721. //fNum = hz * proNum;
  722. int iNum = (int)(fNum / columnSpacing);
  723. float a = (fNum / columnSpacing);
  724. float b = (a - iNum) * columnSpacing;
  725. /* Debug.Log("移动的时候需要在==》" + iNum);
  726. Debug.Log("滚动后的差值==》" + b);*/
  727. int Rc = rCount;
  728. if (!checkRCount(iNum))
  729. {
  730. showItems(startItem + iNum, endItem + iNum, true);
  731. changeRCount(iNum);
  732. }
  733. hm = (Row * (rCount));
  734. fNum = cdz * proNum;
  735. cdm = (columnSpacing) * hm - (0 - Views[0].transform.localPosition.y);
  736. xNum = cdm;
  737. MoveItem(-(b), false);
  738. /* Debug.Log("更改后的需要移动==》" + (fNum - cdm));
  739. Debug.Log("更改后的现有长度==》" + cdm);
  740. Debug.Log("更改后的比值==》" + getProgress());*/
  741. }
  742. }
  743. }
  744. void changeValue(float f)
  745. {
  746. slider3D.value = f;
  747. }
  748. float getValue()
  749. {
  750. return slider3D.value ;
  751. }
  752. }