MenuUI.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. if(XRInputManager.isHand)
  183. ob.transform.position = (eventData as SCPointEventData).Position3D;
  184. else
  185. ob.transform.position = (eventData as SCPointEventData).PressPosition3D;
  186. ob.transform.localEulerAngles = Vector3.zero;
  187. bx = ob.transform.localPosition.x;
  188. }
  189. public void OnDrag(PointerEventData eventData)
  190. {
  191. SCPointEventData sed = eventData as SCPointEventData;
  192. if(sed.inputDevicePartBase is InputDeviceHeadPart)
  193. {
  194. sed.inputDevicePartBase.transform.position = OpenXRCamera.Instance.head.position;
  195. sed.inputDevicePartBase.transform.eulerAngles = OpenXRCamera.Instance.head.eulerAngles;
  196. }
  197. if (XRInputManager.isHand)
  198. ob.transform.position = (eventData as SCPointEventData).Position3D;
  199. else
  200. ob.transform.position = (eventData as SCPointEventData).PressPosition3D;
  201. float ox = ob.transform.localPosition.x;
  202. // return;
  203. float _delta = (bx - ox)*100;//eventData.delta.x / _maxDragValue;//记录拖动的增量比值(用作速度比值)
  204. if (XRInputManager.isHand)
  205. _delta = -_delta;
  206. bx = ox;
  207. // Debug.Log("_delta===>"+_delta);
  208. if (_delta < -0.01f)//向左拖动时
  209. {
  210. // _delta = -0.5f;
  211. _isInRight = false;
  212. if (!_isInLeft)//如果没有归位到当前元素应该处于的位置上,就先让元素先移动到对应的位置上
  213. {
  214. if (_menuElementGroup[0].localPosition == _bezierPointGroup[0])
  215. {
  216. if (!_isClickDel)//如果没有点击删除按钮,则播中间位置元素为放大显示
  217. {
  218. //
  219. _menuElementGroup[_middleIndex].localScale = _targetScale;
  220. _menuElementGroup[_preMidIndex].localScale = _normalScale;
  221. //
  222. }
  223. _isInLeft = true;
  224. return;
  225. }
  226. for (int i = 0; i < _menuElementGroup.Count; i++)
  227. {
  228. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  229. {
  230. //
  231. if (i == _middleIndex)
  232. {
  233. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i + 1]) /
  234. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i + 1]);
  235. _menuElementGroup[i].localScale = Vector3.Lerp(_normalScale, _targetScale, _prop);
  236. }
  237. else if (i == _preMidIndex)
  238. {
  239. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i + 1]) /
  240. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i + 1]);
  241. _menuElementGroup[i].localScale = Vector3.Lerp(_targetScale, _normalScale, _prop);
  242. }
  243. //
  244. }
  245. _menuElementGroup[i].DOKill();
  246. //拖拽的增量比值乘以预设的最大速度,实现设备拖拽速度与游戏对象移动速度成正比
  247. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i], -_delta * _velocityGroup[i + 1].magnitude).SetSpeedBased();
  248. }
  249. }
  250. else//开始移位
  251. {
  252. for (int i = 0; i < _menuElementGroup.Count; i++)
  253. {
  254. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  255. {
  256. //
  257. if (i == _middleIndex)
  258. {
  259. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i]) /
  260. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i - 1]);
  261. _menuElementGroup[i].localScale = Vector3.Lerp(_targetScale, _normalScale, _prop);
  262. }
  263. else if (i == _nextMidIndex)
  264. {
  265. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i]) /
  266. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i - 1]);
  267. _menuElementGroup[i].localScale = Vector3.Lerp(_normalScale, _targetScale, _prop);
  268. }
  269. //
  270. }
  271. _menuElementGroup[i].DOKill();
  272. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i - 1], -_delta * _velocityGroup[i].magnitude).SetSpeedBased();
  273. }
  274. if (_menuElementGroup[0].localPosition == _bezierPointGroup[-1])
  275. {
  276. _menuElementGroup[0].DOKill();
  277. ShiftToLeft();
  278. DisplayMenuElement();
  279. }
  280. }
  281. }
  282. else if (_delta > 0.01f)//向右拖动时
  283. {
  284. // _delta = 0.5f;
  285. _isInLeft = false;
  286. if (!_isInRight)//如果没有归位到当前元素应该处于的位置上,就先让元素移动到对应的位置上
  287. {
  288. if (_menuElementGroup[0].localPosition == _bezierPointGroup[0])
  289. {
  290. if (!_isClickDel)//如果没有点击删除按钮,则中间位置元素为放大显示
  291. {
  292. //
  293. _menuElementGroup[_middleIndex].localScale = _targetScale;
  294. _menuElementGroup[_nextMidIndex].localScale = _normalScale;
  295. //
  296. }
  297. _isInRight = true;
  298. return;
  299. }
  300. for (int i = 0; i < _menuElementGroup.Count; i++)
  301. {
  302. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  303. {
  304. //
  305. if (i == _middleIndex)
  306. {
  307. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i - 1]) /
  308. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i - 1]);
  309. _menuElementGroup[i].localScale = Vector3.Lerp(_normalScale, _targetScale, _prop);
  310. }
  311. else if (i == _nextMidIndex)
  312. {
  313. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i - 1]) /
  314. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i - 1]);
  315. _menuElementGroup[i].localScale = Vector3.Lerp(_targetScale, _normalScale, _prop);
  316. }
  317. //
  318. }
  319. _menuElementGroup[i].DOKill();
  320. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i], _delta * _velocityGroup[i].magnitude).SetSpeedBased();
  321. }
  322. }
  323. else//开始移位
  324. {
  325. for (int i = 0; i < _menuElementGroup.Count; i++)
  326. {
  327. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  328. {
  329. //
  330. if (i == _middleIndex)
  331. {
  332. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i]) /
  333. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i + 1]);
  334. _menuElementGroup[i].localScale = Vector3.Lerp(_targetScale, _normalScale, _prop);
  335. }
  336. else if (i == _preMidIndex)
  337. {
  338. float _prop = Vector3.Distance(_menuElementGroup[i].localPosition, _bezierPointGroup[i]) /
  339. Vector3.Distance(_bezierPointGroup[i], _bezierPointGroup[i + 1]);
  340. _menuElementGroup[i].localScale = Vector3.Lerp(_normalScale, _targetScale, _prop);
  341. }
  342. //
  343. }
  344. _menuElementGroup[i].DOKill();
  345. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i + 1], _delta * _velocityGroup[i + 1].magnitude).SetSpeedBased();
  346. }
  347. if (_menuElementGroup[_menuElementGroup.Count - 1].localPosition == _bezierPointGroup[_menuElementGroup.Count])
  348. {
  349. _menuElementGroup[_menuElementGroup.Count - 1].DOKill();
  350. ShiftToRight();
  351. DisplayMenuElement();
  352. }
  353. }
  354. }
  355. else//无位置变换时间超过一秒,则游戏对象不会移动
  356. {
  357. for (int i = 0; i < _menuElementGroup.Count; i++)
  358. {
  359. _menuElementGroup[i].DOKill();
  360. }
  361. }
  362. }
  363. public void OnEndDrag(PointerEventData eventData)
  364. {
  365. //拖拽结束时,移动回当前对应的定位点位置
  366. for (int i = 0; i < _menuElementGroup.Count; i++)
  367. {
  368. _menuElementGroup[i].DOKill();
  369. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i], 0.5f);
  370. if (!_isClickDel)//如果没有点击删除按钮,则播放缩放动画
  371. {
  372. _menuElementGroup[_middleIndex].DOScale(_targetScale, 0.5f);
  373. }
  374. else
  375. {
  376. _menuElementGroup[_middleIndex].DOScale(_normalScale, 0.5f);
  377. }
  378. _menuElementGroup[_preMidIndex].DOScale(_normalScale, 0.5f);
  379. _menuElementGroup[_nextMidIndex].DOScale(_normalScale, 0.5f);
  380. }
  381. IsDrag(false);
  382. }
  383. private void ShiftToLeft()//集合元素(游戏对象与数据)往左串位
  384. {
  385. //游戏对象往左串位
  386. var _tran = _menuElementGroup[0];
  387. _menuElementGroup.RemoveAt(0);
  388. _menuElementGroup.Add(_tran);
  389. //数据脚本往左串位
  390. var _icon = _elementDataGroup[0];
  391. if (_elementDataGroup[0].DataConfig != null && _elementDataGroup[_elementDataGroup.Count - 1].DataConfig != null)
  392. {
  393. _icon.DataConfig = _elementDataGroup[_elementDataGroup.Count - 1].DataConfig.NextNode;
  394. }
  395. _elementDataGroup.RemoveAt(0);
  396. _elementDataGroup.Add(_icon);
  397. _icon.RefreshData();
  398. //刷新记录物体的缩放值和索引值
  399. RecordValue();
  400. }
  401. private void ShiftToRight()//集合元素(游戏对象与数据)往右串位
  402. {
  403. //游戏对象往右串位
  404. var _tran = _menuElementGroup[_menuElementGroup.Count - 1];
  405. _menuElementGroup.RemoveAt(_menuElementGroup.Count - 1);
  406. _menuElementGroup.Insert(0, _tran);
  407. //数据脚本往右串位
  408. var _icon = _elementDataGroup[_elementDataGroup.Count - 1];
  409. if (_elementDataGroup[0].DataConfig != null && _elementDataGroup[_elementDataGroup.Count - 1].DataConfig != null)
  410. {
  411. _icon.DataConfig = _elementDataGroup[0].DataConfig.PreNode;
  412. }
  413. _elementDataGroup.RemoveAt(_elementDataGroup.Count - 1);
  414. _elementDataGroup.Insert(0, _icon);
  415. _icon.RefreshData();
  416. //刷新记录物体的缩放值和索引值
  417. RecordValue();
  418. }
  419. void RearrangeElements(Transform tran)// 回调方法:当删除完元素时,后续元素所在的游戏对象和数据往前移位
  420. {
  421. int index = -1;
  422. for (int i = 0; i < _menuElementGroup.Count; i++)//求出删除元素所在的位置
  423. {
  424. if (_menuElementGroup[i] == tran)
  425. {
  426. index = i;
  427. break;
  428. }
  429. }
  430. //所删除元素的游戏对象位置变换到最后一个定位点(等待向前移位)
  431. var _tempElement = _menuElementGroup[index];
  432. _tempElement.position = _bezierPointGroup[_menuElementGroup.Count];
  433. _menuElementGroup.RemoveAt(index);
  434. _menuElementGroup.Add(_tempElement);
  435. //游戏数据向前移位,赋予给所删除的游戏对象
  436. var _tempData = _elementDataGroup[index];
  437. _elementDataGroup.RemoveAt(index);
  438. _elementDataGroup.Add(_tempData);
  439. if (_elementDataGroup[_elementDataGroup.Count - 2].DataConfig.NextNode != ConfigModel.Instance.GetFirstMenuItem())
  440. {
  441. _elementDataGroup[_elementDataGroup.Count - 1].DataConfig = _elementDataGroup[_elementDataGroup.Count - 2].DataConfig.NextNode;
  442. }
  443. else
  444. {
  445. Debug.LogError("这个节点的下一个节点元素为头节点,出错了!");
  446. }
  447. //游戏对象向前移位
  448. for (int i = index; i < _menuElementGroup.Count; i++)
  449. {
  450. _menuElementGroup[i].DOLocalMove(_bezierPointGroup[i], 0.2f);
  451. if (i == _preMidIndex)
  452. {
  453. _menuElementGroup[_preMidIndex].DOScale(_normalScale, 0.2f);
  454. _menuElementGroup[_middleIndex].DOScale(_targetScale, 0.2f);
  455. }
  456. else if (i == _middleIndex)
  457. {
  458. _menuElementGroup[_middleIndex].DOScale(_targetScale, 0.2f);
  459. _menuElementGroup[_menuElementGroup.Count - 1].localScale = _normalScale;
  460. }
  461. }
  462. //刷新记录物体的缩放值和索引值
  463. RecordValue();
  464. }
  465. /// <summary>
  466. /// 刷新记录物体的缩放值和索引值
  467. /// </summary>
  468. void RecordValue()
  469. {
  470. for (int i = 0; i < _elementDataGroup.Count; i++)
  471. {
  472. _elementDataGroup[i].RoomIndex = i;
  473. if (i == _middleIndex)
  474. {
  475. _elementDataGroup[i].initAV3 = _targetScale;
  476. }
  477. else
  478. {
  479. _elementDataGroup[i].initAV3 = _normalScale;
  480. }
  481. }
  482. }
  483. /// <summary>
  484. /// 显示房间游戏对象动画
  485. /// </summary>
  486. public void ShowItemEffect()
  487. {
  488. for (int i = 0; i < _elementDataGroup.Count; i++)
  489. {
  490. _elementDataGroup[i].ShowItem();
  491. }
  492. }
  493. /// <summary>
  494. /// 隐藏房间游戏对象动画
  495. /// </summary>
  496. public void HideItemEffect()
  497. {
  498. for (int i = 0; i < _elementDataGroup.Count; i++)
  499. {
  500. _elementDataGroup[i].HideItem();
  501. }
  502. }
  503. /// <summary>
  504. /// 刷新删除按钮的显示状态
  505. /// </summary>
  506. public void RefreshDteBtn()
  507. {
  508. for (int i = 0; i < _elementDataGroup.Count; i++)
  509. {
  510. _elementDataGroup[i].ChangeDteBtn();
  511. }
  512. }
  513. /// <summary>
  514. /// 当加入房间失败时,取消事件监听
  515. /// </summary>
  516. public void RefeshisClick()
  517. {
  518. for (int i = 0; i < _elementDataGroup.Count; i++)
  519. {
  520. _elementDataGroup[i].Refeshbool();
  521. }
  522. }
  523. /// <summary>
  524. /// 刷新数据
  525. /// </summary>
  526. public void UpdateData()
  527. {
  528. for (int i = 0; i < _elementDataGroup.Count; i++)
  529. {
  530. _elementDataGroup[i].RefreshData();
  531. }
  532. }
  533. /// <summary>
  534. /// 游戏对象是否处于拖拽状态
  535. /// </summary>
  536. /// <param name="isDrag"></param>
  537. private void IsDrag(bool isDrag)
  538. {
  539. for (int i = 0; i < _elementDataGroup.Count; i++)
  540. {
  541. _elementDataGroup[i]._isDrag = isDrag;
  542. }
  543. }
  544. void OnDestroy()
  545. {
  546. EventTool._rearrange -= RearrangeElements;
  547. }
  548. }