UICustom.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityGameFramework.Runtime;
  6. using GameFramework;
  7. using GameFramework.DataTable;
  8. using GameFramework.Sound;
  9. using GameFramework.Download;
  10. using GameFramework.FileSystem;
  11. using GameFramework.ObjectPool;
  12. using GameFramework.Resource;
  13. using System;
  14. namespace MetaClient
  15. {
  16. public class UICustom : UGuiForm
  17. {
  18. // Start is called before the first frame update
  19. [Header("初始界面")]
  20. public GameObject toolView;
  21. [Header("基础按钮界面")]
  22. public GameObject baseView;
  23. [Header("保存按钮")]
  24. public GameObject saveBtn;
  25. [Header("捏脸界面")]
  26. public GameObject nieLianView;
  27. [Header("身体界面")]
  28. public GameObject bodyView;
  29. [Header("衣服界面")]
  30. public GameObject clothView;
  31. //[Header("点击后生成的按钮列表")]
  32. //public GameObject buttonList;
  33. [Header("按钮预制体")]
  34. public GameObject buttonItem;
  35. [Header("颜色演示预制体")]
  36. public GameObject colItem;
  37. private float tween_leftMax = -100;
  38. private float tween_leftMix = 73.3f;
  39. private float tween_rightMin = 375f;
  40. private float tween_rightMax = 536f;
  41. private float tween_saveBtnMax = 119;
  42. private float tween_saveBtnMin = -108;
  43. //private float tweenTime = 10;
  44. //private float tweenLeastTime = 0;
  45. private bool isTween = false;
  46. [Header("选择界面分支")]
  47. [SerializeField]
  48. private ECustomStyple eCustomStyple = ECustomStyple.None;
  49. [Header("历史记录用于回退")]
  50. [SerializeField]
  51. private List<string> histroy;
  52. protected override void OnOpen(object userData)
  53. {
  54. base.OnOpen(userData);
  55. //IDataTable<DRCustomRole> _data = GameEntry.DataTable.GetDataTable<DRCustomRole>();
  56. }
  57. protected override void OnClose(bool isShutdown, object userData)
  58. {
  59. base.OnClose(isShutdown, userData);
  60. }
  61. public void ClickBtnFun(object[] _objects) {
  62. if (isTween)
  63. {
  64. return;
  65. }
  66. ECustomStyple _eCustomStyple = (ECustomStyple)int.Parse(_objects[0].ToString());
  67. switch (eCustomStyple)
  68. {
  69. case ECustomStyple.None:
  70. break;
  71. case ECustomStyple.NieLian:
  72. GameObject _nieLianList = nieLianView.transform.GetChild(0).gameObject;
  73. _nieLianList.SetActive(false);
  74. GameObject _nieLianXX = nieLianView.transform.GetChild(2).gameObject;
  75. break;
  76. case ECustomStyple.Body:
  77. break;
  78. case ECustomStyple.Cloth:
  79. break;
  80. }
  81. }
  82. //private IEnumerator Tween(Action _action) {
  83. // for (int i = 0; i < 100; i++)
  84. // {
  85. // float _value = i / 100;
  86. // float _right=Mathf.Lerp(tween_rightMax, tween_rightMin, _value);
  87. // float _left= Mathf.Lerp(tween_leftMix, tween_rightMax, _value);
  88. // clothView.GetComponent<RectTransform>().SetPositionX(_right);
  89. // toolView.GetComponent<RectTransform>().SetPositionX(_right);
  90. // bodyView.GetComponent<RectTransform>().SetPositionX(_right);
  91. // nieLianView.GetComponent<RectTransform>().SetPositionX(_right);
  92. // baseView.GetComponent<RectTransform>().SetPositionX(_left);
  93. // }
  94. // yield return null;
  95. //}
  96. protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
  97. {
  98. base.OnUpdate(elapseSeconds, realElapseSeconds);
  99. }
  100. private void CreateNieLianFun(object[] _objects) {
  101. ENieLianStyple _eNieLianStyple = (ENieLianStyple)int.Parse(_objects[1].ToString());
  102. switch (_eNieLianStyple)
  103. {
  104. case ENieLianStyple.faxing:
  105. break;
  106. case ENieLianStyple.lianxing:
  107. break;
  108. case ENieLianStyple.yankuang:
  109. break;
  110. case ENieLianStyple.tongkong:
  111. break;
  112. case ENieLianStyple.meimao:
  113. break;
  114. case ENieLianStyple.bizi:
  115. break;
  116. case ENieLianStyple.erduo:
  117. break;
  118. case ENieLianStyple.zuiba:
  119. break;
  120. case ENieLianStyple.fuse:
  121. break;
  122. }
  123. //switch()
  124. }
  125. private void CreateButtonFun(string path,GameObject _parent,Action action) {
  126. GameEntry.Resource.LoadAsset(AssetUtility.GetUISpriteAsset(path), new LoadAssetCallbacks(
  127. (assetName, asset, duration, userData) =>
  128. {
  129. Texture2D tex = (Texture2D)asset;
  130. var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
  131. GameObject _obj = GameObject.Instantiate(buttonItem);
  132. Image _objImg = _obj.transform.GetComponent<Image>();
  133. _objImg.sprite = sprite;
  134. _obj.transform.SetParent(_parent.transform);
  135. //GameObject
  136. //img.sprite = sprite;
  137. //if (nativeSize)
  138. //{
  139. // img.SetNativeSize();
  140. //}
  141. }));
  142. }
  143. //public void NieLian() {
  144. //}
  145. public void ClickFaceChangeBtn()
  146. {
  147. GameEntry.Event.Fire(this, CustomRoleFaceEventArgs.Create(EditableFacePart.eye, new Vector3(1, 0, 0)));
  148. }
  149. }
  150. public enum ECustomStyple
  151. {
  152. None,
  153. NieLian,
  154. Body,
  155. Cloth
  156. }
  157. public enum EButtonStyple
  158. {
  159. Button,
  160. Scroll,
  161. TiaoSe,
  162. NorButton,
  163. }
  164. public enum ENieLianStyple {
  165. faxing,
  166. lianxing,
  167. yankuang,
  168. tongkong,
  169. meimao,
  170. bizi,
  171. erduo,
  172. zuiba,
  173. fuse
  174. }
  175. }