AMPropertyAction.cs 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using UnityEngine;
  5. [Serializable]
  6. public class AMPropertyAction : AMAction
  7. {
  8. public PropertyInfo propertyInfo
  9. {
  10. get
  11. {
  12. if (this.cachedPropertyInfo != null)
  13. {
  14. return this.cachedPropertyInfo;
  15. }
  16. if (!this.component || this.propertyName == null)
  17. {
  18. return null;
  19. }
  20. this.cachedPropertyInfo = this.component.GetType().GetProperty(this.propertyName);
  21. return this.cachedPropertyInfo;
  22. }
  23. set
  24. {
  25. if (value != null)
  26. {
  27. this.propertyName = value.Name;
  28. }
  29. else
  30. {
  31. this.propertyName = null;
  32. }
  33. this.cachedPropertyInfo = value;
  34. }
  35. }
  36. public FieldInfo fieldInfo
  37. {
  38. get
  39. {
  40. if (this.cachedFieldInfo != null)
  41. {
  42. return this.cachedFieldInfo;
  43. }
  44. if (!this.component || this.fieldName == null)
  45. {
  46. return null;
  47. }
  48. this.cachedFieldInfo = this.component.GetType().GetField(this.fieldName);
  49. return this.cachedFieldInfo;
  50. }
  51. set
  52. {
  53. if (value != null)
  54. {
  55. this.fieldName = value.Name;
  56. }
  57. else
  58. {
  59. this.fieldName = null;
  60. }
  61. this.cachedFieldInfo = value;
  62. }
  63. }
  64. public MethodInfo methodInfo
  65. {
  66. get
  67. {
  68. if (this.cachedMethodInfo != null)
  69. {
  70. return this.cachedMethodInfo;
  71. }
  72. if (!this.component || this.methodName == null)
  73. {
  74. return null;
  75. }
  76. Type[] array = new Type[this.methodParameterTypes.Length];
  77. for (int i = 0; i < this.methodParameterTypes.Length; i++)
  78. {
  79. array[i] = Type.GetType(this.methodParameterTypes[i]);
  80. }
  81. this.cachedMethodInfo = this.component.GetType().GetMethod(this.methodName, array);
  82. return this.cachedMethodInfo;
  83. }
  84. set
  85. {
  86. if (value != null)
  87. {
  88. this.methodName = value.Name;
  89. }
  90. else
  91. {
  92. this.methodName = null;
  93. }
  94. this.cachedMethodInfo = value;
  95. }
  96. }
  97. public override string ToString(int codeLanguage, int frameRate)
  98. {
  99. if (this.endFrame == -1 || this.targetsAreEqual())
  100. {
  101. return null;
  102. }
  103. string text = string.Empty;
  104. if (this.fieldInfo != null)
  105. {
  106. text = "fieldinfo";
  107. }
  108. else if (this.propertyInfo != null)
  109. {
  110. text = "propertyinfo";
  111. }
  112. else
  113. {
  114. if (this.methodInfo == null)
  115. {
  116. Debug.LogError("Animator: No FieldInfo or PropertyInfo set.");
  117. return "( Error: No FieldInfo, PropertyInfo or MethodInfo set. )";
  118. }
  119. text = "methodinfo";
  120. }
  121. if (codeLanguage == 0)
  122. {
  123. if (this.valueType == 8)
  124. {
  125. return string.Concat(new object[]
  126. {
  127. "AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", ",
  128. base.getWaitTime(frameRate, 0f),
  129. "f, \"time\", ",
  130. this.getTime(frameRate),
  131. "f, \"",
  132. text,
  133. "\", obj.memberinfo, \"methodtype\", \"morph\", \"from\", ",
  134. this.getFloatArrayString(codeLanguage, this.start_morph),
  135. ", \"to\", ",
  136. this.getFloatArrayString(codeLanguage, this.end_morph),
  137. ", ",
  138. base.getEaseString(codeLanguage),
  139. "));"
  140. });
  141. }
  142. if (AMPropertyTrack.isValueTypeNumeric(this.valueType))
  143. {
  144. return string.Concat(new object[]
  145. {
  146. "AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", ",
  147. base.getWaitTime(frameRate, 0f),
  148. "f, \"time\", ",
  149. this.getTime(frameRate),
  150. "f, \"",
  151. text,
  152. "\", obj.memberinfo, \"from\", ",
  153. this.start_val,
  154. "f,\"to\", ",
  155. this.end_val,
  156. "f, ",
  157. base.getEaseString(codeLanguage),
  158. "));"
  159. });
  160. }
  161. if (this.valueType == 4)
  162. {
  163. return string.Concat(new object[]
  164. {
  165. "AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", ",
  166. base.getWaitTime(frameRate, 0f),
  167. "f, \"time\", ",
  168. this.getTime(frameRate),
  169. "f, \"",
  170. text,
  171. "\", obj.memberinfo, \"from\", new Vector2(",
  172. this.start_vect2.x,
  173. "f, ",
  174. this.start_vect2.y,
  175. "f), \"to\", new Vector2(",
  176. this.end_vect2.x,
  177. "f, ",
  178. this.end_vect2.y,
  179. "f), ",
  180. base.getEaseString(codeLanguage),
  181. "));"
  182. });
  183. }
  184. if (this.valueType == 5)
  185. {
  186. return string.Concat(new object[]
  187. {
  188. "AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", ",
  189. base.getWaitTime(frameRate, 0f),
  190. "f, \"time\", ",
  191. this.getTime(frameRate),
  192. "f, \"",
  193. text,
  194. "\", obj.memberinfo, \"from\", new Vector3(",
  195. this.start_vect3.x,
  196. "f, ",
  197. this.start_vect3.y,
  198. "f, ",
  199. this.start_vect3.z,
  200. "f), \"to\", new Vector3(",
  201. this.end_vect3.x,
  202. "f, ",
  203. this.end_vect3.y,
  204. "f, ",
  205. this.end_vect3.z,
  206. "f), ",
  207. base.getEaseString(codeLanguage),
  208. "));"
  209. });
  210. }
  211. if (this.valueType == 6)
  212. {
  213. return string.Concat(new object[]
  214. {
  215. "AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", ",
  216. base.getWaitTime(frameRate, 0f),
  217. "f, \"time\", ",
  218. this.getTime(frameRate),
  219. "f, \"",
  220. text,
  221. "\", obj.memberinfo, \"from\", new Color(",
  222. this.start_color.r,
  223. "f, ",
  224. this.start_color.g,
  225. "f, ",
  226. this.start_color.b,
  227. "f, ",
  228. this.start_color.a,
  229. "f), \"to\", new Color(",
  230. this.end_color.r,
  231. "f, ",
  232. this.end_color.g,
  233. "f, ",
  234. this.end_color.b,
  235. "f, ",
  236. this.end_color.a,
  237. "f), ",
  238. base.getEaseString(codeLanguage),
  239. "));"
  240. });
  241. }
  242. if (this.valueType == 7)
  243. {
  244. return string.Concat(new object[]
  245. {
  246. "AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", ",
  247. base.getWaitTime(frameRate, 0f),
  248. "f, \"time\", ",
  249. this.getTime(frameRate),
  250. "f, \"",
  251. text,
  252. "\", obj.memberinfo, \"from\", new Rect(",
  253. this.start_rect.x,
  254. "f, ",
  255. this.start_rect.y,
  256. "f, ",
  257. this.start_rect.width,
  258. "f, ",
  259. this.start_rect.height,
  260. "f), \"to\", new Rect(",
  261. this.end_rect.x,
  262. "f, ",
  263. this.end_rect.y,
  264. "f, ",
  265. this.end_rect.width,
  266. "f, ",
  267. this.end_rect.height,
  268. "f), ",
  269. base.getEaseString(codeLanguage),
  270. "));"
  271. });
  272. }
  273. return "( Error: ValueType " + this.valueType + " not found )";
  274. }
  275. else
  276. {
  277. if (this.valueType == 8)
  278. {
  279. return string.Concat(new object[]
  280. {
  281. "AMTween.PropertyTo(obj.gameObject, {\"delay\": ",
  282. base.getWaitTime(frameRate, 0f),
  283. ", \"time\": ",
  284. this.getTime(frameRate),
  285. ", \"",
  286. text,
  287. "\": obj.memberinfo, \"methodtype\": \"morph\", \"from\": ",
  288. this.getFloatArrayString(codeLanguage, this.start_morph),
  289. ", \"to\": ",
  290. this.getFloatArrayString(codeLanguage, this.end_morph),
  291. ", ",
  292. base.getEaseString(codeLanguage),
  293. "));"
  294. });
  295. }
  296. if (AMPropertyTrack.isValueTypeNumeric(this.valueType))
  297. {
  298. return string.Concat(new object[]
  299. {
  300. "AMTween.PropertyTo(obj.gameObject, {\"delay\": ",
  301. base.getWaitTime(frameRate, 0f),
  302. ", \"time\": ",
  303. this.getTime(frameRate),
  304. ", \"",
  305. text,
  306. "\": obj.memberinfo, \"from\": ",
  307. this.start_val,
  308. ",\"to\": ",
  309. this.end_val,
  310. ", ",
  311. base.getEaseString(codeLanguage),
  312. "});"
  313. });
  314. }
  315. if (this.valueType == 4)
  316. {
  317. return string.Concat(new object[]
  318. {
  319. "AMTween.PropertyTo(obj.gameObject, {\"delay\": ",
  320. base.getWaitTime(frameRate, 0f),
  321. ", \"time\": ",
  322. this.getTime(frameRate),
  323. ", \"",
  324. text,
  325. "\": obj.memberinfo, \"from\": Vector2(",
  326. this.start_vect2.x,
  327. ", ",
  328. this.start_vect2.y,
  329. "), \"to\": Vector2(",
  330. this.end_vect2.x,
  331. ", ",
  332. this.end_vect2.y,
  333. "), ",
  334. base.getEaseString(codeLanguage),
  335. "});"
  336. });
  337. }
  338. if (this.valueType == 5)
  339. {
  340. return string.Concat(new object[]
  341. {
  342. "AMTween.PropertyTo(obj.gameObject, {\"delay\": ",
  343. base.getWaitTime(frameRate, 0f),
  344. ", \"time\": ",
  345. this.getTime(frameRate),
  346. ", \"",
  347. text,
  348. "\": obj.memberinfo, \"from\": Vector3(",
  349. this.start_vect3.x,
  350. ", ",
  351. this.start_vect3.y,
  352. ", ",
  353. this.start_vect3.z,
  354. "), \"to\": Vector3(",
  355. this.end_vect3.x,
  356. ", ",
  357. this.end_vect3.y,
  358. ", ",
  359. this.end_vect3.z,
  360. "), ",
  361. base.getEaseString(codeLanguage),
  362. "});"
  363. });
  364. }
  365. if (this.valueType == 6)
  366. {
  367. return string.Concat(new object[]
  368. {
  369. "AMTween.PropertyTo(obj.gameObject, {\"delay\": ",
  370. base.getWaitTime(frameRate, 0f),
  371. ", \"time\": ",
  372. this.getTime(frameRate),
  373. ", \"",
  374. text,
  375. "\": obj.memberinfo, \"from\": Color(",
  376. this.start_color.r,
  377. ", ",
  378. this.start_color.g,
  379. ", ",
  380. this.start_color.b,
  381. ", ",
  382. this.start_color.a,
  383. "), \"to\": Color(",
  384. this.end_color.r,
  385. ", ",
  386. this.end_color.g,
  387. ", ",
  388. this.end_color.b,
  389. ", ",
  390. this.end_color.a,
  391. "), ",
  392. base.getEaseString(codeLanguage),
  393. "});"
  394. });
  395. }
  396. if (this.valueType == 7)
  397. {
  398. return string.Concat(new object[]
  399. {
  400. "AMTween.PropertyTo(obj.gameObject, {\"delay\": ",
  401. base.getWaitTime(frameRate, 0f),
  402. ", \"time\": ",
  403. this.getTime(frameRate),
  404. ", \"",
  405. text,
  406. "\": obj.memberinfo, \"from\": Rect(",
  407. this.start_rect.x,
  408. ", ",
  409. this.start_rect.y,
  410. ", ",
  411. this.start_rect.width,
  412. ", ",
  413. this.start_rect.height,
  414. "), \"to\": Rect(",
  415. this.end_rect.x,
  416. ", ",
  417. this.end_rect.y,
  418. ", ",
  419. this.end_rect.width,
  420. ", ",
  421. this.end_rect.height,
  422. "), ",
  423. base.getEaseString(codeLanguage),
  424. "});"
  425. });
  426. }
  427. return "( Error: ValueType " + this.valueType + " not found )";
  428. }
  429. }
  430. public override int getNumberOfFrames()
  431. {
  432. return this.endFrame - this.startFrame;
  433. }
  434. public float getTime(int frameRate)
  435. {
  436. return (float)this.getNumberOfFrames() / (float)frameRate;
  437. }
  438. public override void execute(int frameRate, float delay, string trackId)
  439. {
  440. if (this.targetsAreEqual())
  441. {
  442. return;
  443. }
  444. if (this.endFrame == -1 || !this.component || (this.fieldInfo == null && this.propertyInfo == null && this.methodInfo == null))
  445. {
  446. return;
  447. }
  448. if (this.fieldInfo != null)
  449. {
  450. if (base.hasCustomEase())
  451. {
  452. if (AMPropertyTrack.isValueTypeNumeric(this.valueType))
  453. {
  454. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  455. {
  456. "trackid",
  457. trackId,
  458. "delay",
  459. base.getWaitTime(frameRate, delay),
  460. "time",
  461. this.getTime(frameRate),
  462. "fieldinfo",
  463. this.fieldInfo,
  464. "from",
  465. this.start_val,
  466. "to",
  467. this.end_val,
  468. "easecurve",
  469. base.easeCurve
  470. }));
  471. }
  472. if (this.valueType == 4)
  473. {
  474. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  475. {
  476. "trackid",
  477. trackId,
  478. "delay",
  479. base.getWaitTime(frameRate, delay),
  480. "time",
  481. this.getTime(frameRate),
  482. "fieldinfo",
  483. this.fieldInfo,
  484. "from",
  485. this.start_vect2,
  486. "to",
  487. this.end_vect2,
  488. "easecurve",
  489. base.easeCurve
  490. }));
  491. }
  492. if (this.valueType == 5)
  493. {
  494. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  495. {
  496. "trackid",
  497. trackId,
  498. "delay",
  499. base.getWaitTime(frameRate, delay),
  500. "time",
  501. this.getTime(frameRate),
  502. "fieldinfo",
  503. this.fieldInfo,
  504. "from",
  505. this.start_vect3,
  506. "to",
  507. this.end_vect3,
  508. "easecurve",
  509. base.easeCurve
  510. }));
  511. }
  512. if (this.valueType == 6)
  513. {
  514. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  515. {
  516. "trackid",
  517. trackId,
  518. "delay",
  519. base.getWaitTime(frameRate, delay),
  520. "time",
  521. this.getTime(frameRate),
  522. "fieldinfo",
  523. this.fieldInfo,
  524. "from",
  525. this.start_color,
  526. "to",
  527. this.end_color,
  528. "easecurve",
  529. base.easeCurve
  530. }));
  531. }
  532. if (this.valueType == 7)
  533. {
  534. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  535. {
  536. "trackid",
  537. trackId,
  538. "delay",
  539. base.getWaitTime(frameRate, delay),
  540. "time",
  541. this.getTime(frameRate),
  542. "fieldinfo",
  543. this.fieldInfo,
  544. "from",
  545. this.start_vect2,
  546. "to",
  547. this.end_vect2,
  548. "easecurve",
  549. base.easeCurve
  550. }));
  551. }
  552. }
  553. else
  554. {
  555. if (AMPropertyTrack.isValueTypeNumeric(this.valueType))
  556. {
  557. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  558. {
  559. "trackid",
  560. trackId,
  561. "delay",
  562. base.getWaitTime(frameRate, delay),
  563. "time",
  564. this.getTime(frameRate),
  565. "fieldinfo",
  566. this.fieldInfo,
  567. "from",
  568. this.start_val,
  569. "to",
  570. this.end_val,
  571. "easetype",
  572. (AMTween.EaseType)this.easeType
  573. }));
  574. }
  575. if (this.valueType == 4)
  576. {
  577. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  578. {
  579. "trackid",
  580. trackId,
  581. "delay",
  582. base.getWaitTime(frameRate, delay),
  583. "time",
  584. this.getTime(frameRate),
  585. "fieldinfo",
  586. this.fieldInfo,
  587. "from",
  588. this.start_vect2,
  589. "to",
  590. this.end_vect2,
  591. "easetype",
  592. (AMTween.EaseType)this.easeType
  593. }));
  594. }
  595. if (this.valueType == 5)
  596. {
  597. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  598. {
  599. "trackid",
  600. trackId,
  601. "delay",
  602. base.getWaitTime(frameRate, delay),
  603. "time",
  604. this.getTime(frameRate),
  605. "fieldinfo",
  606. this.fieldInfo,
  607. "from",
  608. this.start_vect3,
  609. "to",
  610. this.end_vect3,
  611. "easetype",
  612. (AMTween.EaseType)this.easeType
  613. }));
  614. }
  615. if (this.valueType == 6)
  616. {
  617. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  618. {
  619. "trackid",
  620. trackId,
  621. "delay",
  622. base.getWaitTime(frameRate, delay),
  623. "time",
  624. this.getTime(frameRate),
  625. "fieldinfo",
  626. this.fieldInfo,
  627. "from",
  628. this.start_color,
  629. "to",
  630. this.end_color,
  631. "easetype",
  632. (AMTween.EaseType)this.easeType
  633. }));
  634. }
  635. if (this.valueType == 7)
  636. {
  637. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  638. {
  639. "trackid",
  640. trackId,
  641. "delay",
  642. base.getWaitTime(frameRate, delay),
  643. "time",
  644. this.getTime(frameRate),
  645. "fieldinfo",
  646. this.fieldInfo,
  647. "from",
  648. this.start_vect2,
  649. "to",
  650. this.end_vect2,
  651. "easetype",
  652. (AMTween.EaseType)this.easeType
  653. }));
  654. }
  655. }
  656. }
  657. else if (this.propertyInfo != null)
  658. {
  659. if (base.hasCustomEase())
  660. {
  661. if (AMPropertyTrack.isValueTypeNumeric(this.valueType))
  662. {
  663. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  664. {
  665. "trackid",
  666. trackId,
  667. "delay",
  668. base.getWaitTime(frameRate, delay),
  669. "time",
  670. this.getTime(frameRate),
  671. "propertyinfo",
  672. this.propertyInfo,
  673. "from",
  674. this.start_val,
  675. "to",
  676. this.end_val,
  677. "easecurve",
  678. base.easeCurve
  679. }));
  680. }
  681. if (this.valueType == 4)
  682. {
  683. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  684. {
  685. "trackid",
  686. trackId,
  687. "delay",
  688. base.getWaitTime(frameRate, delay),
  689. "time",
  690. this.getTime(frameRate),
  691. "propertyinfo",
  692. this.propertyInfo,
  693. "from",
  694. this.start_vect2,
  695. "to",
  696. this.end_vect2,
  697. "easecurve",
  698. base.easeCurve
  699. }));
  700. }
  701. if (this.valueType == 5)
  702. {
  703. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  704. {
  705. "trackid",
  706. trackId,
  707. "delay",
  708. base.getWaitTime(frameRate, delay),
  709. "time",
  710. this.getTime(frameRate),
  711. "propertyinfo",
  712. this.propertyInfo,
  713. "from",
  714. this.start_vect3,
  715. "to",
  716. this.end_vect3,
  717. "easecurve",
  718. base.easeCurve
  719. }));
  720. }
  721. if (this.valueType == 6)
  722. {
  723. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  724. {
  725. "trackid",
  726. trackId,
  727. "delay",
  728. base.getWaitTime(frameRate, delay),
  729. "time",
  730. this.getTime(frameRate),
  731. "propertyinfo",
  732. this.propertyInfo,
  733. "from",
  734. this.start_color,
  735. "to",
  736. this.end_color,
  737. "easecurve",
  738. base.easeCurve
  739. }));
  740. }
  741. if (this.valueType == 7)
  742. {
  743. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  744. {
  745. "trackid",
  746. trackId,
  747. "delay",
  748. base.getWaitTime(frameRate, delay),
  749. "time",
  750. this.getTime(frameRate),
  751. "propertyinfo",
  752. this.propertyInfo,
  753. "from",
  754. this.start_vect2,
  755. "to",
  756. this.end_vect2,
  757. "easecurve",
  758. base.easeCurve
  759. }));
  760. }
  761. }
  762. else
  763. {
  764. if (AMPropertyTrack.isValueTypeNumeric(this.valueType))
  765. {
  766. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  767. {
  768. "trackid",
  769. trackId,
  770. "delay",
  771. base.getWaitTime(frameRate, delay),
  772. "time",
  773. this.getTime(frameRate),
  774. "propertyinfo",
  775. this.propertyInfo,
  776. "from",
  777. this.start_val,
  778. "to",
  779. this.end_val,
  780. "easetype",
  781. (AMTween.EaseType)this.easeType
  782. }));
  783. }
  784. if (this.valueType == 4)
  785. {
  786. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  787. {
  788. "trackid",
  789. trackId,
  790. "delay",
  791. base.getWaitTime(frameRate, delay),
  792. "time",
  793. this.getTime(frameRate),
  794. "propertyinfo",
  795. this.propertyInfo,
  796. "from",
  797. this.start_vect2,
  798. "to",
  799. this.end_vect2,
  800. "easetype",
  801. (AMTween.EaseType)this.easeType
  802. }));
  803. }
  804. if (this.valueType == 5)
  805. {
  806. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  807. {
  808. "trackid",
  809. trackId,
  810. "delay",
  811. base.getWaitTime(frameRate, delay),
  812. "time",
  813. this.getTime(frameRate),
  814. "propertyinfo",
  815. this.propertyInfo,
  816. "from",
  817. this.start_vect3,
  818. "to",
  819. this.end_vect3,
  820. "easetype",
  821. (AMTween.EaseType)this.easeType
  822. }));
  823. }
  824. if (this.valueType == 6)
  825. {
  826. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  827. {
  828. "trackid",
  829. trackId,
  830. "delay",
  831. base.getWaitTime(frameRate, delay),
  832. "time",
  833. this.getTime(frameRate),
  834. "propertyinfo",
  835. this.propertyInfo,
  836. "from",
  837. this.start_color,
  838. "to",
  839. this.end_color,
  840. "easetype",
  841. (AMTween.EaseType)this.easeType
  842. }));
  843. }
  844. if (this.valueType == 7)
  845. {
  846. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  847. {
  848. "trackid",
  849. trackId,
  850. "delay",
  851. base.getWaitTime(frameRate, delay),
  852. "time",
  853. this.getTime(frameRate),
  854. "propertyinfo",
  855. this.propertyInfo,
  856. "from",
  857. this.start_vect2,
  858. "to",
  859. this.end_vect2,
  860. "easetype",
  861. (AMTween.EaseType)this.easeType
  862. }));
  863. }
  864. }
  865. }
  866. else if (this.methodInfo != null)
  867. {
  868. if (base.hasCustomEase())
  869. {
  870. if (this.valueType == 8)
  871. {
  872. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  873. {
  874. "trackid",
  875. trackId,
  876. "delay",
  877. base.getWaitTime(frameRate, delay),
  878. "time",
  879. this.getTime(frameRate),
  880. "methodtype",
  881. "morph",
  882. "methodinfo",
  883. this.methodInfo,
  884. "from",
  885. this.start_morph.ToArray(),
  886. "to",
  887. this.end_morph.ToArray(),
  888. "easecurve",
  889. base.easeCurve
  890. }));
  891. }
  892. }
  893. else if (this.valueType == 8)
  894. {
  895. AMTween.PropertyTo(this.component, AMTween.Hash(new object[]
  896. {
  897. "trackid",
  898. trackId,
  899. "delay",
  900. base.getWaitTime(frameRate, delay),
  901. "time",
  902. this.getTime(frameRate),
  903. "methodtype",
  904. "morph",
  905. "methodinfo",
  906. this.methodInfo,
  907. "from",
  908. this.start_morph.ToArray(),
  909. "to",
  910. this.end_morph.ToArray(),
  911. "easetype",
  912. (AMTween.EaseType)this.easeType
  913. }));
  914. }
  915. }
  916. else
  917. {
  918. Debug.LogError("Animator: No FieldInfo or PropertyInfo set.");
  919. }
  920. }
  921. public string getName()
  922. {
  923. if (this.fieldInfo != null)
  924. {
  925. return this.fieldInfo.Name;
  926. }
  927. if (this.propertyInfo != null)
  928. {
  929. return this.propertyInfo.Name;
  930. }
  931. if (this.methodInfo != null && this.valueType == 8)
  932. {
  933. return "Morph";
  934. }
  935. return "Unknown";
  936. }
  937. public string getFloatArrayString(int codeLanguage, List<float> ls)
  938. {
  939. string text = string.Empty;
  940. if (codeLanguage == 0)
  941. {
  942. text += "new float[]{";
  943. }
  944. else
  945. {
  946. text += "[";
  947. }
  948. for (int i = 0; i < ls.Count; i++)
  949. {
  950. text += ls[i].ToString();
  951. if (codeLanguage == 0)
  952. {
  953. text += "f";
  954. }
  955. if (i < ls.Count - 1)
  956. {
  957. text += ", ";
  958. }
  959. }
  960. if (codeLanguage == 0)
  961. {
  962. text += "}";
  963. }
  964. else
  965. {
  966. text += "]";
  967. }
  968. return text;
  969. }
  970. public string getValueString(bool brief)
  971. {
  972. string text = string.Empty;
  973. if (AMPropertyTrack.isValueTypeNumeric(this.valueType))
  974. {
  975. text += this.formatNumeric(this.start_val);
  976. if (!brief && this.endFrame != -1)
  977. {
  978. text = text + " -> " + this.formatNumeric(this.end_val);
  979. }
  980. }
  981. else if (this.valueType == 4)
  982. {
  983. text += this.start_vect2.ToString();
  984. if (!brief && this.endFrame != -1)
  985. {
  986. text = text + " -> " + this.end_vect2.ToString();
  987. }
  988. }
  989. else if (this.valueType == 5)
  990. {
  991. text += this.start_vect3.ToString();
  992. if (!brief && this.endFrame != -1)
  993. {
  994. text = text + " -> " + this.end_vect3.ToString();
  995. }
  996. }
  997. else if (this.valueType == 6)
  998. {
  999. text += this.start_color.ToString();
  1000. if (!brief && this.endFrame != -1)
  1001. {
  1002. text = text + " -> " + this.end_color.ToString();
  1003. }
  1004. }
  1005. else if (this.valueType == 7)
  1006. {
  1007. text += this.start_rect.ToString();
  1008. if (!brief && this.endFrame != -1)
  1009. {
  1010. text = text + " -> " + this.end_rect.ToString();
  1011. }
  1012. }
  1013. return text;
  1014. }
  1015. private string formatNumeric(float input)
  1016. {
  1017. double num = (double)((input >= 0f) ? input : (input * -1f));
  1018. if (num >= 1.0)
  1019. {
  1020. return input.ToString("N2");
  1021. }
  1022. if (num >= 0.0099999997764825821)
  1023. {
  1024. return input.ToString("N3");
  1025. }
  1026. if (num >= 0.0010000000474974513)
  1027. {
  1028. return input.ToString("N4");
  1029. }
  1030. if (num >= 9.9999997473787516E-05)
  1031. {
  1032. return input.ToString("N5");
  1033. }
  1034. if (num >= 9.9999997473787516E-06)
  1035. {
  1036. return input.ToString("N6");
  1037. }
  1038. return input.ToString();
  1039. }
  1040. private string formatNumeric(double input)
  1041. {
  1042. double num = (input >= 0.0) ? input : (input * -1.0);
  1043. if (num >= 1.0)
  1044. {
  1045. return input.ToString("N2");
  1046. }
  1047. if (num >= 0.01)
  1048. {
  1049. return input.ToString("N3");
  1050. }
  1051. if (num >= 0.001)
  1052. {
  1053. return input.ToString("N4");
  1054. }
  1055. if (num >= 0.0001)
  1056. {
  1057. return input.ToString("N5");
  1058. }
  1059. if (num >= 1E-05)
  1060. {
  1061. return input.ToString("N6");
  1062. }
  1063. return input.ToString();
  1064. }
  1065. public int getStartMorphNameIndex(int numChannels)
  1066. {
  1067. return this.getMorphNameIndex(this.start_morph, numChannels);
  1068. }
  1069. public int getEndMorphNameIndex(int numChannels)
  1070. {
  1071. return this.getMorphNameIndex(this.end_morph, numChannels);
  1072. }
  1073. private int getMorphNameIndex(List<float> morph, int count)
  1074. {
  1075. int num = -1;
  1076. bool flag = true;
  1077. if (morph.Count < count)
  1078. {
  1079. count = morph.Count;
  1080. }
  1081. for (int i = 0; i < count; i++)
  1082. {
  1083. if (flag && morph[i] != 0f)
  1084. {
  1085. flag = false;
  1086. }
  1087. if (morph[i] > 0f && morph[i] < 100f)
  1088. {
  1089. num = -1;
  1090. break;
  1091. }
  1092. if (morph[i] == 100f)
  1093. {
  1094. if (num != -1)
  1095. {
  1096. num = -1;
  1097. break;
  1098. }
  1099. num = i;
  1100. }
  1101. }
  1102. if (flag)
  1103. {
  1104. num = -2;
  1105. }
  1106. return num;
  1107. }
  1108. public bool targetsAreEqual()
  1109. {
  1110. if (this.valueType == 0 || this.valueType == 1 || this.valueType == 2 || this.valueType == 3)
  1111. {
  1112. return this.start_val == this.end_val;
  1113. }
  1114. if (this.valueType == 4)
  1115. {
  1116. return this.start_vect2 == this.end_vect2;
  1117. }
  1118. if (this.valueType == 5)
  1119. {
  1120. return this.start_vect3 == this.end_vect3;
  1121. }
  1122. if (this.valueType == 6)
  1123. {
  1124. return this.start_color == this.end_color;
  1125. }
  1126. if (this.valueType == 7)
  1127. {
  1128. return this.start_rect == this.end_rect;
  1129. }
  1130. if (this.valueType != 8)
  1131. {
  1132. Debug.LogError("Animator: Invalid ValueType " + this.valueType);
  1133. return false;
  1134. }
  1135. if (this.start_morph == null || this.end_morph == null)
  1136. {
  1137. return false;
  1138. }
  1139. for (int i = 0; i < this.start_morph.Count; i++)
  1140. {
  1141. if (this.end_morph.Count <= i || this.start_morph[i] != this.end_morph[i])
  1142. {
  1143. return false;
  1144. }
  1145. }
  1146. return true;
  1147. }
  1148. public object getStartValue()
  1149. {
  1150. if (this.valueType == 0)
  1151. {
  1152. return Convert.ToInt32(this.start_val);
  1153. }
  1154. if (this.valueType == 1)
  1155. {
  1156. return Convert.ToInt64(this.start_val);
  1157. }
  1158. if (this.valueType == 2)
  1159. {
  1160. return Convert.ToSingle(this.start_val);
  1161. }
  1162. if (this.valueType == 3)
  1163. {
  1164. return this.start_val;
  1165. }
  1166. if (this.valueType == 4)
  1167. {
  1168. return this.start_vect2;
  1169. }
  1170. if (this.valueType == 5)
  1171. {
  1172. return this.start_vect3;
  1173. }
  1174. if (this.valueType == 6)
  1175. {
  1176. return this.start_color;
  1177. }
  1178. if (this.valueType == 7)
  1179. {
  1180. return this.start_rect;
  1181. }
  1182. return "Unknown";
  1183. }
  1184. public object getEndValue()
  1185. {
  1186. if (this.valueType == 0)
  1187. {
  1188. return Convert.ToInt32(this.end_val);
  1189. }
  1190. if (this.valueType == 1)
  1191. {
  1192. return Convert.ToInt64(this.end_val);
  1193. }
  1194. if (this.valueType == 2)
  1195. {
  1196. return Convert.ToSingle(this.end_val);
  1197. }
  1198. if (this.valueType == 3)
  1199. {
  1200. return this.end_val;
  1201. }
  1202. if (this.valueType == 4)
  1203. {
  1204. return this.end_vect2;
  1205. }
  1206. if (this.valueType == 5)
  1207. {
  1208. return this.end_vect3;
  1209. }
  1210. if (this.valueType == 6)
  1211. {
  1212. return this.end_color;
  1213. }
  1214. if (this.valueType == 7)
  1215. {
  1216. return this.end_rect;
  1217. }
  1218. return "Unknown";
  1219. }
  1220. public override AnimatorTimeline.JSONAction getJSONAction(int frameRate)
  1221. {
  1222. if (this.targetsAreEqual())
  1223. {
  1224. return null;
  1225. }
  1226. if (this.endFrame == -1 || !this.component || (this.fieldInfo == null && this.propertyInfo == null && this.methodInfo == null))
  1227. {
  1228. return null;
  1229. }
  1230. AnimatorTimeline.JSONAction jsonaction = new AnimatorTimeline.JSONAction();
  1231. jsonaction.method = "propertyto";
  1232. jsonaction.go = this.component.gameObject.name;
  1233. jsonaction.delay = base.getWaitTime(frameRate, 0f);
  1234. jsonaction.time = this.getTime(frameRate);
  1235. List<string> list = new List<string>();
  1236. list.Add(this.component.GetType().Name);
  1237. if (this.fieldInfo != null || this.propertyInfo != null)
  1238. {
  1239. if (this.valueType == 0)
  1240. {
  1241. list.Add("integer");
  1242. jsonaction.ints = new int[]
  1243. {
  1244. Convert.ToInt32(this.start_val),
  1245. Convert.ToInt32(this.end_val)
  1246. };
  1247. }
  1248. else if (this.valueType == 1)
  1249. {
  1250. list.Add("long");
  1251. jsonaction.longs = new long[]
  1252. {
  1253. Convert.ToInt64(this.start_val),
  1254. Convert.ToInt64(this.end_val)
  1255. };
  1256. }
  1257. else if (this.valueType == 2)
  1258. {
  1259. list.Add("float");
  1260. jsonaction.floats = new float[]
  1261. {
  1262. Convert.ToSingle(this.start_val),
  1263. Convert.ToSingle(this.end_val)
  1264. };
  1265. }
  1266. else if (this.valueType == 3)
  1267. {
  1268. list.Add("double");
  1269. jsonaction.doubles = new double[]
  1270. {
  1271. this.start_val,
  1272. this.end_val
  1273. };
  1274. }
  1275. else if (this.valueType == 4)
  1276. {
  1277. list.Add("vector2");
  1278. AnimatorTimeline.JSONVector2 jsonvector = new AnimatorTimeline.JSONVector2();
  1279. jsonvector.setValue(this.start_vect2);
  1280. AnimatorTimeline.JSONVector2 jsonvector2 = new AnimatorTimeline.JSONVector2();
  1281. jsonvector2.setValue(this.end_vect2);
  1282. jsonaction.vect2s = new AnimatorTimeline.JSONVector2[]
  1283. {
  1284. jsonvector,
  1285. jsonvector2
  1286. };
  1287. }
  1288. else if (this.valueType == 5)
  1289. {
  1290. list.Add("vector3");
  1291. jsonaction.setPath(new Vector3[]
  1292. {
  1293. this.start_vect3,
  1294. this.end_vect3
  1295. });
  1296. }
  1297. else if (this.valueType == 6)
  1298. {
  1299. list.Add("color");
  1300. AnimatorTimeline.JSONColor jsoncolor = new AnimatorTimeline.JSONColor();
  1301. jsoncolor.setValue(this.start_color);
  1302. AnimatorTimeline.JSONColor jsoncolor2 = new AnimatorTimeline.JSONColor();
  1303. jsoncolor2.setValue(this.end_color);
  1304. jsonaction.colors = new AnimatorTimeline.JSONColor[]
  1305. {
  1306. jsoncolor,
  1307. jsoncolor2
  1308. };
  1309. }
  1310. else if (this.valueType == 7)
  1311. {
  1312. list.Add("rect");
  1313. AnimatorTimeline.JSONRect jsonrect = new AnimatorTimeline.JSONRect();
  1314. jsonrect.setValue(this.start_rect);
  1315. AnimatorTimeline.JSONRect jsonrect2 = new AnimatorTimeline.JSONRect();
  1316. jsonrect2.setValue(this.end_rect);
  1317. jsonaction.rects = new AnimatorTimeline.JSONRect[]
  1318. {
  1319. jsonrect,
  1320. jsonrect2
  1321. };
  1322. }
  1323. if (this.fieldInfo != null)
  1324. {
  1325. list.Add("fieldinfo");
  1326. list.Add(this.fieldInfo.Name);
  1327. }
  1328. else
  1329. {
  1330. list.Add("propertyinfo");
  1331. list.Add(this.propertyInfo.Name);
  1332. }
  1333. }
  1334. else if (this.methodInfo != null && this.valueType == 8)
  1335. {
  1336. list.Add("morph");
  1337. jsonaction.floats = this.start_morph.ToArray();
  1338. jsonaction.floatsExtra = this.end_morph.ToArray();
  1339. }
  1340. base.setupJSONActionEase(jsonaction);
  1341. jsonaction.strings = list.ToArray();
  1342. return jsonaction;
  1343. }
  1344. public int valueType;
  1345. public Component component;
  1346. public string componentName;
  1347. public int endFrame;
  1348. public string propertyName;
  1349. public string fieldName;
  1350. public string methodName;
  1351. public string[] methodParameterTypes;
  1352. private MethodInfo cachedMethodInfo;
  1353. private PropertyInfo cachedPropertyInfo;
  1354. private FieldInfo cachedFieldInfo;
  1355. public double start_val;
  1356. public Vector2 start_vect2;
  1357. public Vector3 start_vect3;
  1358. public Color start_color;
  1359. public Rect start_rect;
  1360. public double end_val;
  1361. public Vector2 end_vect2;
  1362. public Vector3 end_vect3;
  1363. public Color end_color;
  1364. public Rect end_rect;
  1365. public List<float> start_morph;
  1366. public List<float> end_morph;
  1367. }