UIAnimationMaker.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 float nowTime = 0;//当前帧
  32. protected float finalTime = 0;//末尾帧
  33. protected override void OnOpen(object userData)
  34. {
  35. base.OnOpen(userData);
  36. GameObject objItem = FindChildByName(this.gameObject.transform, "Item").gameObject;
  37. zhenNumberItem = objItem.transform.GetChild(0).gameObject;
  38. zhenBgItem = objItem.transform.GetChild(1).gameObject;
  39. bodyZhenItem = objItem.transform.GetChild(2).gameObject;
  40. zhenItem = objItem.transform.GetChild(3).gameObject;
  41. rotateXY.Add(FindChildByName(this.gameObject.transform,"RotateY"));
  42. rotateXY.Add(FindChildByName(this.gameObject.transform, "RotateX"));
  43. topView = FindChildByName(this.gameObject.transform, "Top");
  44. ButtonFromTransform(topView.GetChild(0)).onClick.AddListener(SimpleFun);
  45. ButtonFromTransform(topView.GetChild(1)).onClick.AddListener(SeniorFun);
  46. ButtonFromTransform(topView.GetChild(2)).onClick.AddListener(SceneDressFun);
  47. ButtonFromTransform(topView.GetChild(3)).onClick.AddListener(ReturnFun);
  48. ButtonFromTransform(topView.GetChild(4)).onClick.AddListener(NightLighting);
  49. ButtonFromTransform(topView.GetChild(4)).onClick.AddListener(SunLighting);
  50. ButtonFromTransform(topView.GetChild(5)).onClick.AddListener(HalfLighting);
  51. commonBtnView = FindChildByName(this.gameObject.transform,"CommonButton");
  52. ButtonFromTransform(commonBtnView.GetChild(0)).onClick.AddListener(SaveBtnFun);
  53. ButtonFromTransform(commonBtnView.GetChild(1)).onClick.AddListener(MusicBtnFun);
  54. ButtonFromTransform(commonBtnView.GetChild(2)).onClick.AddListener(FullScreenBtnFun);
  55. ButtonFromTransform(commonBtnView.GetChild(2)).onClick.AddListener(PlayBtnFun);
  56. //FindButtonByName(this.gameObject.transform, "BackBtn").onClick.AddListener(SaveBtnFun);
  57. //FindButtonByName(this.gameObject.transform, "MusicBtn").onClick.AddListener(MusicBtnFun);
  58. //FindButtonByName(this.gameObject.transform, "FullScreenBtn").onClick.AddListener(FullScreenBtnFun);
  59. //FindButtonByName(this.gameObject.transform, "PlayBtn").onClick.AddListener(PlayBtnFun);
  60. seniorView= FindChildByName(this.gameObject.transform, "Senior");
  61. extraView = FindChildByName(this.gameObject.transform, "Extra");
  62. }
  63. protected void SceneDressFun() {
  64. }
  65. protected void ReturnFun()
  66. {
  67. }
  68. protected void SimpleFun() {
  69. }
  70. protected void SeniorFun()
  71. {
  72. }
  73. /// <summary>
  74. /// 保存按钮
  75. /// </summary>
  76. protected void SaveBtnFun()
  77. {
  78. }
  79. /// <summary>
  80. /// 音乐按钮
  81. /// </summary>
  82. protected void MusicBtnFun()
  83. {
  84. }
  85. /// <summary>
  86. /// 全屏按钮
  87. /// </summary>
  88. protected void FullScreenBtnFun() {
  89. }
  90. /// <summary>
  91. /// 播放按钮
  92. /// </summary>
  93. protected void PlayBtnFun() {
  94. isPlay = !isPlay;
  95. GameObject saveObj = commonBtnView.GetChild(3).gameObject;
  96. saveObj.transform.GetChild(1).gameObject.SetActive(isPlay);
  97. saveObj.transform.GetChild(2).gameObject.SetActive(!isPlay);
  98. // Transform commonButtonRight = FindChildByName(this.gameObject.transform, "CommonButton");
  99. }
  100. /// <summary>
  101. /// 捏脸按钮
  102. /// </summary>
  103. protected void NieLianFun() {
  104. }
  105. /// <summary>
  106. /// 摄像机按钮
  107. /// </summary>
  108. protected void CameraBtnFun() {
  109. }
  110. /// <summary>
  111. /// 下一帧
  112. /// </summary>
  113. protected void NextKBtnFun() {
  114. if (isPlay)
  115. {
  116. return;
  117. }
  118. nowTime += 1;
  119. }
  120. /// <summary>
  121. /// 上一帧
  122. /// </summary>
  123. protected void LastKBtnFun() {
  124. if (isPlay)
  125. {
  126. return;
  127. }
  128. if (nowTime <= 1)
  129. {
  130. return;
  131. }
  132. nowTime -= 1;
  133. }
  134. /// <summary>
  135. /// 下十帧
  136. /// </summary>
  137. protected void NextTenKBtnFun() {
  138. if (isPlay)
  139. {
  140. return;
  141. }
  142. nowTime += 10;
  143. }
  144. /// <summary>
  145. /// 上十帧
  146. /// </summary>
  147. protected void LastTenKBtnFun() {
  148. if (isPlay)
  149. {
  150. return;
  151. }
  152. if (nowTime < 10)
  153. {
  154. return;
  155. }
  156. nowTime -= 10;
  157. }
  158. /// <summary>
  159. ///旋转X轴
  160. /// </summary>
  161. public void RotateXFun() {
  162. }
  163. /// <summary>
  164. /// 旋转Y轴
  165. /// </summary>
  166. public void RotateYFun() {
  167. }
  168. /// <summary>
  169. /// 移动
  170. /// </summary>
  171. public void MoveFun() {
  172. }
  173. /// <summary>
  174. ///摄像机
  175. /// </summary>
  176. public void CameraFun()
  177. {
  178. }
  179. /// <summary>
  180. /// 捏脸
  181. /// </summary>
  182. public void NeiLianFun() {
  183. }
  184. /// <summary>
  185. ///夜晚灯光
  186. /// </summary>
  187. protected void NightLighting()
  188. {
  189. }
  190. /// <summary>
  191. ///白天灯光
  192. /// </summary>
  193. protected void SunLighting()
  194. {
  195. }
  196. /// <summary>
  197. ///中午灯光
  198. /// </summary>
  199. protected void HalfLighting()
  200. {
  201. }
  202. protected override void OnClose(bool isShutdown, object userData)
  203. {
  204. base.OnClose(isShutdown, userData);
  205. }
  206. public Button ButtonFromTransform(Transform trans) {
  207. if (trans.gameObject.GetComponent<Button>() == null)
  208. {
  209. trans.gameObject.AddComponent<Button>();
  210. }
  211. return trans.gameObject.GetComponent<Button>();
  212. }
  213. //public Button FindButtonByName(Transform trans, string name)
  214. //{
  215. // Button[] transformArry = trans.GetComponentsInChildren<Button>();
  216. // foreach (var item in transformArry)
  217. // {
  218. // if (item.gameObject.name == name)
  219. // {
  220. // return item;
  221. // }
  222. // }
  223. // return null;
  224. //}
  225. public Transform FindChildByName(Transform trans, string name)
  226. {
  227. Transform[] transformArry = trans.GetComponentsInChildren<Transform>();
  228. foreach (var item in transformArry)
  229. {
  230. if (item.gameObject.name == name)
  231. {
  232. return item;
  233. }
  234. }
  235. return null;
  236. }
  237. protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
  238. {
  239. base.OnUpdate(elapseSeconds, realElapseSeconds);
  240. if (isPlay)
  241. {
  242. if (nowTime < finalTime)
  243. {
  244. nowTime += 1;
  245. }
  246. else
  247. {
  248. PlayBtnFun();
  249. }
  250. }
  251. }
  252. }
  253. public enum EUIAnimationMakerStyple {
  254. None,
  255. Simple,
  256. Senior,
  257. }
  258. }