UIAnimationMaker.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using GameFramework;
  7. using GameFramework.DataTable;
  8. using GameFramework.Resource;
  9. namespace MetaClient
  10. {
  11. public class UIAnimationMaker : UGuiForm
  12. {
  13. [SerializeField]
  14. [Header("模式类型")]
  15. protected EUIAnimationMakerStyple eUIAnimationMakerStyple = EUIAnimationMakerStyple.Senior;
  16. [SerializeField]
  17. [Header("旋转X或Y")]
  18. protected List<Transform> rotateXY=new List<Transform>();
  19. protected Transform topView;
  20. protected Transform commonBtnView;
  21. protected Transform seniorView;
  22. protected Transform extraView;
  23. protected bool isPlay = false;
  24. protected GameObject zhenNumberItem;//帧数字
  25. protected GameObject zhenBgItem;//帧背景
  26. protected GameObject bodyZhenItem;//身体
  27. protected GameObject zhenItem;//单位帧
  28. protected Transform zhenBgList;
  29. protected Transform bodyZhenList;
  30. protected Transform zhenList;
  31. protected Text zhenTimeText;
  32. protected float nowTime = 0;//当前帧
  33. protected float finalTime = 0;//末尾帧
  34. protected float smallBiLi = 1;
  35. protected override void OnOpen(object userData)
  36. {
  37. base.OnOpen(userData);
  38. GameObject objItem = FindChildByName(this.gameObject.transform, "Item").gameObject;
  39. zhenNumberItem = objItem.transform.GetChild(0).gameObject;
  40. zhenBgItem = objItem.transform.GetChild(1).gameObject;
  41. bodyZhenItem = objItem.transform.GetChild(2).gameObject;
  42. zhenItem = objItem.transform.GetChild(3).gameObject;
  43. rotateXY.Add(FindChildByName(this.gameObject.transform,"RotateY"));
  44. rotateXY.Add(FindChildByName(this.gameObject.transform, "RotateX"));
  45. topView = FindChildByName(this.gameObject.transform, "Top");
  46. ButtonFromTransform(topView.GetChild(0)).onClick.AddListener(SimpleFun);
  47. ButtonFromTransform(topView.GetChild(1)).onClick.AddListener(SeniorFun);
  48. ButtonFromTransform(topView.GetChild(2)).onClick.AddListener(SceneDressFun);
  49. ButtonFromTransform(topView.GetChild(3)).onClick.AddListener(ReturnFun);
  50. ButtonFromTransform(topView.GetChild(4)).onClick.AddListener(NightLighting);
  51. ButtonFromTransform(topView.GetChild(4)).onClick.AddListener(SunLighting);
  52. ButtonFromTransform(topView.GetChild(5)).onClick.AddListener(HalfLighting);
  53. commonBtnView = FindChildByName(this.gameObject.transform,"CommonButton");
  54. ButtonFromTransform(commonBtnView.GetChild(0)).onClick.AddListener(SaveBtnFun);
  55. ButtonFromTransform(commonBtnView.GetChild(1)).onClick.AddListener(MusicBtnFun);
  56. ButtonFromTransform(commonBtnView.GetChild(2)).onClick.AddListener(FullScreenBtnFun);
  57. ButtonFromTransform(commonBtnView.GetChild(2)).onClick.AddListener(PlayBtnFun);
  58. Transform bottomBg = FindChildByName(this.gameObject.transform, "BottomBg");
  59. ButtonFromTransform(bottomBg.GetChild(0)).onClick.AddListener(StartKBtnFun);
  60. ButtonFromTransform(bottomBg.GetChild(1)).onClick.AddListener(EndKBtnFun);
  61. ButtonFromTransform(bottomBg.GetChild(3)).onClick.AddListener(DelectBtnFun);
  62. ButtonFromTransform(bottomBg.GetChild(4)).onClick.AddListener(CopyBtnFun);
  63. ButtonFromTransform(bottomBg.GetChild(5)).onClick.AddListener(NextKBtnFun);
  64. ButtonFromTransform(bottomBg.GetChild(6)).onClick.AddListener(LastKBtnFun);
  65. zhenTimeText = bottomBg.GetChild(7).GetChild(0).gameObject.GetComponent<Text>();
  66. zhenTimeText.text = nowTime+"";
  67. //FindButtonByName(this.gameObject.transform, "BackBtn").onClick.AddListener(SaveBtnFun);
  68. //FindButtonByName(this.gameObject.transform, "MusicBtn").onClick.AddListener(MusicBtnFun);
  69. //FindButtonByName(this.gameObject.transform, "FullScreenBtn").onClick.AddListener(FullScreenBtnFun);
  70. //FindButtonByName(this.gameObject.transform, "PlayBtn").onClick.AddListener(PlayBtnFun);
  71. seniorView = FindChildByName(this.gameObject.transform, "Senior");
  72. extraView = FindChildByName(this.gameObject.transform, "Extra");
  73. }
  74. protected void SceneDressFun() {
  75. }
  76. protected void ReturnFun()
  77. {
  78. }
  79. protected void SimpleFun() {
  80. }
  81. protected void SeniorFun()
  82. {
  83. }
  84. protected void CreateZhenListFun()
  85. {
  86. }
  87. /// <summary>
  88. /// 保存按钮
  89. /// </summary>
  90. protected void SaveBtnFun()
  91. {
  92. }
  93. /// <summary>
  94. /// 音乐按钮
  95. /// </summary>
  96. protected void MusicBtnFun()
  97. {
  98. }
  99. /// <summary>
  100. /// 全屏按钮
  101. /// </summary>
  102. protected void FullScreenBtnFun() {
  103. }
  104. /// <summary>
  105. /// 播放按钮
  106. /// </summary>
  107. protected void PlayBtnFun() {
  108. isPlay = !isPlay;
  109. GameObject saveObj = commonBtnView.GetChild(3).gameObject;
  110. saveObj.transform.GetChild(1).gameObject.SetActive(isPlay);
  111. saveObj.transform.GetChild(2).gameObject.SetActive(!isPlay);
  112. // Transform commonButtonRight = FindChildByName(this.gameObject.transform, "CommonButton");
  113. }
  114. /// <summary>
  115. /// 捏脸按钮
  116. /// </summary>
  117. protected void NieLianFun() {
  118. }
  119. /// <summary>
  120. /// 摄像机按钮
  121. /// </summary>
  122. protected void CameraBtnFun() {
  123. }
  124. protected void DelectBtnFun()
  125. {
  126. }
  127. protected void CopyBtnFun()
  128. {
  129. }
  130. protected void StartKBtnFun() {
  131. }
  132. protected void EndKBtnFun() {
  133. }
  134. /// <summary>
  135. /// 下一帧
  136. /// </summary>
  137. protected void NextKBtnFun() {
  138. if (isPlay)
  139. {
  140. return;
  141. }
  142. nowTime += 1;
  143. }
  144. /// <summary>
  145. /// 上一帧
  146. /// </summary>
  147. protected void LastKBtnFun() {
  148. if (isPlay)
  149. {
  150. return;
  151. }
  152. if (nowTime <= 1)
  153. {
  154. return;
  155. }
  156. nowTime -= 1;
  157. }
  158. /// <summary>
  159. /// 下十帧
  160. /// </summary>
  161. protected void NextTenKBtnFun() {
  162. if (isPlay)
  163. {
  164. return;
  165. }
  166. nowTime += 10;
  167. }
  168. /// <summary>
  169. /// 上十帧
  170. /// </summary>
  171. protected void LastTenKBtnFun() {
  172. if (isPlay)
  173. {
  174. return;
  175. }
  176. if (nowTime < 10)
  177. {
  178. return;
  179. }
  180. nowTime -= 10;
  181. }
  182. /// <summary>
  183. ///旋转X轴
  184. /// </summary>
  185. public void RotateXFun() {
  186. }
  187. /// <summary>
  188. /// 旋转Y轴
  189. /// </summary>
  190. public void RotateYFun() {
  191. }
  192. /// <summary>
  193. /// 移动
  194. /// </summary>
  195. public void MoveFun() {
  196. }
  197. /// <summary>
  198. ///摄像机
  199. /// </summary>
  200. public void CameraFun()
  201. {
  202. }
  203. /// <summary>
  204. /// 捏脸
  205. /// </summary>
  206. public void NeiLianFun() {
  207. }
  208. /// <summary>
  209. ///夜晚灯光
  210. /// </summary>
  211. protected void NightLighting()
  212. {
  213. }
  214. /// <summary>
  215. ///白天灯光
  216. /// </summary>
  217. protected void SunLighting()
  218. {
  219. }
  220. /// <summary>
  221. ///中午灯光
  222. /// </summary>
  223. protected void HalfLighting()
  224. {
  225. }
  226. protected override void OnClose(bool isShutdown, object userData)
  227. {
  228. base.OnClose(isShutdown, userData);
  229. }
  230. public Button ButtonFromTransform(Transform trans) {
  231. if (trans.gameObject.GetComponent<Button>() == null)
  232. {
  233. trans.gameObject.AddComponent<Button>();
  234. }
  235. return trans.gameObject.GetComponent<Button>();
  236. }
  237. //public Button FindButtonByName(Transform trans, string name)
  238. //{
  239. // Button[] transformArry = trans.GetComponentsInChildren<Button>();
  240. // foreach (var item in transformArry)
  241. // {
  242. // if (item.gameObject.name == name)
  243. // {
  244. // return item;
  245. // }
  246. // }
  247. // return null;
  248. //}
  249. public Transform FindChildByName(Transform trans, string name)
  250. {
  251. Transform[] transformArry = trans.GetComponentsInChildren<Transform>();
  252. foreach (var item in transformArry)
  253. {
  254. if (item.gameObject.name == name)
  255. {
  256. return item;
  257. }
  258. }
  259. return null;
  260. }
  261. protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
  262. {
  263. base.OnUpdate(elapseSeconds, realElapseSeconds);
  264. if (isPlay)
  265. {
  266. if (nowTime < finalTime)
  267. {
  268. nowTime += 1;
  269. }
  270. else
  271. {
  272. PlayBtnFun();
  273. }
  274. }
  275. }
  276. }
  277. public enum EUIAnimationMakerStyple {
  278. None,
  279. Simple,
  280. Senior,
  281. }
  282. }