UIAnimationMaker.cs 7.9 KB

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