AnimatorTimeline.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Reflection;
  5. using JsonFx.Json;
  6. using UnityEngine;
  7. public class AnimatorTimeline : MonoBehaviour
  8. {
  9. public static Component aData
  10. {
  11. get
  12. {
  13. if (AnimatorTimeline._aData != null)
  14. {
  15. return AnimatorTimeline._aData;
  16. }
  17. AnimatorTimeline.cachedInvoker = null;
  18. GameObject gameObject = GameObject.Find("AnimatorData");
  19. if (gameObject)
  20. {
  21. AnimatorTimeline._aData = gameObject.GetComponent("AnimatorData");
  22. }
  23. if (!AnimatorTimeline._aData)
  24. {
  25. Debug.LogWarning("Animator: Could not find AnimatorData component.");
  26. }
  27. return AnimatorTimeline._aData;
  28. }
  29. }
  30. private static MethodInfo invoker
  31. {
  32. get
  33. {
  34. if (AnimatorTimeline.cachedInvoker == null)
  35. {
  36. AnimatorTimeline.cachedInvoker = AnimatorTimeline.aData.GetType().GetMethod("Invoker");
  37. }
  38. return AnimatorTimeline.cachedInvoker;
  39. }
  40. }
  41. public static bool isPlaying
  42. {
  43. get
  44. {
  45. return (bool)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  46. {
  47. new object[]
  48. {
  49. 0
  50. }
  51. });
  52. }
  53. set
  54. {
  55. Debug.LogWarning("Animator: Variable Animator.isPlaying is read-only!");
  56. }
  57. }
  58. public static bool isPaused
  59. {
  60. get
  61. {
  62. return (bool)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  63. {
  64. new object[]
  65. {
  66. 12
  67. }
  68. });
  69. }
  70. set
  71. {
  72. Debug.LogWarning("Animator: Variable Animator.isPaused is read-only!");
  73. }
  74. }
  75. public static string nowPlayingTake
  76. {
  77. get
  78. {
  79. return (string)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  80. {
  81. new object[]
  82. {
  83. 1
  84. }
  85. });
  86. }
  87. set
  88. {
  89. Debug.LogWarning("Animator: Variable Animator.nowPlayingTake is read-only!");
  90. }
  91. }
  92. public static float runningTime
  93. {
  94. get
  95. {
  96. return (float)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  97. {
  98. new object[]
  99. {
  100. 10
  101. }
  102. });
  103. }
  104. set
  105. {
  106. Debug.LogWarning("Animator: Variable Animator.runningTime is read-only!");
  107. }
  108. }
  109. public static float totalTime
  110. {
  111. get
  112. {
  113. return (float)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  114. {
  115. new object[]
  116. {
  117. 11
  118. }
  119. });
  120. }
  121. set
  122. {
  123. Debug.LogWarning("Animator: Variable Animator.totalTime is read-only!");
  124. }
  125. }
  126. public static void Play(string takeName, bool loop = false)
  127. {
  128. if (AnimatorTimeline.aData)
  129. {
  130. AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  131. {
  132. new object[]
  133. {
  134. 2,
  135. takeName,
  136. loop
  137. }
  138. });
  139. }
  140. }
  141. public static void Stop()
  142. {
  143. if (AnimatorTimeline.aData)
  144. {
  145. AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  146. {
  147. new object[]
  148. {
  149. 3
  150. }
  151. });
  152. }
  153. }
  154. public static void Pause()
  155. {
  156. if (AnimatorTimeline.aData)
  157. {
  158. AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  159. {
  160. new object[]
  161. {
  162. 4
  163. }
  164. });
  165. }
  166. }
  167. public static void Resume()
  168. {
  169. if (AnimatorTimeline.aData)
  170. {
  171. AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  172. {
  173. new object[]
  174. {
  175. 5
  176. }
  177. });
  178. }
  179. }
  180. public static void PlayFromTime(string takeName, float time, bool loop = false)
  181. {
  182. if (AnimatorTimeline.aData)
  183. {
  184. AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  185. {
  186. new object[]
  187. {
  188. 6,
  189. takeName,
  190. time,
  191. loop
  192. }
  193. });
  194. }
  195. }
  196. public static void PlayFromFrame(string takeName, int frame, bool loop = false)
  197. {
  198. if (AnimatorTimeline.aData)
  199. {
  200. AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  201. {
  202. new object[]
  203. {
  204. 7,
  205. takeName,
  206. frame,
  207. loop
  208. }
  209. });
  210. }
  211. }
  212. public static void PreviewFrame(string takeName, float frame)
  213. {
  214. if (AnimatorTimeline.aData)
  215. {
  216. AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  217. {
  218. new object[]
  219. {
  220. 8,
  221. takeName,
  222. frame
  223. }
  224. });
  225. }
  226. }
  227. public static void PreviewTime(string takeName, float time)
  228. {
  229. if (AnimatorTimeline.aData)
  230. {
  231. AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
  232. {
  233. new object[]
  234. {
  235. 9,
  236. takeName,
  237. time
  238. }
  239. });
  240. }
  241. }
  242. public static void ParseJSON(string textAssetName)
  243. {
  244. TextAsset textAsset = (TextAsset)Resources.Load(textAssetName);
  245. if (!textAsset)
  246. {
  247. Debug.LogError("Animator: Could not find TextAsset '" + textAssetName + ".txt', make sure it's placed in a Resources folder!");
  248. }
  249. AnimatorTimeline.ParseJSON(textAsset);
  250. }
  251. private static void ParseJSON(TextAsset json)
  252. {
  253. AnimatorTimeline.ParseJSONString(json.ToString());
  254. }
  255. public static void ParseJSONString(string json)
  256. {
  257. AnimatorTimeline.JSONTake j = JsonReader.Deserialize<AnimatorTimeline.JSONTake>(json);
  258. if (!AnimatorTimeline.parseJSONTake(j))
  259. {
  260. Debug.LogWarning("Animator: Error parsing JSON");
  261. }
  262. }
  263. private static AnimatorTimeline.JSONVector3[] getJSONVector3Array(Vector3[] v)
  264. {
  265. List<AnimatorTimeline.JSONVector3> list = new List<AnimatorTimeline.JSONVector3>();
  266. foreach (Vector3 value in v)
  267. {
  268. AnimatorTimeline.JSONVector3 jsonvector = new AnimatorTimeline.JSONVector3();
  269. jsonvector.setValue(value);
  270. list.Add(jsonvector);
  271. }
  272. return list.ToArray();
  273. }
  274. private static bool setInitialValue(AnimatorTimeline.JSONInit init)
  275. {
  276. string type = init.type;
  277. if (type != null)
  278. {
  279. if (AnimatorTimeline.<>f__switch$map1 == null)
  280. {
  281. AnimatorTimeline.<>f__switch$map1 = new Dictionary<string, int>(13)
  282. {
  283. {
  284. "position",
  285. 0
  286. },
  287. {
  288. "rotation",
  289. 1
  290. },
  291. {
  292. "orientation",
  293. 2
  294. },
  295. {
  296. "propertymorph",
  297. 3
  298. },
  299. {
  300. "propertyint",
  301. 4
  302. },
  303. {
  304. "propertylong",
  305. 5
  306. },
  307. {
  308. "propertyfloat",
  309. 6
  310. },
  311. {
  312. "propertydouble",
  313. 7
  314. },
  315. {
  316. "propertyvect2",
  317. 8
  318. },
  319. {
  320. "propertyvect3",
  321. 9
  322. },
  323. {
  324. "propertycolor",
  325. 10
  326. },
  327. {
  328. "propertyrect",
  329. 11
  330. },
  331. {
  332. "cameraswitcher",
  333. 12
  334. }
  335. };
  336. }
  337. int num;
  338. if (AnimatorTimeline.<>f__switch$map1.TryGetValue(type, out num))
  339. {
  340. switch (num)
  341. {
  342. case 0:
  343. if (init.position == null || init.go == null)
  344. {
  345. return false;
  346. }
  347. AnimatorTimeline.getGO(init.go).transform.position = init.position.toVector3();
  348. break;
  349. case 1:
  350. if (init.rotation == null || init.go == null)
  351. {
  352. return false;
  353. }
  354. AnimatorTimeline.getGO(init.go).transform.rotation = init.rotation.toQuaternion();
  355. break;
  356. case 2:
  357. if (init.position == null || init.go == null)
  358. {
  359. return false;
  360. }
  361. AnimatorTimeline.getGO(init.go).transform.LookAt(init.position.toVector3());
  362. break;
  363. case 3:
  364. if (init.go == null || init.floats == null)
  365. {
  366. return false;
  367. }
  368. AMTween.SetMorph(AnimatorTimeline.getCMP(init.go, "MegaMorph"), AnimatorTimeline.getMethodInfo(init.go, "MegaMorph", "SetPercent", new string[]
  369. {
  370. "System.Int32",
  371. "System.Single"
  372. }), init.floats);
  373. break;
  374. case 4:
  375. if (!AnimatorTimeline.setInitialValueForProperty(init, init._int))
  376. {
  377. return false;
  378. }
  379. break;
  380. case 5:
  381. if (!AnimatorTimeline.setInitialValueForProperty(init, init._long))
  382. {
  383. return false;
  384. }
  385. break;
  386. case 6:
  387. if (init.floats == null || init.floats.Length <= 0)
  388. {
  389. return false;
  390. }
  391. if (!AnimatorTimeline.setInitialValueForProperty(init, init.floats[0]))
  392. {
  393. return false;
  394. }
  395. break;
  396. case 7:
  397. if (!AnimatorTimeline.setInitialValueForProperty(init, init._double))
  398. {
  399. return false;
  400. }
  401. break;
  402. case 8:
  403. if (init._vect2 == null)
  404. {
  405. return false;
  406. }
  407. if (!AnimatorTimeline.setInitialValueForProperty(init, init._vect2.toVector2()))
  408. {
  409. return false;
  410. }
  411. break;
  412. case 9:
  413. if (init.position == null)
  414. {
  415. return false;
  416. }
  417. if (!AnimatorTimeline.setInitialValueForProperty(init, init.position.toVector3()))
  418. {
  419. return false;
  420. }
  421. break;
  422. case 10:
  423. if (init._color == null)
  424. {
  425. return false;
  426. }
  427. if (!AnimatorTimeline.setInitialValueForProperty(init, init._color.toColor()))
  428. {
  429. return false;
  430. }
  431. break;
  432. case 11:
  433. if (init._rect == null)
  434. {
  435. return false;
  436. }
  437. if (!AnimatorTimeline.setInitialValueForProperty(init, init._rect.toRect()))
  438. {
  439. return false;
  440. }
  441. break;
  442. case 12:
  443. if (init.strings != null && init.strings.Length > 0)
  444. {
  445. AnimatorTimeline.allCameras = new Camera[init.strings.Length];
  446. for (int i = 0; i < init.strings.Length; i++)
  447. {
  448. AnimatorTimeline.allCameras[i] = AnimatorTimeline.getGO(init.strings[i]).GetComponent<Camera>();
  449. }
  450. }
  451. if (init.typeExtra == "camera")
  452. {
  453. if (init.go == null)
  454. {
  455. return false;
  456. }
  457. AMTween.SetTopCamera(AnimatorTimeline.getGO(init.go).GetComponent<Camera>(), AnimatorTimeline.allCameras);
  458. }
  459. else
  460. {
  461. if (init._color == null)
  462. {
  463. return false;
  464. }
  465. AMTween.ShowColor(init._color.toColor());
  466. }
  467. break;
  468. case 13:
  469. goto IL_441;
  470. default:
  471. goto IL_441;
  472. }
  473. return true;
  474. }
  475. }
  476. IL_441:
  477. Debug.LogWarning("Animator: Error parsing initial value type '" + init.type + "'");
  478. return false;
  479. }
  480. private static bool setInitialValueForProperty(AnimatorTimeline.JSONInit init, object value)
  481. {
  482. if (init.go == null || value == null || init.strings == null || init.strings.Length < 2 || init.typeExtra == null)
  483. {
  484. return false;
  485. }
  486. if (init.typeExtra == "fieldInfo")
  487. {
  488. AnimatorTimeline.getFieldInfo(init.go, init.strings[0], init.strings[1]).SetValue(AnimatorTimeline.getCMP(init.go, init.strings[0]), value);
  489. }
  490. else
  491. {
  492. AnimatorTimeline.getPropertyInfo(init.go, init.strings[0], init.strings[1]).SetValue(AnimatorTimeline.getCMP(init.go, init.strings[0]), value, null);
  493. }
  494. return true;
  495. }
  496. private static bool parseJSONTake(AnimatorTimeline.JSONTake j)
  497. {
  498. AnimatorTimeline.dictGameObjects = new Dictionary<string, GameObject>();
  499. AnimatorTimeline.dictComponents = new Dictionary<string, Component>();
  500. AnimatorTimeline.dictMethodInfos = new Dictionary<string, MethodInfo>();
  501. AnimatorTimeline.dictFieldInfos = new Dictionary<string, FieldInfo>();
  502. AnimatorTimeline.dictPropertyInfos = new Dictionary<string, PropertyInfo>();
  503. AnimatorTimeline.allCameras = null;
  504. bool flag = false;
  505. if (j.inits != null)
  506. {
  507. foreach (AnimatorTimeline.JSONInit initialValue in j.inits)
  508. {
  509. if (!AnimatorTimeline.setInitialValue(initialValue))
  510. {
  511. flag = true;
  512. }
  513. }
  514. }
  515. if (j.actions != null)
  516. {
  517. AnimatorTimeline.JSONAction[] actions = j.actions;
  518. int k = 0;
  519. while (k < actions.Length)
  520. {
  521. AnimatorTimeline.JSONAction jsonaction = actions[k];
  522. string method = jsonaction.method;
  523. if (method == null)
  524. {
  525. goto IL_249;
  526. }
  527. if (AnimatorTimeline.<>f__switch$map2 == null)
  528. {
  529. AnimatorTimeline.<>f__switch$map2 = new Dictionary<string, int>(10)
  530. {
  531. {
  532. "moveto",
  533. 0
  534. },
  535. {
  536. "rotateto",
  537. 1
  538. },
  539. {
  540. "lookfollow",
  541. 2
  542. },
  543. {
  544. "looktofollow",
  545. 3
  546. },
  547. {
  548. "playanimation",
  549. 4
  550. },
  551. {
  552. "playaudio",
  553. 5
  554. },
  555. {
  556. "propertyto",
  557. 6
  558. },
  559. {
  560. "sendmessage",
  561. 7
  562. },
  563. {
  564. "invokemethod",
  565. 8
  566. },
  567. {
  568. "camerafade",
  569. 9
  570. }
  571. };
  572. }
  573. int num;
  574. if (!AnimatorTimeline.<>f__switch$map2.TryGetValue(method, out num))
  575. {
  576. goto IL_249;
  577. }
  578. switch (num)
  579. {
  580. case 0:
  581. if (!AnimatorTimeline.parseMoveTo(jsonaction))
  582. {
  583. flag = true;
  584. }
  585. break;
  586. case 1:
  587. if (!AnimatorTimeline.parseRotateTo(jsonaction))
  588. {
  589. flag = true;
  590. }
  591. break;
  592. case 2:
  593. if (!AnimatorTimeline.parseLookFollow(jsonaction))
  594. {
  595. flag = true;
  596. }
  597. break;
  598. case 3:
  599. if (!AnimatorTimeline.parseLookToFollow(jsonaction))
  600. {
  601. flag = true;
  602. }
  603. break;
  604. case 4:
  605. if (!AnimatorTimeline.parsePlayAnimation(jsonaction))
  606. {
  607. flag = true;
  608. }
  609. break;
  610. case 5:
  611. if (!AnimatorTimeline.parsePlayAudio(jsonaction))
  612. {
  613. flag = true;
  614. }
  615. break;
  616. case 6:
  617. if (!AnimatorTimeline.parsePropertyTo(jsonaction))
  618. {
  619. flag = true;
  620. }
  621. break;
  622. case 7:
  623. if (!AnimatorTimeline.parseSendMessage(jsonaction))
  624. {
  625. flag = true;
  626. }
  627. break;
  628. case 8:
  629. if (!AnimatorTimeline.parseInvokeMethod(jsonaction))
  630. {
  631. flag = true;
  632. }
  633. break;
  634. case 9:
  635. if (!AnimatorTimeline.parseCameraFade(jsonaction))
  636. {
  637. flag = true;
  638. }
  639. break;
  640. case 10:
  641. goto IL_249;
  642. default:
  643. goto IL_249;
  644. }
  645. IL_26B:
  646. k++;
  647. continue;
  648. IL_249:
  649. Debug.LogWarning("Animator: Error parsing method '" + jsonaction.method + "'");
  650. flag = true;
  651. goto IL_26B;
  652. }
  653. }
  654. AMTween.StartDisabled();
  655. return !flag;
  656. }
  657. private static bool parseCameraFade(AnimatorTimeline.JSONAction a)
  658. {
  659. if (a.ints == null || a.ints.Length < 3)
  660. {
  661. Debug.LogWarning("Animator: CameraFade missing fade type, start or end targets.");
  662. return false;
  663. }
  664. if (a.strings == null || a.strings.Length < 2 || a.colors == null || a.colors.Length < 2)
  665. {
  666. Debug.LogWarning("Animator: CameraFade missing start or end targets.");
  667. return false;
  668. }
  669. Hashtable hashtable = new Hashtable();
  670. hashtable.Add("time", a.time);
  671. hashtable.Add("delay", a.delay);
  672. AnimatorTimeline.setupHashEase(hashtable, a);
  673. if (a.bools != null && a.bools.Length > 0)
  674. {
  675. hashtable.Add("reversed", a.bools[0]);
  676. }
  677. if (a.ints[1] == 0 || a.ints[2] == 0)
  678. {
  679. hashtable.Add("allcameras", AnimatorTimeline.allCameras);
  680. }
  681. if (a.stringsExtra != null && a.stringsExtra.Length > 0)
  682. {
  683. hashtable.Add("texture", AMTween.LoadTexture2D(a.stringsExtra[0]));
  684. }
  685. if (a.ints[1] == 0)
  686. {
  687. hashtable.Add("camera1", AnimatorTimeline.getGO(a.strings[0]).GetComponent<Camera>());
  688. }
  689. else
  690. {
  691. hashtable.Add("color1", a.colors[0].toColor());
  692. }
  693. if (a.ints[2] == 0)
  694. {
  695. hashtable.Add("camera2", AnimatorTimeline.getGO(a.strings[1]).GetComponent<Camera>());
  696. }
  697. else
  698. {
  699. hashtable.Add("color2", a.colors[1].toColor());
  700. }
  701. float[] array = a.floats;
  702. if (array == null)
  703. {
  704. array = new float[0];
  705. }
  706. AMTween.CameraFade(a.ints[0], a.bools != null && a.bools.Length >= 2 && a.bools[1], array, hashtable);
  707. return true;
  708. }
  709. private static bool parseInvokeMethod(AnimatorTimeline.JSONAction a)
  710. {
  711. if (a.strings == null || a.strings.Length < 2)
  712. {
  713. Debug.LogWarning("Animator: SendMessage missing Component or MethodInfo Name.");
  714. return false;
  715. }
  716. Hashtable hashtable = new Hashtable();
  717. hashtable.Add("disable", true);
  718. hashtable.Add("delay", a.delay);
  719. hashtable.Add("methodinfo", AnimatorTimeline.getMethodInfo(a.go, a.strings[0], a.strings[1], null));
  720. if (a.eventParams != null && a.eventParams.Length > 0)
  721. {
  722. object[] array = new object[a.eventParams.Length];
  723. for (int i = 0; i < a.eventParams.Length; i++)
  724. {
  725. array[i] = a.eventParams[i].toObject();
  726. }
  727. if (array.Length <= 0)
  728. {
  729. array = null;
  730. }
  731. hashtable.Add("parameters", array);
  732. }
  733. AMTween.InvokeMethod(AnimatorTimeline.getCMP(a.go, a.strings[0]), hashtable);
  734. return true;
  735. }
  736. private static bool parseSendMessage(AnimatorTimeline.JSONAction a)
  737. {
  738. if (a.strings == null || a.strings.Length < 1)
  739. {
  740. Debug.LogWarning("Animator: SendMessage missing Method Name.");
  741. return false;
  742. }
  743. Hashtable hashtable = new Hashtable();
  744. hashtable.Add("disable", true);
  745. hashtable.Add("delay", a.delay);
  746. hashtable.Add("methodname", a.strings[0]);
  747. if (a.eventParams != null && a.eventParams.Length > 0)
  748. {
  749. hashtable.Add("parameter", a.eventParams[0].toObject());
  750. }
  751. AMTween.SendMessage(AnimatorTimeline.getGO(a.go), hashtable);
  752. return true;
  753. }
  754. private static bool parsePropertyTo(AnimatorTimeline.JSONAction a)
  755. {
  756. Hashtable hashtable = new Hashtable();
  757. hashtable.Add("disable", true);
  758. hashtable.Add("delay", a.delay);
  759. hashtable.Add("time", a.time);
  760. AnimatorTimeline.setupHashEase(hashtable, a);
  761. if (a.strings == null || a.strings.Length < 2)
  762. {
  763. Debug.LogWarning("Animator: PropertyTo missing Component or property type.");
  764. return false;
  765. }
  766. string componentName = a.strings[0];
  767. bool flag = false;
  768. string text = a.strings[1];
  769. if (text != null)
  770. {
  771. if (AnimatorTimeline.<>f__switch$map3 == null)
  772. {
  773. AnimatorTimeline.<>f__switch$map3 = new Dictionary<string, int>(9)
  774. {
  775. {
  776. "morph",
  777. 0
  778. },
  779. {
  780. "integer",
  781. 1
  782. },
  783. {
  784. "long",
  785. 2
  786. },
  787. {
  788. "float",
  789. 3
  790. },
  791. {
  792. "double",
  793. 4
  794. },
  795. {
  796. "vector2",
  797. 5
  798. },
  799. {
  800. "vector3",
  801. 6
  802. },
  803. {
  804. "color",
  805. 7
  806. },
  807. {
  808. "rect",
  809. 8
  810. }
  811. };
  812. }
  813. int num;
  814. if (AnimatorTimeline.<>f__switch$map3.TryGetValue(text, out num))
  815. {
  816. switch (num)
  817. {
  818. case 0:
  819. if (a.floats == null || a.floatsExtra == null)
  820. {
  821. flag = true;
  822. }
  823. hashtable.Add("methodtype", "morph");
  824. hashtable.Add("methodinfo", AnimatorTimeline.getMethodInfo(a.go, "MegaMorph", "SetPercent", new string[]
  825. {
  826. "System.Int32",
  827. "System.Single"
  828. }));
  829. hashtable.Add("from", a.floats);
  830. hashtable.Add("to", a.floatsExtra);
  831. break;
  832. case 1:
  833. if (a.ints == null || a.ints.Length < 2)
  834. {
  835. flag = true;
  836. }
  837. hashtable.Add("from", a.ints[0]);
  838. hashtable.Add("to", a.ints[1]);
  839. AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
  840. break;
  841. case 2:
  842. if (a.longs == null || a.longs.Length < 2)
  843. {
  844. flag = true;
  845. }
  846. hashtable.Add("from", a.longs[0]);
  847. hashtable.Add("to", a.longs[1]);
  848. AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
  849. break;
  850. case 3:
  851. if (a.floats == null || a.floats.Length < 2)
  852. {
  853. flag = true;
  854. }
  855. hashtable.Add("from", a.floats[0]);
  856. hashtable.Add("to", a.floats[1]);
  857. AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
  858. break;
  859. case 4:
  860. if (a.doubles == null || a.doubles.Length < 2)
  861. {
  862. flag = true;
  863. }
  864. hashtable.Add("from", a.doubles[0]);
  865. hashtable.Add("to", a.doubles[1]);
  866. AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
  867. break;
  868. case 5:
  869. if (a.vect2s == null || a.vect2s.Length < 2)
  870. {
  871. flag = true;
  872. }
  873. hashtable.Add("from", a.vect2s[0].toVector2());
  874. hashtable.Add("to", a.vect2s[1].toVector2());
  875. AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
  876. break;
  877. case 6:
  878. if (a.path == null || a.path.Length < 2)
  879. {
  880. flag = true;
  881. }
  882. hashtable.Add("from", a.path[0].toVector3());
  883. hashtable.Add("to", a.path[1].toVector3());
  884. AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
  885. break;
  886. case 7:
  887. if (a.colors == null || a.colors.Length < 2)
  888. {
  889. flag = true;
  890. }
  891. hashtable.Add("from", a.colors[0].toColor());
  892. hashtable.Add("to", a.colors[1].toColor());
  893. AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
  894. break;
  895. case 8:
  896. if (a.rects == null || a.rects.Length < 2)
  897. {
  898. flag = true;
  899. }
  900. hashtable.Add("from", a.rects[0].toRect());
  901. hashtable.Add("to", a.rects[1].toRect());
  902. AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
  903. break;
  904. case 9:
  905. goto IL_4C3;
  906. default:
  907. goto IL_4C3;
  908. }
  909. if (flag)
  910. {
  911. Debug.LogWarning("Animator: PropertyTo missing 'to' or 'from' targets.");
  912. return false;
  913. }
  914. AMTween.PropertyTo(AnimatorTimeline.getCMP(a.go, componentName), hashtable);
  915. return true;
  916. }
  917. }
  918. IL_4C3:
  919. Debug.LogWarning("Animator: PropertyTo unknown property type '" + a.strings[1] + "'.");
  920. return false;
  921. }
  922. private static void setupHashFieldOrPropertyInfo(Hashtable hash, AnimatorTimeline.JSONAction a)
  923. {
  924. if (a.strings.Length < 4)
  925. {
  926. Debug.LogWarning("Animator: PropertyTo missing Component or property type.");
  927. return;
  928. }
  929. if (a.strings[2] == "fieldinfo")
  930. {
  931. hash.Add("fieldinfo", AnimatorTimeline.getFieldInfo(a.go, a.strings[0], a.strings[3]));
  932. }
  933. else
  934. {
  935. hash.Add("propertyinfo", AnimatorTimeline.getPropertyInfo(a.go, a.strings[0], a.strings[3]));
  936. }
  937. }
  938. private static bool parsePlayAudio(AnimatorTimeline.JSONAction a)
  939. {
  940. Hashtable hashtable = new Hashtable();
  941. hashtable.Add("disable", true);
  942. hashtable.Add("delay", a.delay);
  943. if (a.strings.Length < 1)
  944. {
  945. Debug.LogWarning("Animator: PlayAudio missing 'audioclip' clip name.");
  946. return false;
  947. }
  948. AudioClip audioClip = (AudioClip)Resources.Load(a.strings[0]);
  949. if (audioClip == null)
  950. {
  951. Debug.LogWarning("Animator: Could not find AudioClip '" + a.strings[0] + "'. Make sure the audio file is placed in a Resources folder!");
  952. return false;
  953. }
  954. hashtable.Add("audioclip", audioClip);
  955. if (a.bools.Length >= 1)
  956. {
  957. hashtable.Add("loop", a.bools[0]);
  958. AMTween.PlayAudio((AudioSource)AnimatorTimeline.getCMP(a.go, "AudioSource"), hashtable);
  959. return true;
  960. }
  961. Debug.LogWarning("Animator: PlayAudio missing 'loop'.");
  962. return false;
  963. }
  964. private static bool parsePlayAnimation(AnimatorTimeline.JSONAction a)
  965. {
  966. Hashtable hashtable = new Hashtable();
  967. hashtable.Add("disable", true);
  968. hashtable.Add("delay", a.delay);
  969. if (a.strings.Length < 1)
  970. {
  971. Debug.LogWarning("Animator: PlayAnimation missing 'animation' clip name.");
  972. return false;
  973. }
  974. hashtable.Add("animation", a.strings[0]);
  975. if (a.floats.Length < 2)
  976. {
  977. Debug.LogWarning("Animator: PlayAnimation missing 'wrapmode' or 'fadeLength'.");
  978. return false;
  979. }
  980. hashtable.Add("wrapmode", (WrapMode)a.floats[0]);
  981. hashtable.Add("fadeLength", a.floats[1]);
  982. if (a.bools.Length >= 1)
  983. {
  984. hashtable.Add("crossfade", a.bools[0]);
  985. AMTween.PlayAnimation(AnimatorTimeline.getGO(a.go), hashtable);
  986. return true;
  987. }
  988. Debug.LogWarning("Animator: PlayAnimation missing 'crossfade'.");
  989. return false;
  990. }
  991. private static bool parseLookToFollow(AnimatorTimeline.JSONAction a)
  992. {
  993. Hashtable hashtable = new Hashtable();
  994. hashtable.Add("disable", true);
  995. hashtable.Add("delay", a.delay);
  996. hashtable.Add("time", a.time);
  997. AnimatorTimeline.setupHashEase(hashtable, a);
  998. if (a.strings.Length >= 1)
  999. {
  1000. hashtable.Add("looktarget", AnimatorTimeline.getGO(a.strings[0]).transform);
  1001. if (a.path != null && a.path.Length >= 1)
  1002. {
  1003. hashtable.Add("endposition", a.path[0].toVector3());
  1004. }
  1005. AMTween.LookToFollow(AnimatorTimeline.getGO(a.go), hashtable);
  1006. return true;
  1007. }
  1008. Debug.LogWarning("Animator: LookFollow missing 'looktarget'.");
  1009. return false;
  1010. }
  1011. private static bool parseLookFollow(AnimatorTimeline.JSONAction a)
  1012. {
  1013. Hashtable hashtable = new Hashtable();
  1014. hashtable.Add("disable", true);
  1015. hashtable.Add("delay", a.delay);
  1016. hashtable.Add("time", a.time);
  1017. AnimatorTimeline.setupHashEase(hashtable, a);
  1018. if (a.strings.Length >= 1)
  1019. {
  1020. hashtable.Add("looktarget", AnimatorTimeline.getGO(a.strings[0]).transform);
  1021. AMTween.LookFollow(AnimatorTimeline.getGO(a.go), hashtable);
  1022. return true;
  1023. }
  1024. Debug.LogWarning("Animator: LookFollow missing 'looktarget'.");
  1025. return false;
  1026. }
  1027. private static bool parseMoveTo(AnimatorTimeline.JSONAction a)
  1028. {
  1029. Hashtable hashtable = new Hashtable();
  1030. hashtable.Add("disable", true);
  1031. hashtable.Add("delay", a.delay);
  1032. hashtable.Add("time", a.time);
  1033. AnimatorTimeline.setupHashEase(hashtable, a);
  1034. if (a.path.Length > 1)
  1035. {
  1036. hashtable.Add("path", a.getVector3Path());
  1037. }
  1038. else
  1039. {
  1040. if (a.path.Length != 1)
  1041. {
  1042. Debug.LogWarning("Animator: MoveTo missing 'position' or 'path'.");
  1043. return false;
  1044. }
  1045. hashtable.Add("position", a.path[0].toVector3());
  1046. }
  1047. AMTween.MoveTo(AnimatorTimeline.getGO(a.go), hashtable);
  1048. return true;
  1049. }
  1050. private static bool parseRotateTo(AnimatorTimeline.JSONAction a)
  1051. {
  1052. Hashtable hashtable = new Hashtable();
  1053. hashtable.Add("disable", true);
  1054. hashtable.Add("delay", a.delay);
  1055. hashtable.Add("time", a.time);
  1056. AnimatorTimeline.setupHashEase(hashtable, a);
  1057. if (a.path.Length >= 1)
  1058. {
  1059. hashtable.Add("rotation", a.path[0].toVector3());
  1060. AMTween.RotateTo(AnimatorTimeline.getGO(a.go), hashtable);
  1061. return true;
  1062. }
  1063. Debug.LogWarning("Animator: RotateTo missing 'rotation'.");
  1064. return false;
  1065. }
  1066. private static void setupHashEase(Hashtable hashTable, AnimatorTimeline.JSONAction a)
  1067. {
  1068. if (a.customEase.Length > 0)
  1069. {
  1070. AnimationCurve value = AMTween.GenerateCurve(a.customEase);
  1071. hashTable.Add("easecurve", value);
  1072. }
  1073. else
  1074. {
  1075. hashTable.Add("easetype", (AMTween.EaseType)a.easeType);
  1076. }
  1077. }
  1078. private static GameObject getGO(string name)
  1079. {
  1080. if (name == null)
  1081. {
  1082. Debug.LogWarning("Animator: Error parsing GameObject with null value");
  1083. return null;
  1084. }
  1085. if (AnimatorTimeline.dictGameObjects.ContainsKey(name))
  1086. {
  1087. return AnimatorTimeline.dictGameObjects[name];
  1088. }
  1089. GameObject gameObject = GameObject.Find(name);
  1090. if (!gameObject)
  1091. {
  1092. Debug.LogWarning("Animator: Error parsing JSON; Could not find GameObject '" + name + "'.");
  1093. }
  1094. AnimatorTimeline.dictGameObjects.Add(name, gameObject);
  1095. return gameObject;
  1096. }
  1097. private static Component getCMP(string goName, string componentName)
  1098. {
  1099. if (goName == null || componentName == null)
  1100. {
  1101. Debug.LogWarning("Animator: Error parsing GameObject or Component with null value: " + goName + ", " + componentName);
  1102. return null;
  1103. }
  1104. string key = goName + "." + componentName;
  1105. if (AnimatorTimeline.dictComponents.ContainsKey(key))
  1106. {
  1107. return AnimatorTimeline.dictComponents[key];
  1108. }
  1109. GameObject go = AnimatorTimeline.getGO(goName);
  1110. Component component = go.GetComponent(componentName);
  1111. if (!component)
  1112. {
  1113. Debug.LogWarning(string.Concat(new string[]
  1114. {
  1115. "Animator: Error parsing JSON; Could not find Component '",
  1116. componentName,
  1117. "' on GameObject '",
  1118. goName,
  1119. "'."
  1120. }));
  1121. }
  1122. AnimatorTimeline.dictComponents.Add(key, component);
  1123. return component;
  1124. }
  1125. private static MethodInfo getMethodInfo(string goName, string componentName, string methodName, string[] typeNames)
  1126. {
  1127. if (methodName == null || componentName == null)
  1128. {
  1129. Debug.LogWarning("Animator: Error parsing MethodInfo or Component with null value");
  1130. return null;
  1131. }
  1132. string text = componentName + "." + methodName;
  1133. List<Type> list = new List<Type>();
  1134. if (typeNames != null)
  1135. {
  1136. for (int i = 0; i < typeNames.Length; i++)
  1137. {
  1138. text = text + "." + typeNames[i];
  1139. }
  1140. foreach (string typeName in typeNames)
  1141. {
  1142. list.Add(Type.GetType(typeName));
  1143. }
  1144. }
  1145. if (AnimatorTimeline.dictMethodInfos.ContainsKey(text))
  1146. {
  1147. return AnimatorTimeline.dictMethodInfos[text];
  1148. }
  1149. MethodInfo method;
  1150. if (typeNames == null)
  1151. {
  1152. method = AnimatorTimeline.getCMP(goName, componentName).GetType().GetMethod(methodName);
  1153. }
  1154. else
  1155. {
  1156. method = AnimatorTimeline.getCMP(goName, componentName).GetType().GetMethod(methodName, list.ToArray());
  1157. }
  1158. AnimatorTimeline.dictMethodInfos.Add(text, method);
  1159. return AnimatorTimeline.dictMethodInfos[text];
  1160. }
  1161. private static FieldInfo getFieldInfo(string goName, string componentName, string fieldName)
  1162. {
  1163. if (fieldName == null || componentName == null)
  1164. {
  1165. Debug.LogWarning("Animator: Error parsing FieldInfo or Component with null value");
  1166. return null;
  1167. }
  1168. string key = componentName + "." + fieldName;
  1169. if (AnimatorTimeline.dictFieldInfos.ContainsKey(key))
  1170. {
  1171. return AnimatorTimeline.dictFieldInfos[key];
  1172. }
  1173. AnimatorTimeline.dictFieldInfos.Add(key, AnimatorTimeline.getCMP(goName, componentName).GetType().GetField(fieldName));
  1174. return AnimatorTimeline.dictFieldInfos[key];
  1175. }
  1176. private static PropertyInfo getPropertyInfo(string goName, string componentName, string propertyName)
  1177. {
  1178. if (propertyName == null || componentName == null)
  1179. {
  1180. Debug.LogWarning("Animator: Error parsing PropertyInfo or Component with null value");
  1181. return null;
  1182. }
  1183. string key = componentName + "." + propertyName;
  1184. if (AnimatorTimeline.dictPropertyInfos.ContainsKey(key))
  1185. {
  1186. return AnimatorTimeline.dictPropertyInfos[key];
  1187. }
  1188. AnimatorTimeline.dictPropertyInfos.Add(key, AnimatorTimeline.getCMP(goName, componentName).GetType().GetProperty(propertyName));
  1189. return AnimatorTimeline.dictPropertyInfos[key];
  1190. }
  1191. private static Component _aData;
  1192. private static MethodInfo cachedInvoker;
  1193. private static Dictionary<string, GameObject> dictGameObjects;
  1194. private static Dictionary<string, Component> dictComponents;
  1195. private static Dictionary<string, MethodInfo> dictMethodInfos;
  1196. private static Dictionary<string, FieldInfo> dictFieldInfos;
  1197. private static Dictionary<string, PropertyInfo> dictPropertyInfos;
  1198. private static Camera[] allCameras;
  1199. public class JSONTake
  1200. {
  1201. public string takeName;
  1202. public AnimatorTimeline.JSONInit[] inits;
  1203. public AnimatorTimeline.JSONAction[] actions;
  1204. }
  1205. public class JSONInit
  1206. {
  1207. public string type;
  1208. public string typeExtra;
  1209. public string go;
  1210. public AnimatorTimeline.JSONVector3 position;
  1211. public AnimatorTimeline.JSONQuaternion rotation;
  1212. public float[] floats;
  1213. public string[] strings;
  1214. public string[] stringsExtra;
  1215. public int _int;
  1216. public long _long;
  1217. public double _double;
  1218. public AnimatorTimeline.JSONVector2 _vect2;
  1219. public AnimatorTimeline.JSONColor _color;
  1220. public AnimatorTimeline.JSONRect _rect;
  1221. }
  1222. public class JSONAction
  1223. {
  1224. public void setPath(Vector3[] _path)
  1225. {
  1226. this.path = AnimatorTimeline.getJSONVector3Array(_path);
  1227. }
  1228. public Vector3[] getVector3Path()
  1229. {
  1230. List<Vector3> list = new List<Vector3>();
  1231. for (int i = 0; i < this.path.Length; i++)
  1232. {
  1233. list.Add(this.path[i].toVector3());
  1234. }
  1235. return list.ToArray();
  1236. }
  1237. public string method;
  1238. public string go;
  1239. public float delay;
  1240. public float time;
  1241. public int easeType;
  1242. public float[] customEase;
  1243. public string[] strings;
  1244. public string[] stringsExtra;
  1245. public float[] floats;
  1246. public float[] floatsExtra;
  1247. public bool[] bools;
  1248. public int[] ints;
  1249. public long[] longs;
  1250. public double[] doubles;
  1251. public AnimatorTimeline.JSONVector3[] path;
  1252. public AnimatorTimeline.JSONVector2[] vect2s;
  1253. public AnimatorTimeline.JSONColor[] colors;
  1254. public AnimatorTimeline.JSONRect[] rects;
  1255. public AnimatorTimeline.JSONEventParameter[] eventParams;
  1256. }
  1257. public class JSONEventParameter
  1258. {
  1259. public object toObject()
  1260. {
  1261. if (this.valueType == 13)
  1262. {
  1263. return this.val_bool;
  1264. }
  1265. if (this.valueType == 9)
  1266. {
  1267. return this.val_string;
  1268. }
  1269. if (this.valueType == 10)
  1270. {
  1271. if (this.val_string == null || this.val_string.Length <= 0)
  1272. {
  1273. return '\0';
  1274. }
  1275. return this.val_string[0];
  1276. }
  1277. else
  1278. {
  1279. if (this.valueType == 0 || this.valueType == 1)
  1280. {
  1281. return this.val_int;
  1282. }
  1283. if (this.valueType == 2 || this.valueType == 3)
  1284. {
  1285. return this.val_float;
  1286. }
  1287. if (this.valueType == 4)
  1288. {
  1289. return this.val_vect2;
  1290. }
  1291. if (this.valueType == 5)
  1292. {
  1293. return this.val_vect3;
  1294. }
  1295. if (this.valueType == 6)
  1296. {
  1297. return this.val_vect4;
  1298. }
  1299. if (this.valueType == 7)
  1300. {
  1301. return this.val_color;
  1302. }
  1303. if (this.valueType == 8)
  1304. {
  1305. return this.val_rect;
  1306. }
  1307. if (this.valueType != 11)
  1308. {
  1309. if (this.valueType == 12)
  1310. {
  1311. if (this.array == null || this.array.Length <= 0)
  1312. {
  1313. Debug.LogError("Animator: Expected array parameters in JSON");
  1314. return null;
  1315. }
  1316. if (this.array[0].valueType == 13)
  1317. {
  1318. bool[] array = new bool[this.array.Length];
  1319. for (int i = 0; i < this.array.Length; i++)
  1320. {
  1321. array[i] = this.array[i].val_bool;
  1322. }
  1323. return array;
  1324. }
  1325. if (this.array[0].valueType == 9)
  1326. {
  1327. string[] array2 = new string[this.array.Length];
  1328. for (int j = 0; j < this.array.Length; j++)
  1329. {
  1330. array2[j] = this.array[j].val_string;
  1331. }
  1332. return array2;
  1333. }
  1334. if (this.array[0].valueType == 10)
  1335. {
  1336. char[] array3 = new char[this.array.Length];
  1337. for (int k = 0; k < this.array.Length; k++)
  1338. {
  1339. array3[k] = this.array[k].val_string[0];
  1340. }
  1341. return array3;
  1342. }
  1343. if (this.array[0].valueType == 0 || this.array[0].valueType == 1)
  1344. {
  1345. int[] array4 = new int[this.array.Length];
  1346. for (int l = 0; l < this.array.Length; l++)
  1347. {
  1348. array4[l] = this.array[l].val_int;
  1349. }
  1350. return array4;
  1351. }
  1352. if (this.array[0].valueType == 2 || this.array[0].valueType == 3)
  1353. {
  1354. float[] array5 = new float[this.array.Length];
  1355. for (int m = 0; m < this.array.Length; m++)
  1356. {
  1357. array5[m] = this.array[m].val_float;
  1358. }
  1359. return array5;
  1360. }
  1361. if (this.array[0].valueType == 4)
  1362. {
  1363. Vector2[] array6 = new Vector2[this.array.Length];
  1364. for (int n = 0; n < this.array.Length; n++)
  1365. {
  1366. array6[n] = this.array[n].val_vect2.toVector2();
  1367. }
  1368. return array6;
  1369. }
  1370. if (this.array[0].valueType == 5)
  1371. {
  1372. Vector3[] array7 = new Vector3[this.array.Length];
  1373. for (int num = 0; num < this.array.Length; num++)
  1374. {
  1375. array7[num] = this.array[num].val_vect3.toVector3();
  1376. }
  1377. return array7;
  1378. }
  1379. if (this.array[0].valueType == 6)
  1380. {
  1381. Vector4[] array8 = new Vector4[this.array.Length];
  1382. for (int num2 = 0; num2 < this.array.Length; num2++)
  1383. {
  1384. array8[num2] = this.array[num2].val_vect4.toVector4();
  1385. }
  1386. return array8;
  1387. }
  1388. if (this.array[0].valueType == 7)
  1389. {
  1390. Color[] array9 = new Color[this.array.Length];
  1391. for (int num3 = 0; num3 < this.array.Length; num3++)
  1392. {
  1393. array9[num3] = this.array[num3].val_color.toColor();
  1394. }
  1395. return array9;
  1396. }
  1397. if (this.array[0].valueType == 8)
  1398. {
  1399. Rect[] array10 = new Rect[this.array.Length];
  1400. for (int num4 = 0; num4 < this.array.Length; num4++)
  1401. {
  1402. array10[num4] = this.array[num4].val_rect.toRect();
  1403. }
  1404. return array10;
  1405. }
  1406. if (this.array[0].valueType == 11)
  1407. {
  1408. UnityEngine.Object[] array11 = new UnityEngine.Object[this.array.Length];
  1409. for (int num5 = 0; num5 < this.array.Length; num5++)
  1410. {
  1411. array11[num5] = AnimatorTimeline.getGO(this.array[num5].val_obj);
  1412. }
  1413. return array11;
  1414. }
  1415. }
  1416. Debug.LogError("Animator: Type not found for Event Parameter valueType " + this.valueType);
  1417. return null;
  1418. }
  1419. if (this.val_obj_extra == null)
  1420. {
  1421. return AnimatorTimeline.getGO(this.val_obj);
  1422. }
  1423. return AnimatorTimeline.getCMP(this.val_obj_extra, this.val_obj);
  1424. }
  1425. }
  1426. public int valueType;
  1427. public bool val_bool;
  1428. public int val_int;
  1429. public float val_float;
  1430. public AnimatorTimeline.JSONVector2 val_vect2;
  1431. public AnimatorTimeline.JSONVector3 val_vect3;
  1432. public AnimatorTimeline.JSONVector4 val_vect4;
  1433. public AnimatorTimeline.JSONColor val_color;
  1434. public AnimatorTimeline.JSONRect val_rect;
  1435. public string val_string;
  1436. public string val_obj;
  1437. public string val_obj_extra;
  1438. public AnimatorTimeline.JSONEventParameter[] array;
  1439. public enum ValueType
  1440. {
  1441. Integer,
  1442. Long,
  1443. Float,
  1444. Double,
  1445. Vector2,
  1446. Vector3,
  1447. Vector4,
  1448. Color,
  1449. Rect,
  1450. String,
  1451. Char,
  1452. Object,
  1453. Array,
  1454. Boolean
  1455. }
  1456. }
  1457. public class JSONVector4
  1458. {
  1459. public void setValue(Vector4 v)
  1460. {
  1461. this.x = v.x;
  1462. this.y = v.y;
  1463. this.z = v.z;
  1464. this.w = v.w;
  1465. }
  1466. public Vector4 toVector4()
  1467. {
  1468. return new Vector4(this.x, this.y, this.z, this.w);
  1469. }
  1470. public float x;
  1471. public float y;
  1472. public float z;
  1473. public float w;
  1474. }
  1475. public class JSONVector3
  1476. {
  1477. public void setValue(Vector3 v)
  1478. {
  1479. this.x = v.x;
  1480. this.y = v.y;
  1481. this.z = v.z;
  1482. }
  1483. public Vector3 toVector3()
  1484. {
  1485. return new Vector3(this.x, this.y, this.z);
  1486. }
  1487. public float x;
  1488. public float y;
  1489. public float z;
  1490. }
  1491. public class JSONVector2
  1492. {
  1493. public void setValue(Vector2 v)
  1494. {
  1495. this.x = v.x;
  1496. this.y = v.y;
  1497. }
  1498. public Vector2 toVector2()
  1499. {
  1500. return new Vector2(this.x, this.y);
  1501. }
  1502. public float x;
  1503. public float y;
  1504. }
  1505. public class JSONQuaternion
  1506. {
  1507. public void setValue(Vector4 q)
  1508. {
  1509. this.x = q.x;
  1510. this.y = q.y;
  1511. this.z = q.z;
  1512. this.w = q.w;
  1513. }
  1514. public Quaternion toQuaternion()
  1515. {
  1516. return new Quaternion(this.x, this.y, this.z, this.w);
  1517. }
  1518. public float x;
  1519. public float y;
  1520. public float z;
  1521. public float w;
  1522. }
  1523. public class JSONColor
  1524. {
  1525. public void setValue(Color c)
  1526. {
  1527. this.r = c.r;
  1528. this.g = c.g;
  1529. this.b = c.b;
  1530. this.a = c.a;
  1531. }
  1532. public Color toColor()
  1533. {
  1534. return new Color(this.r, this.g, this.b, this.a);
  1535. }
  1536. public float r;
  1537. public float g;
  1538. public float b;
  1539. public float a;
  1540. }
  1541. public class JSONRect
  1542. {
  1543. public void setValue(Rect r)
  1544. {
  1545. this.x = r.x;
  1546. this.y = r.y;
  1547. this.width = r.width;
  1548. this.height = r.height;
  1549. }
  1550. public Rect toRect()
  1551. {
  1552. return new Rect(this.x, this.y, this.width, this.height);
  1553. }
  1554. public float x;
  1555. public float y;
  1556. public float width;
  1557. public float height;
  1558. }
  1559. }