LuoShuanMenuAnimation.cs 24 KB

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