UICustom.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  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 ornamentsView;
  36. [Header("左边界面")]
  37. public GameObject leftView;
  38. [Header("右边界面")]
  39. public GameObject rightView;
  40. //[Header("点击后生成的按钮列表")]
  41. //public GameObject buttonList;
  42. [Header("白底背景")]
  43. public GameObject whitebg;
  44. [Header("按钮预制体")]
  45. public GameObject buttonItem;
  46. [Header("滑块")]
  47. public Scrollbar scrollbar;
  48. [Header("颜色选择界面")]
  49. public GameObject colorView;
  50. [Header("调色版界面")]
  51. public GameObject tiaoSeBanView;
  52. // [Header("顺序")]
  53. private EButtonShunXu eButtonShunXu = EButtonShunXu.None;
  54. [Header("颜色演示预制体")]
  55. public GameObject colItem;
  56. public bool hasColorChoose = false;
  57. public float tween_leftMax = 0;
  58. public float tween_leftMin = -250;
  59. public float tween_rightMin = 0;
  60. public float tween_rightMax = 223;
  61. //private float tween_saveBtnMax = 119;
  62. //private float tween_saveBtnMin = -108;
  63. private float tweenTime = 0.5f;
  64. //private float tweenTime = 10;
  65. //private float tweenLeastTime = 0;
  66. private GameObject nowChooseColorObj;
  67. public bool isTween = false;
  68. [Header("选择界面分支")]
  69. [SerializeField]
  70. private ECustomStyple eCustomStyple = ECustomStyple.None;
  71. [Header("历史记录用于回退")]
  72. [SerializeField]
  73. private List<string> histroy;
  74. //用来判断是否是例如颜色框 调色板等额外的弹窗;
  75. private bool histroyextra;
  76. private int part = 0;
  77. private int id = -1;
  78. private GameObject nowPickOnImg=null;
  79. private Vector3 colorV3 = new Vector3(0, 0, 0);
  80. //[Header("接受到的数据")]
  81. //[SerializeField]
  82. private IDataTable<DRCustomBody> _bodydata;
  83. private IDataTable<DRCustomFace> _facedata;
  84. public void ChangeECustomStyple(ECustomStyple ec) {
  85. eCustomStyple = ec;
  86. }
  87. protected override void OnOpen(object userData)
  88. {
  89. base.OnOpen(userData);
  90. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  91. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  92. _facedata = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  93. }
  94. public void ColorChange(Vector3 _v3) {
  95. colorV3 = _v3;
  96. }
  97. public void SaveColorChange()
  98. {
  99. var a = new UIColorData(eCustomStyple,id,colorV3);
  100. String str = JsonUtility.ToJson(a);
  101. // var obj = JsonUtility.FromJson<PartData>(str);
  102. SaveColorAdd(3);
  103. SaveColorAdd(2);
  104. GameEntry.Setting.SetString("savecolor"+eCustomStyple+"/"+id+"/"+1, str);
  105. GameEntry.Setting.Save();
  106. ChooseColorChange();
  107. //GameEntry.Setting.HasSetting("savecolor");
  108. //GameEntry.Setting.GetString("");
  109. }
  110. public void SaveColorAdd(int _Index)
  111. {
  112. if (GameEntry.Setting.HasSetting("savecolor" + eCustomStyple + "/" + id + "/"+_Index))
  113. {
  114. String _saveStr=GameEntry.Setting.GetString("savecolor" + eCustomStyple + "/" + id + "/" + (_Index-1));
  115. GameEntry.Setting.SetString("savecolor" + eCustomStyple + "/" + id + "/" +_Index, _saveStr);
  116. }
  117. }
  118. public void ColorHuaDong(Vector3 _v3)
  119. {
  120. colorV3 = _v3;
  121. }
  122. public void ChooseColorChange()
  123. {
  124. Debug.Log(nowChooseColorObj.transform.parent.name);
  125. if (nowChooseColorObj!=null)
  126. {
  127. Image _img=nowChooseColorObj.transform.GetComponent<Image>();
  128. _img.color = new Color(colorV3.x,colorV3.y,colorV3.z);
  129. }
  130. }
  131. protected override void OnClose(bool isShutdown, object userData)
  132. {
  133. base.OnClose(isShutdown, userData);
  134. }
  135. public void ClickBotton(ECustomStyple eCustomStyple,int id,bool ziDingYi,bool isColor)
  136. {
  137. if (isTween)
  138. {
  139. return;
  140. }
  141. isTween = true;
  142. leftView.transform.DOLocalMoveX(tween_leftMin, tweenTime).SetEase(Ease.InOutBack).OnComplete(()=> {
  143. //whitebg.SetActive(bg);
  144. ClickBtnFun(eCustomStyple,id,ziDingYi,isColor);
  145. leftView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  146. isTween = false;
  147. Debug.Log("222");
  148. });
  149. });
  150. Debug.Log("333");
  151. rightView.transform.DOLocalMoveX(tween_rightMax, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  152. rightView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  153. });
  154. });
  155. }
  156. /// <summary>
  157. /// 调色界面打开
  158. /// </summary>
  159. public void TiaoSeViewOpenFun() {
  160. HistoryAdd("Color");
  161. rightView.SetActive(false);
  162. colorView.SetActive(true);
  163. }
  164. /// <summary>
  165. /// 调色板的调色板打开或关闭
  166. /// </summary>
  167. public void TiaoSeBanOpenStyple(bool _bo)
  168. {
  169. colorView.SetActive(!_bo);
  170. tiaoSeBanView.SetActive(_bo);
  171. }
  172. /// <summary>
  173. /// 调色板确认按钮
  174. /// </summary>
  175. public void TiaoSeSure()
  176. {
  177. SaveColorChange();
  178. TiaoSeBanOpenStyple(false);
  179. }
  180. /// <summary>
  181. /// 调色板取消按钮
  182. /// </summary>
  183. public void TiaoSeBanCloseFun() {
  184. }
  185. /// <summary>
  186. /// 自定义调色板
  187. /// </summary>
  188. public void TiaoSeBanCustom() {
  189. }
  190. public void TiaoSeViewRefesh() {
  191. GameObject _obj = tiaoSeBanView.transform.GetChild(0).GetChild(0).gameObject;
  192. RemoveAllChildren(_obj, 1);
  193. }
  194. public void TiaoSeAddItem(GameObject _par) {
  195. if (GameEntry.Setting.HasSetting("savecolor" + eCustomStyple + "/" + id + "/" + 3))
  196. {
  197. }
  198. GameObject _clone = GameObject.Instantiate(colItem);
  199. _clone.transform.SetParent(_par.transform);
  200. }
  201. public bool HasCustomColor(int _index)
  202. {
  203. bool _has = GameEntry.Setting.HasSetting("savecolor" + eCustomStyple + "/" + id + "/" + _index+"");
  204. return _has;
  205. }
  206. //public UIColorData GetUIColorData(int _index) {
  207. // String _str= GameEntry.Setting.GetString("savecolor" + eCustomStyple + "/" + id + "/" + _index+"");
  208. // return
  209. //}
  210. /// <summary>
  211. /// 设置是否已在缓动
  212. /// </summary>
  213. public void SetTween(bool _bo) {
  214. isTween = _bo;
  215. }
  216. /// <summary>
  217. /// 获取是否缓动
  218. /// </summary>
  219. public bool GetTween()
  220. {
  221. return isTween;
  222. }
  223. public void HistoryAdd(string _str) {
  224. histroy.Add(_str);
  225. }
  226. /// <summary>
  227. /// 滑块改变
  228. /// </summary>
  229. public void ScrollValueChange()
  230. {
  231. //Debug.Log(scrollbar.value);
  232. switch (eCustomStyple)
  233. {
  234. case ECustomStyple.None:
  235. break;
  236. case ECustomStyple.Body:
  237. GameEntry.Event.Fire(this, CustomRoleBodyEventArgs.Create(part, new Vector3(scrollbar.value, 0, 0)));
  238. break;
  239. case ECustomStyple.NieLian:
  240. break;
  241. case ECustomStyple.Cloth:
  242. break;
  243. }
  244. // GameEntry.Event.Fire(this, CustomRoleBodyEventArgs.Create(part, new Vector3(scrollbar.value, 0, 0)));
  245. }
  246. public void BackBtn_Fun()
  247. {
  248. if (histroyextra)
  249. {
  250. BackExtraFun();
  251. histroyextra = false;
  252. return;
  253. }
  254. int index = this.histroy.Count;
  255. index = eCustomStyple == ECustomStyple.Ornament ? index - 1 : index;
  256. switch (this.histroy.Count)
  257. {
  258. case 0:
  259. Debug.Log("返回上一层");
  260. //GameEntry.UI.CloseUIForm(104);
  261. GameEntry.UI.OpenUIForm(UIFormId.GameMenuForm);
  262. // Close();
  263. break;
  264. case 1:
  265. Debug.Log("返回选择捏脸/身体/服装");
  266. histroy.RemoveAt(histroy.Count - 1);
  267. Back_OneFun();
  268. break;
  269. case 2:
  270. Debug.Log("进入选择界面");
  271. scrollbar.gameObject.SetActive(false);
  272. histroy.RemoveAt(histroy.Count - 1);
  273. Back_TwoFun(true);
  274. break;
  275. default:
  276. Debug.Log("进入自定义或颜色");
  277. // histroy.RemoveAt(histroy.Count - 1);
  278. Back_ThreeFun();
  279. histroy.RemoveAt(histroy.Count - 1);
  280. break;
  281. }
  282. }
  283. public void BackBtnFun()
  284. {
  285. if (isTween)
  286. {
  287. return;
  288. }
  289. //if (histroy.Count == 0)
  290. //{
  291. // GameEntry.UI.OpenUIForm(UIFormId.GameMenuForm);
  292. // Close();
  293. // return;
  294. //}
  295. isTween = true;
  296. leftView.transform.DOLocalMoveX(tween_leftMin, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  297. //whitebg.SetActive(bg);
  298. BackBtn_Fun();
  299. leftView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  300. isTween = false;
  301. Debug.Log("222");
  302. });
  303. });
  304. Debug.Log("333");
  305. rightView.transform.DOLocalMoveX(tween_rightMax, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  306. rightView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  307. });
  308. });
  309. }
  310. /// <summary>
  311. /// 返回的方法一
  312. /// </summary>
  313. void Back_OneFun() {
  314. ViewSetFalse();
  315. toolView.SetActive(true);
  316. //toolView.SetActive(true);
  317. //bodyView.SetActive(false);
  318. //nieLianView.SetActive(false);
  319. //clothView.SetActive(false);
  320. }
  321. /// <summary>
  322. /// 返回的方法extra
  323. /// </summary>
  324. void BackExtraFun()
  325. {
  326. rightView.SetActive(true);
  327. scrollbar.gameObject.SetActive(false);
  328. }
  329. /// <summary>
  330. /// 面板全部隐藏
  331. /// </summary>
  332. void ViewSetFalse()
  333. {
  334. toolView.SetActive(false);
  335. bodyView.SetActive(false);
  336. nieLianView.SetActive(false);
  337. clothView.SetActive(false);
  338. }
  339. void BackView_Extra(GameObject _obj,bool _bo) {
  340. ViewSetFalse();
  341. _obj.SetActive(_bo);
  342. ViewSetChildTrue(_obj,_bo);
  343. }
  344. void ViewSetChildTrue(GameObject _obj,bool _bo)
  345. {
  346. _obj.transform.GetChild(0).gameObject.SetActive(_bo);
  347. _obj.transform.GetChild(0).gameObject.SetActive(_bo);
  348. _obj.transform.GetChild(2).gameObject.SetActive(!_bo);
  349. }
  350. /// <summary>
  351. /// 返回的方法二
  352. /// </summary>
  353. void Back_TwoFun(bool _bo)
  354. {
  355. // int _choose = int.Parse(histroy[1]);
  356. // switch ((ECustomStyple)_choose)
  357. whitebg.SetActive(false);
  358. switch(eCustomStyple)
  359. {
  360. case ECustomStyple.Body:
  361. BackView_Extra(bodyView,_bo);
  362. break;
  363. case ECustomStyple.Cloth:
  364. BackView_Extra(clothView, _bo);
  365. break;
  366. case ECustomStyple.None:
  367. break;
  368. case ECustomStyple.NieLian:
  369. BackView_Extra(nieLianView, _bo);
  370. break;
  371. case ECustomStyple.Ornament:
  372. // BackView_Extra(ornamentsView, _bo);
  373. BackView_Extra(clothView, _bo);
  374. ornamentsView.SetActive(false);
  375. break;
  376. }
  377. //toolView.SetActive(true);
  378. //bodyView.SetActive(false);
  379. //nieLianView.SetActive(false);
  380. //clothView.SetActive(false);
  381. }
  382. /// <summary>
  383. /// 返回的方法三
  384. /// </summary>
  385. void Back_ThreeFun()
  386. {
  387. string[] _strArrary = histroy[histroy.Count - 1].Split(',');
  388. if (_strArrary[0] == "Color")
  389. {
  390. colorView.SetActive(false);
  391. rightView.SetActive(true);
  392. }
  393. else if (_strArrary[0] == "ziDingyi")
  394. {
  395. scrollbar.gameObject.SetActive(false);
  396. int _chooseId = int.Parse(_strArrary[2]);
  397. hasColorChoose = int.Parse(_strArrary[1]) == 1 ? true : false;
  398. ClickBtnFun(eCustomStyple, _chooseId, true,hasColorChoose);
  399. }
  400. else
  401. {
  402. Debug.Log("缺少当前情况需要添加>>>>");
  403. }
  404. //toolView.SetActive(true);
  405. //bodyView.SetActive(false);
  406. //nieLianView.SetActive(false);
  407. //clothView.SetActive(false);
  408. }
  409. public void PickOnButton(GameObject _obj,int _id) {
  410. if (_obj.transform.childCount <= 0)
  411. {
  412. return;
  413. }
  414. GameObject _nowPickOnImg = _obj.transform.GetChild(0).gameObject;
  415. if (nowPickOnImg==null)
  416. {
  417. nowPickOnImg = _nowPickOnImg;
  418. id = _id;
  419. nowPickOnImg.SetActive(true);
  420. }
  421. else
  422. {
  423. if (_id != id)
  424. {
  425. nowPickOnImg.SetActive(false);
  426. id = _id;
  427. nowPickOnImg = _nowPickOnImg;
  428. _nowPickOnImg.SetActive(true);
  429. }
  430. else
  431. {
  432. nowPickOnImg = _nowPickOnImg;
  433. _nowPickOnImg.SetActive(!_nowPickOnImg.activeSelf);
  434. }
  435. }
  436. scrollbar.gameObject.SetActive(nowPickOnImg.activeSelf);
  437. }
  438. /// <summary>
  439. /// 修改滑块
  440. /// </summary>
  441. public void SetValue(int _part,ECustomStyple eCustomStyple)
  442. {
  443. //scrollbar.value = _value;
  444. part = _part;
  445. scrollbar.value = CustomManager.Instance.GetBodyBoneValue(part);
  446. }
  447. /// <summary>
  448. /// 获得滑块值
  449. /// </summary>
  450. public float GetValue()
  451. {
  452. return scrollbar.value;
  453. }
  454. /// <summary>
  455. /// 修改颜色
  456. /// </summary>
  457. public void SetColor(int _part, ECustomStyple eCustomStyple)
  458. {
  459. //scrollbar.value = _value;
  460. part = _part;
  461. }
  462. /// <summary>
  463. /// 按钮点击事件
  464. /// </summary>
  465. public void ClickBtnFun(ECustomStyple eCustomStyple,int id,bool zidingyi,bool isColor) {
  466. //if (isTween)
  467. //{
  468. // return;
  469. //}
  470. hasColorChoose = isColor;
  471. whitebg.SetActive(true);
  472. scrollbar.gameObject.SetActive(false);
  473. this.eCustomStyple = eCustomStyple;
  474. //ECustomStyple _eCustomStyple = (ECustomStyple)int.Parse(_objects[0].ToString());
  475. switch (eCustomStyple)
  476. {
  477. case ECustomStyple.None:
  478. break;
  479. case ECustomStyple.NieLian:
  480. XXListShow(nieLianView);
  481. //GameObject _nieLianList = nieLianView.transform.GetChild(0).gameObject;
  482. //_nieLianList.SetActive(false);
  483. //GameObject _nieLianXX = nieLianView.transform.GetChild(2).gameObject;
  484. //_nieLianXX.SetActive(true);
  485. //if (!zidingyi)
  486. //{
  487. // ZiDingYiNeiLian(eCustomStyple, id, _nieLianXX.transform.GetChild(0).gameObject);
  488. // return;
  489. //}
  490. CreateNieLianImg(id, zidingyi,isColor);
  491. break;
  492. case ECustomStyple.Body:
  493. XXListShow(bodyView);
  494. //GameObject _bodyList = bodyView.transform.GetChild(0).gameObject;
  495. //_bodyList.SetActive(false);
  496. //GameObject _bodyListXX =bodyView.transform.GetChild(2).gameObject;
  497. //_bodyListXX.SetActive(true);
  498. //if (!zidingyi)
  499. //{
  500. // ZiDingYiBody(eCustomStyple, id, _bodyListXX.transform.GetChild(0).gameObject);
  501. // return;
  502. //}
  503. CreateBodyImg(id, zidingyi,isColor);
  504. break;
  505. case ECustomStyple.Cloth:
  506. XXListShow(clothView);
  507. //GameObject _clothList = clothView.transform.GetChild(0).gameObject;
  508. //_clothList.SetActive(false);
  509. //GameObject _clothListXX = clothView.transform.GetChild(2).gameObject;
  510. //_clothListXX.SetActive(true);
  511. //if (!zidingyi)
  512. //{
  513. // ZiDingYiCloth(eCustomStyple, id, _clothListXX.transform.GetChild(0).gameObject);
  514. // return;
  515. //}
  516. CreateClothImg(id, zidingyi,isColor);
  517. break;
  518. case ECustomStyple.Ornament:
  519. XXListShow(ornamentsView);
  520. //GameObject _Ornament = ornamentsView.transform.GetChild(0).gameObject;
  521. //_Ornament.SetActive(false);
  522. //GameObject _OrnamentXX = ornamentsView.transform.GetChild(2).gameObject;
  523. //_OrnamentXX.SetActive(true);
  524. break;
  525. }
  526. }
  527. public void XXListShow(GameObject obj)
  528. {
  529. obj.transform.GetChild(0).gameObject.SetActive(false);
  530. obj.transform.GetChild(2).gameObject.SetActive(true);
  531. }
  532. //public Action ActionFun() {
  533. // return null;
  534. //}
  535. public void ModelMove(Vector2 v2)
  536. {
  537. Debug.Log(v2.x);
  538. //CustomManaget.Instance.RotateModel(v2.x);
  539. }
  540. private void RemoveAllChildren(GameObject parent,int _index=0)
  541. {
  542. Transform transform;
  543. for (int i = _index; i < parent.transform.childCount; i++)
  544. {
  545. transform = parent.transform.GetChild(i);
  546. GameObject.Destroy(transform.gameObject);
  547. }
  548. }
  549. //public void ZiDingYiNeiLian(ECustomStyple eCustomStyple, int id,GameObject _objPar) {
  550. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  551. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  552. // _obj.transform.SetParent(_objPar.transform);
  553. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  554. // _uICustomBtn.id = id;
  555. // _uICustomBtn.eCustomStyple = eCustomStyple;
  556. // _obj.SetActive(true);
  557. //}
  558. //public void ZiDingYiBody(ECustomStyple eCustomStyple, int id, GameObject _objPar)
  559. //{
  560. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  561. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  562. // _obj.transform.SetParent(_objPar.transform);
  563. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  564. // _uICustomBtn.id = id;
  565. // _uICustomBtn.eCustomStyple = eCustomStyple;
  566. // _obj.SetActive(true);
  567. //}
  568. //public void ZiDingYiCloth(ECustomStyple eCustomStyple, int id, GameObject _objPar)
  569. //{
  570. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  571. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  572. // _obj.transform.SetParent(_objPar.transform);
  573. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  574. // _uICustomBtn.id = id;
  575. // _uICustomBtn.eCustomStyple = eCustomStyple;
  576. // _obj.SetActive(true);
  577. //}
  578. public void CreateNieLianImg(int parentid, bool ziDingYi, bool isColor)
  579. {
  580. GameObject _objPar = nieLianView.transform.GetChild(2).GetChild(0).gameObject;
  581. RemoveAllChildren(_objPar);
  582. //等有捏脸表时改为捏脸
  583. IDataTable<DRCustomFace> _data = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  584. _facedata = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  585. int cengji = ziDingYi ? 0 : 1;
  586. if (ziDingYi)
  587. {
  588. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  589. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  590. //_obj.transform.SetParent(_objPar.transform);
  591. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  592. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  593. //_uICustomBtn.id =parentid;
  594. //_uICustomBtn.eCustomStyple = eCustomStyple;
  595. //_obj.SetActive(true);
  596. }
  597. if (isColor)
  598. {
  599. CreateColFun(parentid, _objPar,colItem);
  600. }
  601. DRCustomFace[] dRCustomBodies = _facedata.GetAllDataRows();
  602. for (int i = 0; i < dRCustomBodies.Length; i++)
  603. {
  604. Debug.Log(dRCustomBodies[i].Id);
  605. if (dRCustomBodies[i].ParentStyple == parentid&&dRCustomBodies[i].Cengji==cengji)
  606. {
  607. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  608. }
  609. }
  610. ChangeListBotton(_objPar);
  611. }
  612. public void CreateClothImg(int parentid,bool ziDingYi, bool isColor)
  613. {
  614. GameObject _objPar = clothView.transform.GetChild(2).GetChild(0).gameObject;
  615. RemoveAllChildren(_objPar);
  616. //if (parentid == 8)
  617. //{
  618. //}
  619. //等有服装时改为服装
  620. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  621. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  622. int cengji = ziDingYi ? 0 : 1;
  623. if (ziDingYi)
  624. {
  625. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  626. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  627. //_obj.transform.SetParent(_objPar.transform);
  628. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  629. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  630. //_uICustomBtn.id = parentid;
  631. //_uICustomBtn.eCustomStyple = eCustomStyple;
  632. //_obj.SetActive(true);
  633. }
  634. if (isColor)
  635. {
  636. CreateColFun(parentid, _objPar, colItem);
  637. }
  638. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  639. for (int i = 0; i < dRCustomBodies.Length; i++)
  640. {
  641. Debug.Log(dRCustomBodies[i].Id);
  642. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  643. {
  644. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  645. }
  646. }
  647. ChangeListBotton(_objPar);
  648. }
  649. public void CreateOrnamentImg(int parentid, bool ziDingYi, bool isColor)
  650. {
  651. GameObject _objPar = ornamentsView.transform.GetChild(2).GetChild(0).gameObject;
  652. RemoveAllChildren(_objPar);
  653. //if (parentid == 8)
  654. //{
  655. //}
  656. //等有服装时改为服装
  657. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  658. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  659. int cengji = ziDingYi ? 0 : 1;
  660. //if (ziDingYi)
  661. //{
  662. // CreateZDYFun(parentid, _objPar, ziDingYiBtn);
  663. // //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  664. // //_obj.transform.SetParent(_objPar.transform);
  665. // //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  666. // //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  667. // //_uICustomBtn.id = parentid;
  668. // //_uICustomBtn.eCustomStyple = eCustomStyple;
  669. // //_obj.SetActive(true);
  670. //}
  671. //if (isColor)
  672. //{
  673. // CreateColFun(parentid, _objPar, colItem);
  674. //}
  675. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  676. for (int i = 0; i < dRCustomBodies.Length; i++)
  677. {
  678. Debug.Log(dRCustomBodies[i].Id);
  679. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  680. {
  681. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  682. }
  683. }
  684. ChangeListBotton(_objPar);
  685. }
  686. private void CreateZDYFun(int parentid,GameObject _objPar,GameObject _clone)
  687. {
  688. GameObject _obj = GameObject.Instantiate(_clone);
  689. _obj.transform.SetParent(_objPar.transform);
  690. UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  691. ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  692. }
  693. private void CreateColFun(int parentid, GameObject _objPar, GameObject _clone)
  694. {
  695. GameObject _obj = GameObject.Instantiate(_clone);
  696. _obj.transform.SetParent(_objPar.transform);
  697. UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  698. ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  699. nowChooseColorObj = _obj;
  700. }
  701. //private void CreateColorFun(int parentid, GameObject _objPar, GameObject _clone)
  702. //{
  703. // GameObject _obj = GameObject.Instantiate(_clone);
  704. // _obj.transform.SetParent(_objPar.transform);
  705. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  706. // ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  707. //}
  708. public void ChangeUICustom(UICustomBtn uICustomBtn,int id, ECustomStyple eCustomStyple)
  709. {
  710. uICustomBtn.id = id;
  711. uICustomBtn.eCustomStyple = eCustomStyple;
  712. uICustomBtn.gameObject.SetActive(true);
  713. }
  714. public void CreateBodyImg(int parentid,bool ziDingYi, bool isColor) {
  715. GameObject _objPar = bodyView.transform.GetChild(2).GetChild(0).gameObject;
  716. RemoveAllChildren(_objPar);
  717. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  718. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  719. int cengji = ziDingYi ?0:1;
  720. if (ziDingYi)
  721. {
  722. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  723. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  724. //_obj.transform.SetParent(_objPar.transform);
  725. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  726. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  727. //_uICustomBtn.id = parentid;
  728. //_uICustomBtn.eCustomStyple = eCustomStyple;
  729. //_obj.SetActive(true);
  730. }
  731. if (isColor)
  732. {
  733. CreateColFun(parentid, _objPar, colItem);
  734. }
  735. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  736. for (int i = 0; i < dRCustomBodies.Length; i++)
  737. {
  738. Debug.Log(dRCustomBodies[i].Id);
  739. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  740. {
  741. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  742. }
  743. }
  744. ChangeListBotton(_objPar);
  745. }
  746. /// <summary>
  747. /// 改变列表长短
  748. /// </summary>
  749. public void ChangeListBotton(GameObject _obj) {
  750. //Debug.Log("改变列表"+ _obj.transform.childCount+"");
  751. float _x = _obj.GetComponent<RectTransform>().offsetMin.x;
  752. int _childNum = _obj.transform.childCount;
  753. float _y = _childNum > 7 ? -240 * (_childNum - 7) : 0;
  754. _obj.GetComponent<RectTransform>().offsetMax = new Vector2(_x, 0);
  755. _obj.GetComponent<RectTransform>().offsetMin = new Vector2(_x, _y);
  756. }
  757. //public void OrnamentListOpen()
  758. //{
  759. // HistoryAdd(ECustomStyple.Ornament+"");
  760. //}
  761. //private IEnumerator Tween(Action _action) {
  762. // for (int i = 0; i < 100; i++)
  763. // {
  764. // float _value = i / 100;
  765. // float _right=Mathf.Lerp(tween_rightMax, tween_rightMin, _value);
  766. // float _left= Mathf.Lerp(tween_leftMix, tween_rightMax, _value);
  767. // clothView.GetComponent<RectTransform>().SetPositionX(_right);
  768. // toolView.GetComponent<RectTransform>().SetPositionX(_right);
  769. // bodyView.GetComponent<RectTransform>().SetPositionX(_right);
  770. // nieLianView.GetComponent<RectTransform>().SetPositionX(_right);
  771. // baseView.GetComponent<RectTransform>().SetPositionX(_left);
  772. // }
  773. // yield return null;
  774. //}
  775. protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
  776. {
  777. base.OnUpdate(elapseSeconds, realElapseSeconds);
  778. }
  779. //private void CreateNieLianFun(object[] _objects) {
  780. // ENieLianStyple _eNieLianStyple = (ENieLianStyple)int.Parse(_objects[1].ToString());
  781. // switch (_eNieLianStyple)
  782. // {
  783. // case ENieLianStyple.faxing:
  784. // break;
  785. // case ENieLianStyple.lianxing:
  786. // break;
  787. // case ENieLianStyple.yankuang:
  788. // break;
  789. // case ENieLianStyple.tongkong:
  790. // break;
  791. // case ENieLianStyple.meimao:
  792. // break;
  793. // case ENieLianStyple.bizi:
  794. // break;
  795. // case ENieLianStyple.erduo:
  796. // break;
  797. // case ENieLianStyple.zuiba:
  798. // break;
  799. // case ENieLianStyple.fuse:
  800. // break;
  801. // }
  802. // //switch()
  803. //}
  804. private void CreateButtonFun(string path,string _name, GameObject _parent,int _id,int buttonstyple,ECustomStyple eCustomStyple,int _isactive) {
  805. //Debug.Log(path);
  806. // Debug.Log(_parent);
  807. path = "CustomRole/" + path;
  808. Debug.Log("图片名称" + _name);
  809. GameEntry.Resource.LoadAsset(AssetUtility.GetUISpriteAsset(path), new LoadAssetCallbacks(
  810. (assetName, asset, duration, userData) =>
  811. {
  812. // Debug.Log(path);
  813. // Debug.Log(_parent);
  814. Texture2D tex = (Texture2D)asset;
  815. var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
  816. GameObject _obj = GameObject.Instantiate(buttonItem);
  817. Image _objImg = _obj.transform.GetComponent<Image>();
  818. _obj.SetActive(true);
  819. _objImg.sprite = sprite;
  820. _obj.name = _name+"";
  821. _obj.transform.SetParent(_parent.transform);
  822. if (_isactive != 1)
  823. {
  824. _obj.SetActive(false);
  825. }
  826. UICustomBtn uICustomBtn = _obj.GetComponent<UICustomBtn>();
  827. uICustomBtn.id = _id;
  828. uICustomBtn.eButtonStyple = (EButtonStyple)buttonstyple;
  829. uICustomBtn.eCustomStyple = eCustomStyple;
  830. uICustomBtn.isCreate = false;
  831. //uICustomBtn.part = _part;
  832. //GameObject
  833. //img.sprite = sprite;
  834. //if (nativeSize)
  835. //{
  836. // img.SetNativeSize();
  837. //}
  838. ChangeListBotton(_parent);
  839. }));
  840. }
  841. //public void NieLian() {
  842. //}
  843. public void ClickFaceChangeBtn()
  844. {
  845. GameEntry.Event.Fire(this, CustomRoleFaceEventArgs.Create(EditableFacePart.eye, new Vector3(1, 0, 0)));
  846. }
  847. public void ClickResetBtn()
  848. {
  849. CustomManager.Instance.ResetRole();
  850. }
  851. }
  852. public enum ECustomStyple
  853. {
  854. None,
  855. NieLian,
  856. Body,
  857. Cloth,
  858. Ornament,
  859. }
  860. public enum EButtonStyple
  861. {
  862. Button,
  863. Scroll,
  864. TiaoSe,
  865. NorButton,
  866. Back
  867. }
  868. public enum ENieLianStyple {
  869. None,
  870. faxing,
  871. lianxing,
  872. yankuang,
  873. tongkong,
  874. meimao,
  875. bizi,
  876. erduo,
  877. zuiba,
  878. fuse
  879. }
  880. public enum EButtonShunXu {
  881. None,
  882. First,
  883. Second,
  884. Third
  885. }
  886. public enum ETSStyple {
  887. None,
  888. ViewOpen,
  889. Close,
  890. Sure,
  891. Open,
  892. Button
  893. }
  894. }