UICustom.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  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. using DG.Tweening;
  15. namespace MetaClient
  16. {
  17. public class UICustom : UGuiForm
  18. {
  19. // Start is called before the first frame update
  20. [Header("初始界面")]
  21. public GameObject toolView;
  22. [Header("基础按钮界面")]
  23. public GameObject baseView;
  24. [Header("保存按钮")]
  25. public GameObject saveBtn;
  26. [Header("捏脸界面")]
  27. public GameObject nieLianView;
  28. [Header("身体界面")]
  29. public GameObject bodyView;
  30. [Header("自定义")]
  31. public GameObject ziDingYiBtn;
  32. [Header("衣服界面")]
  33. public GameObject clothView;
  34. [Header("左边界面")]
  35. public GameObject leftView;
  36. [Header("右边界面")]
  37. public GameObject rightView;
  38. //[Header("点击后生成的按钮列表")]
  39. //public GameObject buttonList;
  40. [Header("白底背景")]
  41. public GameObject whitebg;
  42. [Header("按钮预制体")]
  43. public GameObject buttonItem;
  44. [Header("滑块")]
  45. public Scrollbar scrollbar;
  46. [Header("颜色选择界面")]
  47. public GameObject colorView;
  48. [Header("调色版界面")]
  49. public GameObject tiaoSeBanView;
  50. // [Header("顺序")]
  51. private EButtonShunXu eButtonShunXu = EButtonShunXu.None;
  52. [Header("颜色演示预制体")]
  53. public GameObject colItem;
  54. public float tween_leftMax = 0;
  55. public float tween_leftMin = -250;
  56. public float tween_rightMin = 0;
  57. public float tween_rightMax = 223;
  58. //private float tween_saveBtnMax = 119;
  59. //private float tween_saveBtnMin = -108;
  60. private float tweenTime = 0.5f;
  61. //private float tweenTime = 10;
  62. //private float tweenLeastTime = 0;
  63. public bool isTween = false;
  64. [Header("选择界面分支")]
  65. [SerializeField]
  66. private ECustomStyple eCustomStyple = ECustomStyple.None;
  67. [Header("历史记录用于回退")]
  68. [SerializeField]
  69. private List<string> histroy;
  70. //用来判断是否是例如颜色框 调色板等额外的弹窗;
  71. private bool histroyextra;
  72. private int part = 0;
  73. private int id = -1;
  74. private GameObject nowPickOnImg=null;
  75. //[Header("接受到的数据")]
  76. //[SerializeField]
  77. private IDataTable<DRCustomBody> _bodydata;
  78. protected override void OnOpen(object userData)
  79. {
  80. base.OnOpen(userData);
  81. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  82. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  83. }
  84. protected override void OnClose(bool isShutdown, object userData)
  85. {
  86. base.OnClose(isShutdown, userData);
  87. }
  88. public void ClickBotton(ECustomStyple eCustomStyple,int id,bool ziDingYi)
  89. {
  90. if (isTween)
  91. {
  92. return;
  93. }
  94. isTween = true;
  95. leftView.transform.DOLocalMoveX(tween_leftMin, tweenTime).SetEase(Ease.InOutBack).OnComplete(()=> {
  96. //whitebg.SetActive(bg);
  97. ClickBtnFun(eCustomStyple,id,ziDingYi);
  98. leftView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  99. isTween = false;
  100. Debug.Log("222");
  101. });
  102. });
  103. Debug.Log("333");
  104. rightView.transform.DOLocalMoveX(tween_rightMax, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  105. rightView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  106. });
  107. });
  108. }
  109. /// <summary>
  110. /// 调色界面打开
  111. /// </summary>
  112. public void TiaoSeViewOpenFun() {
  113. rightView.SetActive(false);
  114. colorView.SetActive(true);
  115. }
  116. /// <summary>
  117. /// 调色板的调色板打开或关闭
  118. /// </summary>
  119. public void TiaoSeBanOpenStyple(bool _bo)
  120. {
  121. colorView.SetActive(_bo);
  122. tiaoSeBanView.SetActive(!_bo);
  123. }
  124. /// <summary>
  125. /// 调色板确认按钮
  126. /// </summary>
  127. public void TiaoSeSure()
  128. {
  129. TiaoSeBanOpenStyple(false);
  130. }
  131. /// <summary>
  132. /// 自定义调色板
  133. /// </summary>
  134. public void TiaoSeBanCustom() {
  135. }
  136. /// <summary>
  137. /// 设置是否已在缓动
  138. /// </summary>
  139. public void SetTween(bool _bo) {
  140. isTween = _bo;
  141. }
  142. /// <summary>
  143. /// 获取是否缓动
  144. /// </summary>
  145. public bool GetTween()
  146. {
  147. return isTween;
  148. }
  149. public void HistoryAdd(string _str) {
  150. histroy.Add(_str);
  151. }
  152. /// <summary>
  153. /// 滑块改变
  154. /// </summary>
  155. public void ScrollValueChange()
  156. {
  157. //Debug.Log(scrollbar.value);
  158. GameEntry.Event.Fire(this, CustomRoleBodyEventArgs.Create(part, new Vector3(scrollbar.value, 0, 0)));
  159. }
  160. public void BackBtn_Fun()
  161. {
  162. if (histroyextra)
  163. {
  164. BackExtraFun();
  165. histroyextra = false;
  166. return;
  167. }
  168. switch (this.histroy.Count)
  169. {
  170. case 0:
  171. Debug.Log("返回上一层");
  172. break;
  173. case 1:
  174. Debug.Log("返回选择捏脸/身体/服装");
  175. histroy.RemoveAt(histroy.Count - 1);
  176. Back_OneFun();
  177. break;
  178. case 2:
  179. Debug.Log("进入选择界面");
  180. histroy.RemoveAt(histroy.Count - 1);
  181. Back_TwoFun(true);
  182. break;
  183. default:
  184. Debug.Log("进入自定义或颜色");
  185. // histroy.RemoveAt(histroy.Count - 1);
  186. Back_ThreeFun();
  187. histroy.RemoveAt(histroy.Count - 1);
  188. break;
  189. }
  190. }
  191. public void BackBtnFun()
  192. {
  193. if (isTween)
  194. {
  195. return;
  196. }
  197. isTween = true;
  198. leftView.transform.DOLocalMoveX(tween_leftMin, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  199. //whitebg.SetActive(bg);
  200. BackBtn_Fun();
  201. leftView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  202. isTween = false;
  203. Debug.Log("222");
  204. });
  205. });
  206. Debug.Log("333");
  207. rightView.transform.DOLocalMoveX(tween_rightMax, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  208. rightView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  209. });
  210. });
  211. }
  212. /// <summary>
  213. /// 返回的方法一
  214. /// </summary>
  215. void Back_OneFun() {
  216. ViewSetFalse();
  217. toolView.SetActive(true);
  218. //toolView.SetActive(true);
  219. //bodyView.SetActive(false);
  220. //nieLianView.SetActive(false);
  221. //clothView.SetActive(false);
  222. }
  223. /// <summary>
  224. /// 返回的方法extra
  225. /// </summary>
  226. void BackExtraFun()
  227. {
  228. rightView.SetActive(true);
  229. scrollbar.gameObject.SetActive(false);
  230. }
  231. /// <summary>
  232. /// 面板全部隐藏
  233. /// </summary>
  234. void ViewSetFalse()
  235. {
  236. toolView.SetActive(false);
  237. bodyView.SetActive(false);
  238. nieLianView.SetActive(false);
  239. clothView.SetActive(false);
  240. }
  241. void BackView_Extra(GameObject _obj,bool _bo) {
  242. ViewSetFalse();
  243. _obj.SetActive(_bo);
  244. ViewSetChildTrue(_obj,_bo);
  245. }
  246. void ViewSetChildTrue(GameObject _obj,bool _bo)
  247. {
  248. _obj.transform.GetChild(0).gameObject.SetActive(_bo);
  249. _obj.transform.GetChild(0).gameObject.SetActive(_bo);
  250. _obj.transform.GetChild(2).gameObject.SetActive(!_bo);
  251. }
  252. /// <summary>
  253. /// 返回的方法二
  254. /// </summary>
  255. void Back_TwoFun(bool _bo)
  256. {
  257. // int _choose = int.Parse(histroy[1]);
  258. // switch ((ECustomStyple)_choose)
  259. whitebg.SetActive(false);
  260. switch(eCustomStyple)
  261. {
  262. case ECustomStyple.Body:
  263. BackView_Extra(bodyView,_bo);
  264. break;
  265. case ECustomStyple.Cloth:
  266. BackView_Extra(clothView, _bo);
  267. break;
  268. case ECustomStyple.None:
  269. break;
  270. case ECustomStyple.NieLian:
  271. BackView_Extra(nieLianView, _bo);
  272. break;
  273. }
  274. //toolView.SetActive(true);
  275. //bodyView.SetActive(false);
  276. //nieLianView.SetActive(false);
  277. //clothView.SetActive(false);
  278. }
  279. /// <summary>
  280. /// 返回的方法三
  281. /// </summary>
  282. void Back_ThreeFun()
  283. {
  284. string[] _strArrary = histroy[histroy.Count - 1].Split(',');
  285. if (_strArrary[0] == "Color")
  286. {
  287. colorView.SetActive(false);
  288. rightView.SetActive(true);
  289. }
  290. else if (_strArrary[0] == "ziDingyi")
  291. {
  292. int _chooseId = int.Parse(_strArrary[1]);
  293. ClickBtnFun(eCustomStyple, _chooseId, false);
  294. }
  295. else
  296. {
  297. Debug.Log("缺少当前情况需要添加>>>>");
  298. }
  299. //toolView.SetActive(true);
  300. //bodyView.SetActive(false);
  301. //nieLianView.SetActive(false);
  302. //clothView.SetActive(false);
  303. }
  304. public void PickOnButton(GameObject _obj,int _id) {
  305. if (_obj.transform.childCount <= 0)
  306. {
  307. return;
  308. }
  309. GameObject _nowPickOnImg = _obj.transform.GetChild(0).gameObject;
  310. if (nowPickOnImg==null)
  311. {
  312. nowPickOnImg = _nowPickOnImg;
  313. id = _id;
  314. nowPickOnImg.SetActive(true);
  315. }
  316. else
  317. {
  318. if (_id != id)
  319. {
  320. nowPickOnImg.SetActive(false);
  321. id = _id;
  322. nowPickOnImg = _nowPickOnImg;
  323. _nowPickOnImg.SetActive(true);
  324. }
  325. else
  326. {
  327. nowPickOnImg = _nowPickOnImg;
  328. _nowPickOnImg.SetActive(!_nowPickOnImg.activeSelf);
  329. }
  330. }
  331. scrollbar.gameObject.SetActive(nowPickOnImg.activeSelf);
  332. }
  333. /// <summary>
  334. /// 修改滑块
  335. /// </summary>
  336. public void SetValue(int _part,ECustomStyple eCustomStyple)
  337. {
  338. //scrollbar.value = _value;
  339. part = _part;
  340. scrollbar.value = CustomManager.Instance.GetBodyBoneValue(part);
  341. }
  342. /// <summary>
  343. /// 获得滑块值
  344. /// </summary>
  345. public float GetValue()
  346. {
  347. return scrollbar.value;
  348. }
  349. /// <summary>
  350. /// 修改颜色
  351. /// </summary>
  352. public void SetColor(int _part, ECustomStyple eCustomStyple)
  353. {
  354. //scrollbar.value = _value;
  355. part = _part;
  356. }
  357. /// <summary>
  358. /// 按钮点击事件
  359. /// </summary>
  360. public void ClickBtnFun(ECustomStyple eCustomStyple,int id,bool zidingyi) {
  361. //if (isTween)
  362. //{
  363. // return;
  364. //}
  365. whitebg.SetActive(true);
  366. scrollbar.gameObject.SetActive(false);
  367. this.eCustomStyple = eCustomStyple;
  368. //ECustomStyple _eCustomStyple = (ECustomStyple)int.Parse(_objects[0].ToString());
  369. switch (eCustomStyple)
  370. {
  371. case ECustomStyple.None:
  372. break;
  373. case ECustomStyple.NieLian:
  374. GameObject _nieLianList = nieLianView.transform.GetChild(0).gameObject;
  375. _nieLianList.SetActive(false);
  376. GameObject _nieLianXX = nieLianView.transform.GetChild(2).gameObject;
  377. _nieLianXX.SetActive(true);
  378. //if (!zidingyi)
  379. //{
  380. // ZiDingYiNeiLian(eCustomStyple, id, _nieLianXX.transform.GetChild(0).gameObject);
  381. // return;
  382. //}
  383. CreateNieLianImg(id, zidingyi);
  384. break;
  385. case ECustomStyple.Body:
  386. GameObject _bodyList = bodyView.transform.GetChild(0).gameObject;
  387. _bodyList.SetActive(false);
  388. GameObject _bodyListXX =bodyView.transform.GetChild(2).gameObject;
  389. _bodyListXX.SetActive(true);
  390. //if (!zidingyi)
  391. //{
  392. // ZiDingYiBody(eCustomStyple, id, _bodyListXX.transform.GetChild(0).gameObject);
  393. // return;
  394. //}
  395. CreateBodyImg(id, zidingyi);
  396. break;
  397. case ECustomStyple.Cloth:
  398. GameObject _clothList = clothView.transform.GetChild(0).gameObject;
  399. _clothList.SetActive(false);
  400. GameObject _clothListXX = clothView.transform.GetChild(2).gameObject;
  401. _clothListXX.SetActive(true);
  402. //if (!zidingyi)
  403. //{
  404. // ZiDingYiCloth(eCustomStyple, id, _clothListXX.transform.GetChild(0).gameObject);
  405. // return;
  406. //}
  407. CreateClothImg(id, zidingyi);
  408. break;
  409. }
  410. }
  411. //public Action ActionFun() {
  412. // return null;
  413. //}
  414. private void RemoveAllChildren(GameObject parent)
  415. {
  416. Transform transform;
  417. for (int i = 0; i < parent.transform.childCount; i++)
  418. {
  419. transform = parent.transform.GetChild(i);
  420. GameObject.Destroy(transform.gameObject);
  421. }
  422. }
  423. //public void ZiDingYiNeiLian(ECustomStyple eCustomStyple, int id,GameObject _objPar) {
  424. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  425. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  426. // _obj.transform.SetParent(_objPar.transform);
  427. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  428. // _uICustomBtn.id = id;
  429. // _uICustomBtn.eCustomStyple = eCustomStyple;
  430. // _obj.SetActive(true);
  431. //}
  432. //public void ZiDingYiBody(ECustomStyple eCustomStyple, int id, GameObject _objPar)
  433. //{
  434. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  435. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  436. // _obj.transform.SetParent(_objPar.transform);
  437. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  438. // _uICustomBtn.id = id;
  439. // _uICustomBtn.eCustomStyple = eCustomStyple;
  440. // _obj.SetActive(true);
  441. //}
  442. //public void ZiDingYiCloth(ECustomStyple eCustomStyple, int id, GameObject _objPar)
  443. //{
  444. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  445. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  446. // _obj.transform.SetParent(_objPar.transform);
  447. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  448. // _uICustomBtn.id = id;
  449. // _uICustomBtn.eCustomStyple = eCustomStyple;
  450. // _obj.SetActive(true);
  451. //}
  452. public void CreateNieLianImg(int parentid, bool ziDingYi)
  453. {
  454. GameObject _objPar = bodyView.transform.GetChild(2).GetChild(0).gameObject;
  455. RemoveAllChildren(_objPar);
  456. //等有捏脸表时改为捏脸
  457. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  458. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  459. int cengji = ziDingYi ? 0 : 1;
  460. if (ziDingYi)
  461. {
  462. CreateZDYFun(parentid, _objPar);
  463. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  464. //_obj.transform.SetParent(_objPar.transform);
  465. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  466. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  467. //_uICustomBtn.id =parentid;
  468. //_uICustomBtn.eCustomStyple = eCustomStyple;
  469. //_obj.SetActive(true);
  470. }
  471. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  472. for (int i = 0; i < dRCustomBodies.Length; i++)
  473. {
  474. Debug.Log(dRCustomBodies[i].Id);
  475. if (dRCustomBodies[i].ParentStyple == parentid&&dRCustomBodies[i].Cengji==cengji)
  476. {
  477. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Part, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  478. }
  479. }
  480. ChangeListBotton(_objPar);
  481. }
  482. public void CreateClothImg(int parentid,bool ziDingYi)
  483. {
  484. GameObject _objPar = bodyView.transform.GetChild(2).GetChild(0).gameObject;
  485. RemoveAllChildren(_objPar);
  486. //等有服装时改为服装
  487. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  488. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  489. int cengji = ziDingYi ? 0 : 1;
  490. if (ziDingYi)
  491. {
  492. CreateZDYFun(parentid, _objPar);
  493. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  494. //_obj.transform.SetParent(_objPar.transform);
  495. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  496. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  497. //_uICustomBtn.id = parentid;
  498. //_uICustomBtn.eCustomStyple = eCustomStyple;
  499. //_obj.SetActive(true);
  500. }
  501. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  502. for (int i = 0; i < dRCustomBodies.Length; i++)
  503. {
  504. Debug.Log(dRCustomBodies[i].Id);
  505. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  506. {
  507. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Part, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  508. }
  509. }
  510. ChangeListBotton(_objPar);
  511. }
  512. private void CreateZDYFun(int parentid,GameObject _objPar)
  513. {
  514. GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  515. _obj.transform.SetParent(_objPar.transform);
  516. UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  517. ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  518. }
  519. public void ChangeUICustom(UICustomBtn uICustomBtn,int id, ECustomStyple eCustomStyple)
  520. {
  521. uICustomBtn.id = id;
  522. uICustomBtn.eCustomStyple = eCustomStyple;
  523. uICustomBtn.gameObject.SetActive(true);
  524. }
  525. public void CreateBodyImg(int parentid,bool ziDingYi) {
  526. GameObject _objPar = bodyView.transform.GetChild(2).GetChild(0).gameObject;
  527. RemoveAllChildren(_objPar);
  528. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  529. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  530. int cengji = ziDingYi ?0:1;
  531. if (ziDingYi)
  532. {
  533. CreateZDYFun(parentid, _objPar);
  534. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  535. //_obj.transform.SetParent(_objPar.transform);
  536. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  537. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  538. //_uICustomBtn.id = parentid;
  539. //_uICustomBtn.eCustomStyple = eCustomStyple;
  540. //_obj.SetActive(true);
  541. }
  542. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  543. for (int i = 0; i < dRCustomBodies.Length; i++)
  544. {
  545. Debug.Log(dRCustomBodies[i].Id);
  546. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  547. {
  548. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Part, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  549. }
  550. }
  551. ChangeListBotton(_objPar);
  552. }
  553. /// <summary>
  554. /// 改变列表长短
  555. /// </summary>
  556. public void ChangeListBotton(GameObject _obj) {
  557. //Debug.Log("改变列表"+ _obj.transform.childCount+"");
  558. float _x = _obj.GetComponent<RectTransform>().offsetMin.x;
  559. int _childNum = _obj.transform.childCount;
  560. float _y = _childNum > 7 ? -240 * (_childNum - 7) : 0;
  561. _obj.GetComponent<RectTransform>().offsetMax = new Vector2(_x, 0);
  562. _obj.GetComponent<RectTransform>().offsetMin = new Vector2(_x, _y);
  563. }
  564. //private IEnumerator Tween(Action _action) {
  565. // for (int i = 0; i < 100; i++)
  566. // {
  567. // float _value = i / 100;
  568. // float _right=Mathf.Lerp(tween_rightMax, tween_rightMin, _value);
  569. // float _left= Mathf.Lerp(tween_leftMix, tween_rightMax, _value);
  570. // clothView.GetComponent<RectTransform>().SetPositionX(_right);
  571. // toolView.GetComponent<RectTransform>().SetPositionX(_right);
  572. // bodyView.GetComponent<RectTransform>().SetPositionX(_right);
  573. // nieLianView.GetComponent<RectTransform>().SetPositionX(_right);
  574. // baseView.GetComponent<RectTransform>().SetPositionX(_left);
  575. // }
  576. // yield return null;
  577. //}
  578. protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
  579. {
  580. base.OnUpdate(elapseSeconds, realElapseSeconds);
  581. }
  582. //private void CreateNieLianFun(object[] _objects) {
  583. // ENieLianStyple _eNieLianStyple = (ENieLianStyple)int.Parse(_objects[1].ToString());
  584. // switch (_eNieLianStyple)
  585. // {
  586. // case ENieLianStyple.faxing:
  587. // break;
  588. // case ENieLianStyple.lianxing:
  589. // break;
  590. // case ENieLianStyple.yankuang:
  591. // break;
  592. // case ENieLianStyple.tongkong:
  593. // break;
  594. // case ENieLianStyple.meimao:
  595. // break;
  596. // case ENieLianStyple.bizi:
  597. // break;
  598. // case ENieLianStyple.erduo:
  599. // break;
  600. // case ENieLianStyple.zuiba:
  601. // break;
  602. // case ENieLianStyple.fuse:
  603. // break;
  604. // }
  605. // //switch()
  606. //}
  607. private void CreateButtonFun(string path,int _part,string _name, GameObject _parent,int _id,int buttonstyple,ECustomStyple eCustomStyple,int _isactive) {
  608. //Debug.Log(path);
  609. // Debug.Log(_parent);
  610. path = "CustomRole/" + path;
  611. GameEntry.Resource.LoadAsset(AssetUtility.GetUISpriteAsset(path), new LoadAssetCallbacks(
  612. (assetName, asset, duration, userData) =>
  613. {
  614. // Debug.Log(path);
  615. // Debug.Log(_parent);
  616. Texture2D tex = (Texture2D)asset;
  617. var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
  618. GameObject _obj = GameObject.Instantiate(buttonItem);
  619. Image _objImg = _obj.transform.GetComponent<Image>();
  620. _obj.SetActive(true);
  621. _objImg.sprite = sprite;
  622. _obj.name = part+"";
  623. _obj.transform.SetParent(_parent.transform);
  624. if (_isactive != 1)
  625. {
  626. _obj.SetActive(false);
  627. }
  628. UICustomBtn uICustomBtn = _obj.GetComponent<UICustomBtn>();
  629. uICustomBtn.id = _id;
  630. uICustomBtn.eButtonStyple = (EButtonStyple)buttonstyple;
  631. uICustomBtn.eCustomStyple = eCustomStyple;
  632. uICustomBtn.isCreate = false;
  633. uICustomBtn.part = _part;
  634. //GameObject
  635. //img.sprite = sprite;
  636. //if (nativeSize)
  637. //{
  638. // img.SetNativeSize();
  639. //}
  640. ChangeListBotton(_parent);
  641. }));
  642. }
  643. //public void NieLian() {
  644. //}
  645. public void ClickFaceChangeBtn()
  646. {
  647. GameEntry.Event.Fire(this, CustomRoleFaceEventArgs.Create(EditableFacePart.eye, new Vector3(1, 0, 0)));
  648. }
  649. }
  650. public enum ECustomStyple
  651. {
  652. None,
  653. NieLian,
  654. Body,
  655. Cloth
  656. }
  657. public enum EButtonStyple
  658. {
  659. Button,
  660. Scroll,
  661. TiaoSe,
  662. NorButton,
  663. Back
  664. }
  665. public enum ENieLianStyple {
  666. None,
  667. faxing,
  668. lianxing,
  669. yankuang,
  670. tongkong,
  671. meimao,
  672. bizi,
  673. erduo,
  674. zuiba,
  675. fuse
  676. }
  677. public enum EButtonShunXu {
  678. None,
  679. First,
  680. Second,
  681. Third
  682. }
  683. public enum ETSStyple {
  684. None,
  685. ViewOpen,
  686. Close,
  687. Sure,
  688. Open,
  689. Button
  690. }
  691. }