LuoShuanMenuAnimation.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. using ChivaXR;
  2. using Sirenix.OdinInspector;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using UnityEditor;
  8. using UnityEngine;
  9. [ExecuteInEditMode]
  10. public class LuoShuanMenuAnimation : SerializedMonoBehaviour
  11. {
  12. ///螺栓长短不一时,动画无法适配
  13. ///不适配成双螺丝,多组螺丝位置分散时,操作麻烦
  14. ///类型得手选,听鸡肋的,点着麻烦。默认排序也有问题,应该默认螺母
  15. private bool showAniInfo = false;
  16. private float timer = 0;
  17. private bool isInit = true;
  18. private LuoShuanObj aniMenuItem;
  19. private int objListCount = 0;
  20. private int runListIndex = 0;
  21. private int aniState = 0;
  22. private int num = 0;
  23. //[HideInInspector]
  24. public bool reverse = false;
  25. private float lerp;
  26. /// <summary> 存放锚点服务体的列表 </summary>
  27. private List<GameObject> tempMenuList = new List<GameObject>();
  28. public enum objType { 螺母, 垫片,螺丝 }
  29. [Tooltip("和物体名称一样,只用于在执行队列中起提示作用,无实际代码逻辑作用")]
  30. [LabelText("物体类型"), PropertyOrder(0),OnValueChanged("ChangeType")]
  31. public objType itemType = objType.螺母;
  32. void ChangeType()
  33. {
  34. objName= itemType.ToString();
  35. if (objName.Equals("垫片"))
  36. {
  37. localMovePos = Vector3.zero;
  38. rotAngle = 0;
  39. duration = 0;
  40. showAniInfo = true;
  41. }
  42. else
  43. {
  44. rotAngle = -360;
  45. duration = 2;
  46. showAniInfo = false;
  47. }
  48. }
  49. [LabelText("是否对角拆除"), PropertyOrder(0)]
  50. public bool playType = true;
  51. [Tooltip("和物体类型一样,只用于在执行队列中起提示作用,无实际代码逻辑作用")]
  52. [LabelText("物体名称"), PropertyOrder(0)]
  53. public string objName = "螺母";
  54. [FoldoutGroup("动画属性"), LabelText("移动方向"), PropertyOrder(1),HideIf("showAniInfo")]
  55. public Vector3 localMovePos;
  56. [FoldoutGroup("动画属性"), LabelText("旋转角度"), PropertyOrder(1), HideIf("showAniInfo")]
  57. public float rotAngle = 0;
  58. [FoldoutGroup("动画属性"), LabelText("运行时长"), PropertyOrder(1), HideIf("showAniInfo")]
  59. public float duration;
  60. [LabelText("执行队列"), PropertyOrder(1)]
  61. public List<LuoShuanObj> menuList = new List<LuoShuanObj>();
  62. public void SetInitState()
  63. {
  64. foreach (LuoShuanObj obj in menuList)
  65. {
  66. for (int i = 0; i < obj.objList.Count; i++)
  67. {
  68. if (!reverse)
  69. {
  70. obj.objList[i].transform.position = obj.tmpList[i].transform.position;
  71. obj.objList[i].transform.rotation = obj.tmpList[i].transform.rotation;
  72. obj.objList[i].SetActive(true);
  73. }
  74. else
  75. {
  76. obj.objList[i].transform.position = obj.tmpList[i].transform.position + obj.tmpList[i].transform.TransformDirection(obj.localMovePos);
  77. obj.objList[i].transform.rotation = obj.tmpList[i].transform.rotation;
  78. obj.objList[i].transform.RotateAround(obj.tmpList[i].transform.position, obj.tmpList[i].transform.TransformDirection(obj.localMovePos), obj.rotAngle);
  79. obj.objList[i].SetActive(false);
  80. }
  81. }
  82. }
  83. }
  84. public void SetFinishedState()
  85. {
  86. foreach (LuoShuanObj obj in menuList)
  87. {
  88. for (int i = 0; i < obj.objList.Count; i++)
  89. {
  90. if (reverse)
  91. {
  92. obj.objList[i].transform.position = obj.tmpList[i].transform.position;
  93. obj.objList[i].transform.rotation = obj.tmpList[i].transform.rotation;
  94. obj.objList[i].SetActive(true);
  95. }
  96. else
  97. {
  98. obj.objList[i].transform.position = obj.tmpList[i].transform.position + obj.tmpList[i].transform.TransformDirection(obj.localMovePos);
  99. obj.objList[i].transform.rotation = obj.tmpList[i].transform.rotation;
  100. obj.objList[i].transform.RotateAround(obj.tmpList[i].transform.position, obj.tmpList[i].transform.TransformDirection(obj.localMovePos), obj.rotAngle);
  101. obj.objList[i].SetActive(false);
  102. }
  103. }
  104. }
  105. }
  106. #if UNITY_EDITOR
  107. [Button("添加组"), PropertyOrder(2)]
  108. public void AddMenu()
  109. {
  110. if (Selection.gameObjects.Length == 0) return;
  111. List<LsListSort> objList = new List<LsListSort> ();
  112. try
  113. {
  114. foreach (GameObject obj in Selection.gameObjects)
  115. {
  116. objList.Add(new LsListSort(obj));
  117. }
  118. objList.Sort(objListSort);
  119. }
  120. catch (Exception)
  121. {
  122. infoStr = "选中的物体无法添加\n请检查选中物体的名称后缀是否为三个数字";
  123. infoBoxIsShow = true;
  124. return;
  125. }
  126. infoBoxIsShow = false;
  127. List<GameObject> sortList = new List<GameObject>();
  128. foreach (LsListSort obj in objList)
  129. {
  130. sortList.Add(obj.Object);
  131. }
  132. menuList.Add(new LuoShuanObj(objName, sortList, localMovePos, rotAngle, duration, new List<GameObject>(), showAniInfo,itemType));
  133. }
  134. [Button("生成锚点"), PropertyOrder(2)]
  135. public void AddSelectObj()
  136. {
  137. if (tempMenuList.Count != 0)
  138. {
  139. foreach (GameObject obj in tempMenuList)
  140. DestroyImmediate(obj);
  141. tempMenuList.Clear();
  142. }
  143. if (menuList.Count != 0)
  144. foreach (LuoShuanObj lsObj in menuList)
  145. {
  146. if (lsObj.tmpList.Count != 0)
  147. {
  148. foreach (GameObject obj in lsObj.tmpList)
  149. DestroyImmediate(obj);
  150. }
  151. lsObj.tmpList.Clear();
  152. }
  153. foreach (LuoShuanObj lsObj in menuList)
  154. {
  155. if (lsObj.objList.Count == 0) return;
  156. GameObject tmpList = new GameObject("锚点组_" + lsObj.objName);
  157. tmpList.transform.parent = transform;
  158. foreach (GameObject obj in lsObj.objList)
  159. {
  160. GameObject tmpItem = new GameObject("锚点_" + obj.gameObject.name);
  161. tmpItem.transform.parent = tmpList.transform;
  162. tmpItem.transform.position = obj.transform.position;
  163. tmpItem.transform.rotation = obj.transform.rotation;
  164. lsObj.tmpList.Add(tmpItem);
  165. }
  166. tempMenuList.Add(tmpList);
  167. }
  168. }
  169. [ShowIf("infoBoxIsShow"), PropertyOrder(3)]
  170. [DisplayAsString]
  171. public string infoStr = "目前只支持4倍数的物体,请检查";
  172. private bool infoBoxIsShow = false;
  173. [Button("Play"), PropertyOrder(2)]
  174. public void Play()
  175. {
  176. isPlaying = true;
  177. timer = 0;
  178. isInit = true;
  179. objListCount = 0;
  180. runListIndex = 0;
  181. if (reverse)
  182. aniState = menuList.Count - 1;
  183. else
  184. aniState = 0;
  185. num = 0;
  186. }
  187. [HideInInspector]
  188. public bool isPlaying;
  189. [HideInInspector]
  190. public bool isShowPath = true;
  191. public bool ShowPath { get { return isShowPath; } }
  192. private void OnDrawGizmos()
  193. {
  194. DrawPathLine();
  195. }
  196. public void DrawPathLine()
  197. {
  198. if (!isShowPath) return;
  199. if (tempMenuList.Count != 0)
  200. {
  201. foreach (LuoShuanObj lsObj in menuList)
  202. {
  203. if (lsObj.tmpList.Count != 0)
  204. {
  205. switch (lsObj.itemType)
  206. {
  207. case objType.螺丝: Gizmos.color = Color.yellow; break;
  208. case objType.螺母: Gizmos.color = Color.blue; break;
  209. //case objType.垫片: return;
  210. }
  211. Gizmos.DrawLine(lsObj.tmpList[1].transform.position, lsObj.tmpList[1].transform.position + lsObj.tmpList[1].transform.TransformDirection(lsObj.localMovePos));
  212. }
  213. }
  214. }
  215. }
  216. private void OnEnable()
  217. {
  218. EditorApplication.update += EditorUpdate;
  219. Selection.selectionChanged += SelectionChanged;
  220. }
  221. private void OnDisable()
  222. {
  223. EditorApplication.update -= EditorUpdate;
  224. Selection.selectionChanged -= SelectionChanged;
  225. }
  226. void EditorUpdate()
  227. {
  228. if (!isPlaying) return;
  229. foreach (LuoShuanObj obj in menuList)
  230. {
  231. if (obj.objList.Count == 0)
  232. {
  233. infoStr = "无物体对象数据,请检查";
  234. infoBoxIsShow = true;
  235. return;
  236. }
  237. if (obj.tmpList.Count == 0)
  238. {
  239. infoStr = "无锚点数据,请检查";
  240. infoBoxIsShow = true;
  241. return;
  242. }
  243. if (objListCount == 0)
  244. objListCount = obj.objList.Count;
  245. else
  246. if (objListCount != obj.objList.Count)
  247. {
  248. infoStr = "列表物体数量不匹配,请检查";
  249. infoBoxIsShow = true;
  250. return;
  251. }
  252. if(objListCount %4 != 0 && playType == true)
  253. {
  254. infoStr = "目前只支持4倍数的物体,请检查";
  255. infoBoxIsShow = true;
  256. return;
  257. }
  258. infoBoxIsShow = false;
  259. }
  260. if (isInit)
  261. {
  262. aniMenuItem = menuList[aniState];
  263. isInit = false;
  264. }
  265. if (reverse)
  266. {
  267. lerp = (1 - timer / aniMenuItem.duration);
  268. }
  269. else
  270. {
  271. lerp = timer / aniMenuItem.duration;
  272. }
  273. if (aniMenuItem.localMovePos != Vector3.zero)
  274. {
  275. if (playType == true)
  276. {
  277. PlayByDJ();
  278. }
  279. else
  280. {
  281. PlayByList();
  282. }
  283. }
  284. timer += Time.deltaTime;
  285. if (timer > aniMenuItem.duration)
  286. {
  287. timer = 0;
  288. if (playType == true)
  289. {
  290. HideObjByDJ();
  291. }
  292. else
  293. {
  294. HideObjBylist();
  295. }
  296. if (reverse)
  297. if (--aniState < 0)
  298. {
  299. aniState = menuList.Count - 1;
  300. if (num % 2 != 0)
  301. runListIndex++;
  302. num++;
  303. }
  304. if (!reverse)
  305. if (++aniState > menuList.Count - 1)
  306. {
  307. aniState = 0;
  308. if (num % 2 != 0)
  309. runListIndex++;
  310. num++;
  311. }
  312. aniMenuItem = menuList[aniState];
  313. if (runListIndex > objListCount / 4-1)
  314. {
  315. foreach (LuoShuanObj obj in menuList)
  316. {
  317. for (int i = 0; i < obj.objList.Count; i++)
  318. {
  319. if (obj.duration != 0 )
  320. {
  321. obj.objList[i].transform.position = obj.tmpList[i].transform.position;
  322. obj.objList[i].transform.rotation = obj.tmpList[i].transform.rotation;
  323. }
  324. obj.objList[i].SetActive(true);
  325. }
  326. }
  327. isPlaying = false;
  328. }
  329. }
  330. }
  331. public int objListSort(LsListSort obj1, LsListSort obj2)
  332. {
  333. if (obj1.objNameNum > obj2.objNameNum)
  334. return 1;
  335. else
  336. return -1;
  337. }
  338. public class LsListSort
  339. {
  340. public GameObject Object;
  341. public int objNameNum;
  342. public LsListSort(GameObject Object)
  343. {
  344. this.Object = Object;
  345. if(Object.name.Length>3)
  346. objNameNum = Convert.ToInt32(Object.name.Substring(Object.name.Length - 3, 3));
  347. else
  348. objNameNum = Convert.ToInt32(Object.name);
  349. }
  350. }
  351. void SelectionChanged()
  352. {
  353. if (Selection.gameObjects.Contains(this.gameObject))
  354. {
  355. isShowPath = true;
  356. }
  357. else
  358. {
  359. isShowPath = false;
  360. }
  361. }
  362. #endif
  363. public IEnumerator IEAniPlay(Action finishedCallBack = null)
  364. {
  365. timer = 0;
  366. isInit = true;
  367. objListCount = 0;
  368. runListIndex = 0;
  369. if (reverse)
  370. aniState = menuList.Count - 1;
  371. else
  372. aniState = 0;
  373. num = 0;
  374. foreach (LuoShuanObj obj in menuList)
  375. {
  376. if (obj.objList.Count == 0)
  377. {
  378. Debug.Log( "无物体对象数据,请检查");
  379. StopCoroutine(IEAniPlay());
  380. yield return new WaitForEndOfFrame();
  381. }
  382. if (obj.tmpList.Count == 0)
  383. {
  384. Debug.Log("无锚点数据,请检查");
  385. StopCoroutine(IEAniPlay());
  386. yield return new WaitForEndOfFrame();
  387. }
  388. if (objListCount == 0)
  389. objListCount = obj.objList.Count;
  390. else
  391. if (objListCount != obj.objList.Count)
  392. {
  393. Debug.Log("列表物体数量不匹配,请检查");
  394. StopCoroutine(IEAniPlay());
  395. yield return new WaitForEndOfFrame();
  396. }
  397. if (objListCount % 4 != 0 && playType)
  398. {
  399. Debug.Log("目前只支持4倍数的物体,请检查");
  400. StopCoroutine(IEAniPlay());
  401. yield return new WaitForEndOfFrame();
  402. }
  403. }
  404. aniMenuItem = menuList[aniState];
  405. while (runListIndex < objListCount / 4 )
  406. {
  407. if(playType == true)
  408. {
  409. PlayByDJ();
  410. }
  411. else
  412. {
  413. PlayByList();
  414. }
  415. timer += Time.deltaTime;
  416. if (timer > aniMenuItem.duration)
  417. {
  418. timer = 0;
  419. if (playType == true)
  420. {
  421. HideObjByDJ();
  422. }
  423. else
  424. {
  425. HideObjBylist();
  426. }
  427. if(reverse)
  428. if (--aniState < 0 )
  429. {
  430. aniState = menuList.Count - 1;
  431. if (num % 2 != 0)
  432. runListIndex++;
  433. num++;
  434. }
  435. if (!reverse)
  436. if (++aniState > menuList.Count - 1)
  437. {
  438. aniState = 0;
  439. if (num % 2 != 0)
  440. runListIndex++;
  441. num++;
  442. }
  443. aniMenuItem = menuList[aniState];
  444. }
  445. yield return new WaitForEndOfFrame();
  446. }
  447. SetFinishedState();
  448. finishedCallBack?.Invoke();
  449. }
  450. private void PlayByDJ()
  451. {
  452. if (reverse)
  453. lerp = (1 - timer / aniMenuItem.duration);
  454. else
  455. lerp = timer / aniMenuItem.duration;
  456. if (aniMenuItem.localMovePos != Vector3.zero && aniMenuItem.duration >0)
  457. {
  458. if (num % 2 != 0)
  459. {
  460. aniMenuItem.objList[runListIndex + objListCount / 4].SetActive(true);
  461. aniMenuItem.objList[runListIndex + 3 * objListCount / 4].SetActive(true);
  462. aniMenuItem.objList[runListIndex + objListCount / 4].transform.position = Vector3.Lerp(aniMenuItem.tmpList[runListIndex + objListCount / 4].transform.position, aniMenuItem.tmpList[runListIndex + objListCount / 4].transform.position + aniMenuItem.tmpList[runListIndex + objListCount / 4].transform.TransformDirection(aniMenuItem.localMovePos), lerp);
  463. aniMenuItem.objList[runListIndex + objListCount / 4].transform.rotation = aniMenuItem.tmpList[runListIndex + objListCount / 4].transform.rotation;
  464. aniMenuItem.objList[runListIndex + objListCount / 4].transform.RotateAround(aniMenuItem.tmpList[runListIndex + objListCount / 4].transform.position, aniMenuItem.tmpList[runListIndex + objListCount / 4].transform.TransformDirection(aniMenuItem.localMovePos), aniMenuItem.rotAngle * lerp);
  465. aniMenuItem.objList[runListIndex + 3 * objListCount / 4].transform.position = Vector3.Lerp(aniMenuItem.tmpList[runListIndex + 3 * objListCount / 4].transform.position, aniMenuItem.tmpList[runListIndex + 3 * objListCount / 4].transform.position + aniMenuItem.tmpList[runListIndex + 3 * objListCount / 4].transform.TransformDirection(aniMenuItem.localMovePos), lerp);
  466. aniMenuItem.objList[runListIndex + 3 * objListCount / 4].transform.rotation = aniMenuItem.tmpList[runListIndex + 3 * objListCount / 4].transform.rotation;
  467. aniMenuItem.objList[runListIndex + 3 * objListCount / 4].transform.RotateAround(aniMenuItem.tmpList[runListIndex + 3 * objListCount / 4].transform.position, aniMenuItem.tmpList[runListIndex + 3 * objListCount / 4].transform.TransformDirection(aniMenuItem.localMovePos), aniMenuItem.rotAngle * lerp);
  468. }
  469. else
  470. {
  471. aniMenuItem.objList[runListIndex].SetActive(true);
  472. aniMenuItem.objList[runListIndex + objListCount / 2].SetActive(true);
  473. aniMenuItem.objList[runListIndex].transform.position = Vector3.Lerp(aniMenuItem.tmpList[runListIndex].transform.position, aniMenuItem.tmpList[runListIndex].transform.position + aniMenuItem.tmpList[runListIndex].transform.TransformDirection(aniMenuItem.localMovePos), lerp);
  474. aniMenuItem.objList[runListIndex].transform.rotation = aniMenuItem.tmpList[runListIndex].transform.rotation;
  475. aniMenuItem.objList[runListIndex].transform.RotateAround(aniMenuItem.tmpList[runListIndex].transform.position, aniMenuItem.tmpList[runListIndex].transform.TransformDirection(aniMenuItem.localMovePos), aniMenuItem.rotAngle * lerp);
  476. aniMenuItem.objList[runListIndex + objListCount / 2].transform.position = Vector3.Lerp(aniMenuItem.tmpList[runListIndex + objListCount / 2].transform.position, aniMenuItem.tmpList[runListIndex + objListCount / 2].transform.position + aniMenuItem.tmpList[runListIndex + objListCount / 2].transform.TransformDirection(aniMenuItem.localMovePos), lerp);
  477. aniMenuItem.objList[runListIndex + objListCount / 2].transform.rotation = aniMenuItem.tmpList[runListIndex + objListCount / 2].transform.rotation;
  478. aniMenuItem.objList[runListIndex + objListCount / 2].transform.RotateAround(aniMenuItem.tmpList[runListIndex + objListCount / 2].transform.position, aniMenuItem.tmpList[runListIndex].transform.TransformDirection(aniMenuItem.localMovePos), aniMenuItem.rotAngle * lerp);
  479. }
  480. }
  481. }
  482. public void HideObjByDJ()
  483. {
  484. if (num % 2 != 0)
  485. {
  486. aniMenuItem.objList[runListIndex + objListCount / 4].SetActive(reverse);
  487. aniMenuItem.objList[runListIndex + 3 * objListCount / 4].SetActive(reverse);
  488. }
  489. else
  490. {
  491. aniMenuItem.objList[runListIndex].SetActive(reverse);
  492. aniMenuItem.objList[runListIndex + objListCount / 2].SetActive(reverse);
  493. }
  494. }
  495. public void HideObjBylist()
  496. {
  497. if (num % 2 != 0)
  498. {
  499. aniMenuItem.objList[runListIndex * 4 + 2].SetActive(reverse);
  500. aniMenuItem.objList[runListIndex * 4 + 3].SetActive(reverse);
  501. }
  502. else
  503. {
  504. aniMenuItem.objList[runListIndex * 4].SetActive(reverse);
  505. aniMenuItem.objList[runListIndex * 4 + 1].SetActive(reverse);
  506. }
  507. }
  508. private void PlayByList()
  509. {
  510. if (reverse)
  511. lerp = (1 - timer / aniMenuItem.duration);
  512. else
  513. lerp = timer / aniMenuItem.duration;
  514. if (aniMenuItem.localMovePos != Vector3.zero && aniMenuItem.duration > 0)
  515. {
  516. if (num % 2 != 0)
  517. {
  518. aniMenuItem.objList[runListIndex * 4 + 2].SetActive(true);
  519. aniMenuItem.objList[runListIndex * 4 + 3].SetActive(true);
  520. aniMenuItem.objList[runListIndex * 4 + 2].transform.position = Vector3.Lerp(aniMenuItem.tmpList[runListIndex * 4 + 2].transform.position, aniMenuItem.tmpList[runListIndex * 4 + 2].transform.position + aniMenuItem.tmpList[runListIndex * 4 + 2].transform.TransformDirection(aniMenuItem.localMovePos), lerp);
  521. aniMenuItem.objList[runListIndex * 4 + 2].transform.rotation = aniMenuItem.tmpList[runListIndex * 4 + 2].transform.rotation;
  522. aniMenuItem.objList[runListIndex * 4 + 2].transform.RotateAround(aniMenuItem.tmpList[runListIndex * 4 + 2].transform.position, aniMenuItem.tmpList[runListIndex * 4 + 2].transform.TransformDirection(aniMenuItem.localMovePos), aniMenuItem.rotAngle * lerp);
  523. aniMenuItem.objList[runListIndex * 4 + 3].transform.position = Vector3.Lerp(aniMenuItem.tmpList[runListIndex * 4 + 3].transform.position, aniMenuItem.tmpList[runListIndex * 4 + 3].transform.position + aniMenuItem.tmpList[runListIndex * 4 + 3].transform.TransformDirection(aniMenuItem.localMovePos), lerp);
  524. aniMenuItem.objList[runListIndex * 4 + 3].transform.rotation = aniMenuItem.tmpList[runListIndex * 4 + 3].transform.rotation;
  525. aniMenuItem.objList[runListIndex * 4 + 3].transform.RotateAround(aniMenuItem.tmpList[runListIndex * 4 + 3].transform.position, aniMenuItem.tmpList[runListIndex * 4 + 3].transform.TransformDirection(aniMenuItem.localMovePos), aniMenuItem.rotAngle * lerp);
  526. }
  527. else
  528. {
  529. aniMenuItem.objList[runListIndex * 4].SetActive(true);
  530. aniMenuItem.objList[runListIndex * 4 + 1].SetActive(true);
  531. aniMenuItem.objList[runListIndex * 4].transform.position = Vector3.Lerp(aniMenuItem.tmpList[runListIndex * 4].transform.position, aniMenuItem.tmpList[runListIndex * 4].transform.position + aniMenuItem.tmpList[runListIndex * 4].transform.TransformDirection(aniMenuItem.localMovePos), lerp);
  532. aniMenuItem.objList[runListIndex * 4].transform.rotation = aniMenuItem.tmpList[runListIndex * 4].transform.rotation;
  533. aniMenuItem.objList[runListIndex * 4].transform.RotateAround(aniMenuItem.tmpList[runListIndex * 4].transform.position, aniMenuItem.tmpList[runListIndex * 4].transform.TransformDirection(aniMenuItem.localMovePos), aniMenuItem.rotAngle * lerp);
  534. aniMenuItem.objList[runListIndex * 4 + 1].transform.position = Vector3.Lerp(aniMenuItem.tmpList[runListIndex * 4 + 1].transform.position, aniMenuItem.tmpList[runListIndex * 4 + 1].transform.position + aniMenuItem.tmpList[runListIndex * 4 + 1].transform.TransformDirection(aniMenuItem.localMovePos), lerp);
  535. aniMenuItem.objList[runListIndex * 4 + 1].transform.rotation = aniMenuItem.tmpList[runListIndex * 4 + 1].transform.rotation;
  536. aniMenuItem.objList[runListIndex * 4 + 1].transform.RotateAround(aniMenuItem.tmpList[runListIndex * 4 + 1].transform.position, aniMenuItem.tmpList[runListIndex * 4 + 1].transform.TransformDirection(aniMenuItem.localMovePos), aniMenuItem.rotAngle * lerp);
  537. }
  538. }
  539. }
  540. [SerializeField]
  541. public struct LuoShuanObj
  542. {
  543. [LabelText("名称")]
  544. public string objName;
  545. [LabelText("对象列表")]
  546. public List<GameObject> objList;
  547. [FoldoutGroup("动画属性"), LabelText("移动方向"), HideIf("showAniInfo")]
  548. public Vector3 localMovePos;
  549. [FoldoutGroup("动画属性"), LabelText("旋转角度"), HideIf("showAniInfo")]
  550. public float rotAngle;
  551. [FoldoutGroup("动画属性"), LabelText("运行时长"), HideIf("showAniInfo")]
  552. public float duration;
  553. [LabelText("锚点列表"), HideIf("showAniInfo")]
  554. public List<GameObject> tmpList;
  555. private bool showAniInfo;
  556. [HideInInspector]
  557. public objType itemType;
  558. public LuoShuanObj(string objName, List<GameObject> objList, Vector3 localMovePos, float rotAngle, float duration, List<GameObject> tmpList, bool showAniInfo, objType itemType)
  559. {
  560. this.objName = objName;
  561. this.objList = objList;
  562. this.localMovePos = localMovePos;
  563. this.rotAngle = rotAngle;
  564. this.duration = duration;
  565. this.tmpList = tmpList;
  566. this.showAniInfo = showAniInfo;
  567. this.itemType = itemType;
  568. }
  569. }
  570. }