MenuUI.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. using DG.Tweening;
  2. using SC.XR.Unity.Module_InputSystem;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.EventSystems;
  7. using UnityEngine.UI;
  8. using SC.XR.Unity;
  9. using XRTool.Util;
  10. using SC.XR.Unity.Module_InputSystem.InputDeviceHead;
  11. public class MenuUI : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
  12. {
  13. Transform _pointParent;//曲线控制点父物体
  14. List<Transform> _anchorPointGroup = new List<Transform>();//曲线控制点集合
  15. Transform _menuParent;//菜单元素父物体
  16. List<Transform> _menuElementGroup = new List<Transform>();//菜单元素集合
  17. List<MenuIcon> _elementDataGroup = new List<MenuIcon>();//元素数据集合。菜单元素集合与元素数据集合始终保持一 一对应的关系(在集合中的位置)
  18. int _preMidIndex;//元素集合中间索引的上一个索引
  19. int _middleIndex;//元素集合中间索引
  20. int _nextMidIndex;//元素集合中间索引的下一个索引
  21. int _segmentNum;//所需贝塞尔曲线点连接的段数(点的数量减一)
  22. public Dictionary<int, Vector3> _bezierPointGroup = new Dictionary<int, Vector3>();//记录所需贝塞尔曲线定位点的集合
  23. Vector3[] _velocityGroup;//从一点到另一点的最大速度集合
  24. float _spacingTime = 0.2f;//从一点到另一点的最短时间(用于计算预设的最大速度)
  25. bool _isInLeft = false;//图标是否开始真正往左串位
  26. bool _isInRight = false;//图标是否开始真正往右串位
  27. float _maxDragValue = 100f;//拖动时,x坐标的预设增量基数
  28. Vector3 _normalScale;//正常的缩放值
  29. Vector3 _targetScale;//预设的目标放大值
  30. float _scaleFactor = 1.4f;//缩放系数
  31. bool _isOver = false;//链表中数据是否读取完
  32. bool _isClickDel = false;//是否点击了删除按钮
  33. bool _isInit = false;//是否初始化完毕
  34. /// <summary>
  35. /// 初始化
  36. /// </summary>
  37. public void Init()
  38. {
  39. _pointParent = transform.Find("AnchorPoint");
  40. _menuParent = transform.Find("Element");
  41. LoadAnchorPoint();
  42. LoadGameObject();
  43. _segmentNum = _menuElementGroup.Count + 1;
  44. _velocityGroup = new Vector3[_segmentNum];
  45. _normalScale = _menuElementGroup[0].localScale;
  46. _targetScale = _normalScale * _scaleFactor;
  47. SaveCurvePoint();
  48. GetVelocity();
  49. DisplayMenuElement();
  50. RecordValue();
  51. EventTool._rearrange += RearrangeElements;
  52. _isInit = true;
  53. }
  54. void LoadAnchorPoint()//加载定位点
  55. {
  56. foreach (Transform item in _pointParent)
  57. {
  58. _anchorPointGroup.Add(item);
  59. }
  60. }
  61. MenuIcon _tempIcon;
  62. void LoadGameObject()//加载游戏对象和游戏对象所承载的数据
  63. {
  64. foreach (Transform item in _menuParent)
  65. {
  66. _tempIcon = item.gameObject.AddComponent<MenuIcon>();
  67. _tempIcon.Init();
  68. _menuElementGroup.Add(item);
  69. _elementDataGroup.Add(_tempIcon);
  70. }
  71. LoadData();
  72. _preMidIndex = _menuElementGroup.Count / 2 - 1;
  73. _middleIndex = _menuElementGroup.Count / 2;
  74. _nextMidIndex = _menuElementGroup.Count / 2 + 1;
  75. }
  76. /// <summary>
  77. /// 初始化加载数据
  78. /// </summary>
  79. public void LoadData()
  80. {
  81. _isOver = false;
  82. //清空数据
  83. for (int i = 0; i < _elementDataGroup.Count; i++)
  84. {
  85. _elementDataGroup[i].DataConfig = null;
  86. }
  87. DoubleLinkNode<RoomConfig> _node = ConfigModel.Instance.GetFirstMenuItem();
  88. //初始化数据
  89. for (int i = 0; i < _elementDataGroup.Count; i++)
  90. {
  91. if (!_isOver)
  92. {
  93. if (ConfigModel.Instance.GetFirstMenuItem() != null)
  94. {
  95. _elementDataGroup[i].DataConfig = _node;
  96. _node = _node.NextNode;
  97. if (_node.PreNode == ConfigModel.Instance.GetLastMenuItem())
  98. {
  99. _isOver = true;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. void GetVelocity()//求得从一点到另一点的最大速度(存入数组中)(速度方向从左指向右)
  106. {
  107. for (int i = 0; i < _velocityGroup.Length; i++)
  108. {
  109. float _dis = Vector3.Distance(_bezierPointGroup[i - 1], _bezierPointGroup[i]);
  110. _velocityGroup[i] = (_dis / _spacingTime) * (_bezierPointGroup[i] - _bezierPointGroup[i - 1]).normalized;
  111. }
  112. }
  113. void DisplayMenuElement()//刷新让元素处于对应的坐标点和缩放值
  114. {
  115. for (int i = 0; i < _menuElementGroup.Count; i++)
  116. {
  117. _menuElementGroup[i].localPosition = _bezierPointGroup[i];
  118. }
  119. if (!_isClickDel)//如果没有点击删除按钮,则中间位置元素为放大显示
  120. {
  121. //
  122. _menuElementGroup[_middleIndex].localScale = _targetScale;
  123. _menuElementGroup[_preMidIndex].localScale = _normalScale;
  124. _menuElementGroup[_nextMidIndex].localScale = _normalScale;
  125. //
  126. }
  127. }
  128. private void SaveCurvePoint()//存储贝塞尔曲线上的七个定位点位置
  129. {
  130. for (int i = -1; i < _segmentNum; i++)
  131. {
  132. float t = (i + 1) / (float)_segmentNum;
  133. int nodeIndex = 0;
  134. Vector3 pixel = CalculateBezierPoint(t, _anchorPointGroup[nodeIndex].localPosition,
  135. _anchorPointGroup[nodeIndex + 1].localPosition, _anchorPointGroup[nodeIndex + 2].localPosition);
  136. _bezierPointGroup.Add(i, pixel);
  137. }
  138. }
  139. void ResetCurvePoint()//重置贝塞尔曲线上的七个定位点
  140. {
  141. for (int i = -1; i < _segmentNum; i++)
  142. {
  143. float t = (i + 1) / (float)_segmentNum;
  144. int nodeIndex = 0;
  145. Vector3 pixel = CalculateBezierPoint(t, _anchorPointGroup[nodeIndex].localPosition,
  146. _anchorPointGroup[nodeIndex + 1].localPosition, _anchorPointGroup[nodeIndex + 2].localPosition);
  147. _bezierPointGroup[i] = pixel;
  148. }
  149. }
  150. void Update()
  151. {
  152. if (_isInit)
  153. {
  154. ResetCurvePoint();
  155. }
  156. }
  157. private Vector3 CalculateBezierPoint(float t, Vector3 p0, Vector3 p1, Vector3 p2)//根据t值计算相应曲线上的点
  158. {
  159. float u = 1 - t;
  160. float tt = t * t;
  161. float uu = u * u;
  162. Vector3 p = uu * p0;
  163. p += 2 * u * t * p1;
  164. p += tt * p2;
  165. return p;
  166. }
  167. float bx;
  168. GameObject ob;
  169. public void OnBeginDrag(PointerEventData eventData)
  170. {
  171. IsDrag(true);
  172. if(ob!=null)
  173. Destroy(ob);
  174. SCPointEventData sed = eventData as SCPointEventData;
  175. ob = new GameObject();
  176. if( DeviceType.type== "Rhinox")
  177. ob.transform.parent = sed.inputDevicePartBase.inputDevicePartUIBase.transform;
  178. else
  179. {
  180. ob.transform.parent = sed.inputDevicePartBase.transform;
  181. }
  182. ob.transform.position = (eventData as SCPointEventData).PressPosition3D;
  183. ob.transform.localEulerAngles = Vector3.zero;
  184. bx = ob.transform.localPosition.x;
  185. }
  186. public void OnDrag(PointerEventData eventData)
  187. {
  188. SCPointEventData sed = eventData as SCPointEventData;
  189. if(sed.inputDevicePartBase is InputDeviceHeadPart)
  190. {
  191. sed.inputDevicePartBase.transform.position = OpenXRCamera.Instance.head.position;
  192. sed.inputDevicePartBase.transform.eulerAngles = OpenXRCamera.Instance.head.eulerAngles;
  193. }
  194. ob.transform.position = (eventData as SCPointEventData).PressPosition3D;
  195. float ox = ob.transform.localPosition.x;
  196. // return;
  197. float _delta = (bx - ox)*100;//eventData.delta.x / _maxDragValue;//记录拖动的增量比值(用作速度比值)
  198. bx = ox;
  199. // Debug.Log("_delta===>"+_delta);
  200. if (_delta < -0.01f)//向左拖动时
  201. {
  202. // _delta = -0.5f;
  203. _isInRight = false;
  204. if (!_isInLeft)//如果没有归位到当前元素应该处于的位置上,就先让元素先移动到对应的位置上
  205. {
  206. if (_menuElementGroup[0].localPosition == _bezierPointGroup[0])
  207. {
  208. if (!_isClickDel)//如果没有点击删除按钮,则播中间位置元素为放大显示
  209. {
  210. //
  211. _menuElementGroup[_middleIndex].localScale = _targetScale;
  212. _menuElementGroup[_preMidIndex].localScale = _normalScale;
  213. //
  214. }
  215. _isInLeft = true;
  216. return;
  217. }
  218. for (int i = 0; i < _menuElementGroup.Count; i++)
  219. {
  220. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  221. {
  222. //
  223. if (i == _middleIndex)
  224. {
  225. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i + 1]) /
  226. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i + 1]);
  227. _menuElementGroup[i].localScale = Vector3.Lerp(_normalScale, _targetScale, _prop);
  228. }
  229. else if (i == _preMidIndex)
  230. {
  231. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i + 1]) /
  232. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i + 1]);
  233. _menuElementGroup[i].localScale = Vector3.Lerp(_targetScale, _normalScale, _prop);
  234. }
  235. //
  236. }
  237. _menuElementGroup[i].DOKill();
  238. //拖拽的增量比值乘以预设的最大速度,实现设备拖拽速度与游戏对象移动速度成正比
  239. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i], -_delta * _velocityGroup[i + 1].magnitude).SetSpeedBased();
  240. }
  241. }
  242. else//开始移位
  243. {
  244. for (int i = 0; i < _menuElementGroup.Count; i++)
  245. {
  246. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  247. {
  248. //
  249. if (i == _middleIndex)
  250. {
  251. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i]) /
  252. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i - 1]);
  253. _menuElementGroup[i].localScale = Vector3.Lerp(_targetScale, _normalScale, _prop);
  254. }
  255. else if (i == _nextMidIndex)
  256. {
  257. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i]) /
  258. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i - 1]);
  259. _menuElementGroup[i].localScale = Vector3.Lerp(_normalScale, _targetScale, _prop);
  260. }
  261. //
  262. }
  263. _menuElementGroup[i].DOKill();
  264. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i - 1], -_delta * _velocityGroup[i].magnitude).SetSpeedBased();
  265. }
  266. if (_menuElementGroup[0].localPosition == _bezierPointGroup[-1])
  267. {
  268. _menuElementGroup[0].DOKill();
  269. ShiftToLeft();
  270. DisplayMenuElement();
  271. }
  272. }
  273. }
  274. else if (_delta > 0.01f)//向右拖动时
  275. {
  276. // _delta = 0.5f;
  277. _isInLeft = false;
  278. if (!_isInRight)//如果没有归位到当前元素应该处于的位置上,就先让元素移动到对应的位置上
  279. {
  280. if (_menuElementGroup[0].localPosition == _bezierPointGroup[0])
  281. {
  282. if (!_isClickDel)//如果没有点击删除按钮,则中间位置元素为放大显示
  283. {
  284. //
  285. _menuElementGroup[_middleIndex].localScale = _targetScale;
  286. _menuElementGroup[_nextMidIndex].localScale = _normalScale;
  287. //
  288. }
  289. _isInRight = true;
  290. return;
  291. }
  292. for (int i = 0; i < _menuElementGroup.Count; i++)
  293. {
  294. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  295. {
  296. //
  297. if (i == _middleIndex)
  298. {
  299. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i - 1]) /
  300. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i - 1]);
  301. _menuElementGroup[i].localScale = Vector3.Lerp(_normalScale, _targetScale, _prop);
  302. }
  303. else if (i == _nextMidIndex)
  304. {
  305. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i - 1]) /
  306. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i - 1]);
  307. _menuElementGroup[i].localScale = Vector3.Lerp(_targetScale, _normalScale, _prop);
  308. }
  309. //
  310. }
  311. _menuElementGroup[i].DOKill();
  312. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i], _delta * _velocityGroup[i].magnitude).SetSpeedBased();
  313. }
  314. }
  315. else//开始移位
  316. {
  317. for (int i = 0; i < _menuElementGroup.Count; i++)
  318. {
  319. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  320. {
  321. //
  322. if (i == _middleIndex)
  323. {
  324. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i]) /
  325. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i + 1]);
  326. _menuElementGroup[i].localScale = Vector3.Lerp(_targetScale, _normalScale, _prop);
  327. }
  328. else if (i == _preMidIndex)
  329. {
  330. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i]) /
  331. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i + 1]);
  332. _menuElementGroup[i].localScale = Vector3.Lerp(_normalScale, _targetScale, _prop);
  333. }
  334. //
  335. }
  336. _menuElementGroup[i].DOKill();
  337. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i + 1], _delta * _velocityGroup[i + 1].magnitude).SetSpeedBased();
  338. }
  339. if (_menuElementGroup[_menuElementGroup.Count - 1].localPosition == _bezierPointGroup[_menuElementGroup.Count])
  340. {
  341. _menuElementGroup[_menuElementGroup.Count - 1].DOKill();
  342. ShiftToRight();
  343. DisplayMenuElement();
  344. }
  345. }
  346. }
  347. else//无位置变换时间超过一秒,则游戏对象不会移动
  348. {
  349. for (int i = 0; i < _menuElementGroup.Count; i++)
  350. {
  351. _menuElementGroup[i].DOKill();
  352. }
  353. }
  354. }
  355. public void OnEndDrag(PointerEventData eventData)
  356. {
  357. //拖拽结束时,移动回当前对应的定位点位置
  358. for (int i = 0; i < _menuElementGroup.Count; i++)
  359. {
  360. _menuElementGroup[i].DOKill();
  361. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i], 0.5f);
  362. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  363. {
  364. _menuElementGroup[_middleIndex].DOScale(_targetScale, 0.5f);
  365. }
  366. else
  367. {
  368. _menuElementGroup[_middleIndex].DOScale(_normalScale, 0.5f);
  369. }
  370. _menuElementGroup[_preMidIndex].DOScale(_normalScale, 0.5f);
  371. _menuElementGroup[_nextMidIndex].DOScale(_normalScale, 0.5f);
  372. }
  373. IsDrag(false);
  374. }
  375. private void ShiftToLeft()//集合元素(游戏对象与数据)往左串位
  376. {
  377. //游戏对象往左串位
  378. var _tran = _menuElementGroup[0];
  379. _menuElementGroup.RemoveAt(0);
  380. _menuElementGroup.Add(_tran);
  381. //数据脚本往左串位
  382. var _icon = _elementDataGroup[0];
  383. if (_elementDataGroup[0].DataConfig != null && _elementDataGroup[_elementDataGroup.Count - 1].DataConfig != null)
  384. {
  385. _icon.DataConfig = _elementDataGroup[_elementDataGroup.Count - 1].DataConfig.NextNode;
  386. }
  387. _elementDataGroup.RemoveAt(0);
  388. _elementDataGroup.Add(_icon);
  389. _icon.RefreshData();
  390. //刷新记录物体的缩放值和索引值
  391. RecordValue();
  392. }
  393. private void ShiftToRight()//集合元素(游戏对象与数据)往右串位
  394. {
  395. //游戏对象往右串位
  396. var _tran = _menuElementGroup[_menuElementGroup.Count - 1];
  397. _menuElementGroup.RemoveAt(_menuElementGroup.Count - 1);
  398. _menuElementGroup.Insert(0, _tran);
  399. //数据脚本往右串位
  400. var _icon = _elementDataGroup[_elementDataGroup.Count - 1];
  401. if (_elementDataGroup[0].DataConfig != null && _elementDataGroup[_elementDataGroup.Count - 1].DataConfig != null)
  402. {
  403. _icon.DataConfig = _elementDataGroup[0].DataConfig.PreNode;
  404. }
  405. _elementDataGroup.RemoveAt(_elementDataGroup.Count - 1);
  406. _elementDataGroup.Insert(0, _icon);
  407. _icon.RefreshData();
  408. //刷新记录物体的缩放值和索引值
  409. RecordValue();
  410. }
  411. void RearrangeElements(Transform tran)// 回调方法:当删除完元素时,后续元素所在的游戏对象和数据往前移位
  412. {
  413. int index = -1;
  414. for (int i = 0; i < _menuElementGroup.Count; i++)//求出删除元素所在的位置
  415. {
  416. if (_menuElementGroup[i] == tran)
  417. {
  418. index = i;
  419. break;
  420. }
  421. }
  422. //所删除元素的游戏对象位置变换到最后一个定位点(等待向前移位)
  423. var _tempElement = _menuElementGroup[index];
  424. _tempElement.position = _bezierPointGroup[_menuElementGroup.Count];
  425. _menuElementGroup.RemoveAt(index);
  426. _menuElementGroup.Add(_tempElement);
  427. //游戏数据向前移位,赋予给所删除的游戏对象
  428. var _tempData = _elementDataGroup[index];
  429. _elementDataGroup.RemoveAt(index);
  430. _elementDataGroup.Add(_tempData);
  431. if (_elementDataGroup[_elementDataGroup.Count - 2].DataConfig.NextNode != ConfigModel.Instance.GetFirstMenuItem())
  432. {
  433. _elementDataGroup[_elementDataGroup.Count - 1].DataConfig = _elementDataGroup[_elementDataGroup.Count - 2].DataConfig.NextNode;
  434. }
  435. else
  436. {
  437. Debug.LogError("这个节点的下一个节点元素为头节点,出错了!");
  438. }
  439. //游戏对象向前移位
  440. for (int i = index; i < _menuElementGroup.Count; i++)
  441. {
  442. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i], 0.2f);
  443. if (i == _preMidIndex)
  444. {
  445. _menuElementGroup[_preMidIndex].DOScale(_normalScale, 0.2f);
  446. _menuElementGroup[_middleIndex].DOScale(_targetScale, 0.2f);
  447. }
  448. else if (i == _middleIndex)
  449. {
  450. _menuElementGroup[_middleIndex].DOScale(_targetScale, 0.2f);
  451. _menuElementGroup[_menuElementGroup.Count - 1].localScale = _normalScale;
  452. }
  453. }
  454. //刷新记录物体的缩放值和索引值
  455. RecordValue();
  456. }
  457. /// <summary>
  458. /// 刷新记录物体的缩放值和索引值
  459. /// </summary>
  460. void RecordValue()
  461. {
  462. for (int i = 0; i < _elementDataGroup.Count; i++)
  463. {
  464. _elementDataGroup[i].RoomIndex = i;
  465. if (i == _middleIndex)
  466. {
  467. _elementDataGroup[i].initAV3 = _targetScale;
  468. }
  469. else
  470. {
  471. _elementDataGroup[i].initAV3 = _normalScale;
  472. }
  473. }
  474. }
  475. /// <summary>
  476. /// 显示房间游戏对象动画
  477. /// </summary>
  478. public void ShowItemEffect()
  479. {
  480. for (int i = 0; i < _elementDataGroup.Count; i++)
  481. {
  482. _elementDataGroup[i].ShowItem();
  483. }
  484. }
  485. /// <summary>
  486. /// 隐藏房间游戏对象动画
  487. /// </summary>
  488. public void HideItemEffect()
  489. {
  490. for (int i = 0; i < _elementDataGroup.Count; i++)
  491. {
  492. _elementDataGroup[i].HideItem();
  493. }
  494. }
  495. /// <summary>
  496. /// 刷新删除按钮的显示状态
  497. /// </summary>
  498. public void RefreshDteBtn()
  499. {
  500. for (int i = 0; i < _elementDataGroup.Count; i++)
  501. {
  502. _elementDataGroup[i].ChangeDteBtn();
  503. }
  504. }
  505. /// <summary>
  506. /// 当加入房间失败时,取消事件监听
  507. /// </summary>
  508. public void RefeshisClick()
  509. {
  510. for (int i = 0; i < _elementDataGroup.Count; i++)
  511. {
  512. _elementDataGroup[i].Refeshbool();
  513. }
  514. }
  515. /// <summary>
  516. /// 刷新数据
  517. /// </summary>
  518. public void UpdateData()
  519. {
  520. for (int i = 0; i < _elementDataGroup.Count; i++)
  521. {
  522. _elementDataGroup[i].RefreshData();
  523. }
  524. }
  525. /// <summary>
  526. /// 游戏对象是否处于拖拽状态
  527. /// </summary>
  528. /// <param name="isDrag"></param>
  529. private void IsDrag(bool isDrag)
  530. {
  531. for (int i = 0; i < _elementDataGroup.Count; i++)
  532. {
  533. _elementDataGroup[i]._isDrag = isDrag;
  534. }
  535. }
  536. void OnDestroy()
  537. {
  538. EventTool._rearrange -= RearrangeElements;
  539. }
  540. }