UICustom.cs 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  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 (eCustomStyple == ECustomStyple.Ornament)
  389. {
  390. BackView_Extra(ornamentsView, true);
  391. return;
  392. }
  393. if (_strArrary[0] == "Color")
  394. {
  395. colorView.SetActive(false);
  396. rightView.SetActive(true);
  397. }
  398. else if (_strArrary[0] == "ziDingyi")
  399. {
  400. scrollbar.gameObject.SetActive(false);
  401. int _chooseId = int.Parse(_strArrary[2]);
  402. hasColorChoose = int.Parse(_strArrary[1]) == 1 ? true : false;
  403. ClickBtnFun(eCustomStyple, _chooseId, true,hasColorChoose);
  404. }
  405. else
  406. {
  407. Debug.Log("缺少当前情况需要添加>>>>");
  408. }
  409. //toolView.SetActive(true);
  410. //bodyView.SetActive(false);
  411. //nieLianView.SetActive(false);
  412. //clothView.SetActive(false);
  413. }
  414. public void PickOnButton(GameObject _obj,int _id) {
  415. if (_obj.transform.childCount <= 0)
  416. {
  417. return;
  418. }
  419. GameObject _nowPickOnImg = _obj.transform.GetChild(0).gameObject;
  420. if (nowPickOnImg==null)
  421. {
  422. nowPickOnImg = _nowPickOnImg;
  423. id = _id;
  424. nowPickOnImg.SetActive(true);
  425. }
  426. else
  427. {
  428. if (_id != id)
  429. {
  430. nowPickOnImg.SetActive(false);
  431. id = _id;
  432. nowPickOnImg = _nowPickOnImg;
  433. _nowPickOnImg.SetActive(true);
  434. }
  435. else
  436. {
  437. nowPickOnImg = _nowPickOnImg;
  438. _nowPickOnImg.SetActive(!_nowPickOnImg.activeSelf);
  439. }
  440. }
  441. scrollbar.gameObject.SetActive(nowPickOnImg.activeSelf);
  442. }
  443. /// <summary>
  444. /// 修改滑块
  445. /// </summary>
  446. public void SetValue(int _part,ECustomStyple eCustomStyple)
  447. {
  448. //scrollbar.value = _value;
  449. part = _part;
  450. switch (eCustomStyple)
  451. {
  452. case ECustomStyple.None:
  453. break;
  454. case ECustomStyple.Cloth:
  455. break;
  456. case ECustomStyple.NieLian:
  457. break;
  458. case ECustomStyple.Body:
  459. scrollbar.value = CustomManager.Instance.GetBodyBoneValue(part);
  460. break;
  461. case ECustomStyple.Ornament:
  462. break;
  463. }
  464. }
  465. /// <summary>
  466. /// 获得滑块值
  467. /// </summary>
  468. public float GetValue()
  469. {
  470. return scrollbar.value;
  471. }
  472. /// <summary>
  473. /// 修改颜色
  474. /// </summary>
  475. public void SetColor(int _part, ECustomStyple eCustomStyple)
  476. {
  477. //scrollbar.value = _value;
  478. part = _part;
  479. }
  480. /// <summary>
  481. /// 按钮点击事件
  482. /// </summary>
  483. public void ClickBtnFun(ECustomStyple eCustomStyple,int id,bool zidingyi,bool isColor) {
  484. //if (isTween)
  485. //{
  486. // return;
  487. //}
  488. hasColorChoose = isColor;
  489. whitebg.SetActive(true);
  490. scrollbar.gameObject.SetActive(false);
  491. this.eCustomStyple = eCustomStyple;
  492. //ECustomStyple _eCustomStyple = (ECustomStyple)int.Parse(_objects[0].ToString());
  493. switch (eCustomStyple)
  494. {
  495. case ECustomStyple.None:
  496. break;
  497. case ECustomStyple.NieLian:
  498. XXListShow(nieLianView);
  499. //GameObject _nieLianList = nieLianView.transform.GetChild(0).gameObject;
  500. //_nieLianList.SetActive(false);
  501. //GameObject _nieLianXX = nieLianView.transform.GetChild(2).gameObject;
  502. //_nieLianXX.SetActive(true);
  503. //if (!zidingyi)
  504. //{
  505. // ZiDingYiNeiLian(eCustomStyple, id, _nieLianXX.transform.GetChild(0).gameObject);
  506. // return;
  507. //}
  508. CreateNieLianImg(id, zidingyi,isColor);
  509. break;
  510. case ECustomStyple.Body:
  511. XXListShow(bodyView);
  512. //GameObject _bodyList = bodyView.transform.GetChild(0).gameObject;
  513. //_bodyList.SetActive(false);
  514. //GameObject _bodyListXX =bodyView.transform.GetChild(2).gameObject;
  515. //_bodyListXX.SetActive(true);
  516. //if (!zidingyi)
  517. //{
  518. // ZiDingYiBody(eCustomStyple, id, _bodyListXX.transform.GetChild(0).gameObject);
  519. // return;
  520. //}
  521. CreateBodyImg(id, zidingyi,isColor);
  522. break;
  523. case ECustomStyple.Cloth:
  524. XXListShow(clothView);
  525. //GameObject _clothList = clothView.transform.GetChild(0).gameObject;
  526. //_clothList.SetActive(false);
  527. //GameObject _clothListXX = clothView.transform.GetChild(2).gameObject;
  528. //_clothListXX.SetActive(true);
  529. //if (!zidingyi)
  530. //{
  531. // ZiDingYiCloth(eCustomStyple, id, _clothListXX.transform.GetChild(0).gameObject);
  532. // return;
  533. //}
  534. CreateClothImg(id, zidingyi,isColor);
  535. break;
  536. case ECustomStyple.Ornament:
  537. XXListShow(ornamentsView);
  538. //GameObject _Ornament = ornamentsView.transform.GetChild(0).gameObject;
  539. //_Ornament.SetActive(false);
  540. //GameObject _OrnamentXX = ornamentsView.transform.GetChild(2).gameObject;
  541. //_OrnamentXX.SetActive(true);
  542. break;
  543. }
  544. }
  545. public void XXListShow(GameObject obj)
  546. {
  547. obj.transform.GetChild(0).gameObject.SetActive(false);
  548. obj.transform.GetChild(2).gameObject.SetActive(true);
  549. }
  550. //public Action ActionFun() {
  551. // return null;
  552. //}
  553. public void ModelMove(Vector2 v2)
  554. {
  555. Debug.Log(v2.x);
  556. //CustomManaget.Instance.RotateModel(v2.x);
  557. }
  558. private void RemoveAllChildren(GameObject parent,int _index=0)
  559. {
  560. Transform transform;
  561. for (int i = _index; i < parent.transform.childCount; i++)
  562. {
  563. transform = parent.transform.GetChild(i);
  564. GameObject.Destroy(transform.gameObject);
  565. }
  566. }
  567. //public void ZiDingYiNeiLian(ECustomStyple eCustomStyple, int id,GameObject _objPar) {
  568. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  569. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  570. // _obj.transform.SetParent(_objPar.transform);
  571. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  572. // _uICustomBtn.id = id;
  573. // _uICustomBtn.eCustomStyple = eCustomStyple;
  574. // _obj.SetActive(true);
  575. //}
  576. //public void ZiDingYiBody(ECustomStyple eCustomStyple, int id, GameObject _objPar)
  577. //{
  578. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  579. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  580. // _obj.transform.SetParent(_objPar.transform);
  581. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  582. // _uICustomBtn.id = id;
  583. // _uICustomBtn.eCustomStyple = eCustomStyple;
  584. // _obj.SetActive(true);
  585. //}
  586. //public void ZiDingYiCloth(ECustomStyple eCustomStyple, int id, GameObject _objPar)
  587. //{
  588. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  589. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  590. // _obj.transform.SetParent(_objPar.transform);
  591. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  592. // _uICustomBtn.id = id;
  593. // _uICustomBtn.eCustomStyple = eCustomStyple;
  594. // _obj.SetActive(true);
  595. //}
  596. public void CreateNieLianImg(int parentid, bool ziDingYi, bool isColor)
  597. {
  598. GameObject _objPar = nieLianView.transform.GetChild(2).GetChild(0).gameObject;
  599. RemoveAllChildren(_objPar);
  600. //等有捏脸表时改为捏脸
  601. IDataTable<DRCustomFace> _data = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  602. _facedata = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  603. int cengji = ziDingYi ? 0 : 1;
  604. if (ziDingYi)
  605. {
  606. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  607. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  608. //_obj.transform.SetParent(_objPar.transform);
  609. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  610. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  611. //_uICustomBtn.id =parentid;
  612. //_uICustomBtn.eCustomStyple = eCustomStyple;
  613. //_obj.SetActive(true);
  614. }
  615. if (isColor)
  616. {
  617. CreateColFun(parentid, _objPar,colItem);
  618. }
  619. DRCustomFace[] dRCustomBodies = _facedata.GetAllDataRows();
  620. for (int i = 0; i < dRCustomBodies.Length; i++)
  621. {
  622. Debug.Log(dRCustomBodies[i].Id);
  623. if (dRCustomBodies[i].ParentStyple == parentid&&dRCustomBodies[i].Cengji==cengji)
  624. {
  625. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  626. }
  627. }
  628. ChangeListBotton(_objPar);
  629. }
  630. public void CreateClothImg(int parentid,bool ziDingYi, bool isColor)
  631. {
  632. GameObject _objPar = clothView.transform.GetChild(2).GetChild(0).gameObject;
  633. RemoveAllChildren(_objPar);
  634. //if (parentid == 8)
  635. //{
  636. //}
  637. //等有服装时改为服装
  638. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  639. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  640. int cengji = ziDingYi ? 0 : 1;
  641. if (ziDingYi)
  642. {
  643. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  644. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  645. //_obj.transform.SetParent(_objPar.transform);
  646. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  647. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  648. //_uICustomBtn.id = parentid;
  649. //_uICustomBtn.eCustomStyple = eCustomStyple;
  650. //_obj.SetActive(true);
  651. }
  652. if (isColor)
  653. {
  654. CreateColFun(parentid, _objPar, colItem);
  655. }
  656. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  657. for (int i = 0; i < dRCustomBodies.Length; i++)
  658. {
  659. Debug.Log(dRCustomBodies[i].Id);
  660. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  661. {
  662. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  663. }
  664. }
  665. ChangeListBotton(_objPar);
  666. }
  667. public void CreateOrnamentImg(int parentid, bool ziDingYi, bool isColor)
  668. {
  669. GameObject _objPar = ornamentsView.transform.GetChild(2).GetChild(0).gameObject;
  670. RemoveAllChildren(_objPar);
  671. //if (parentid == 8)
  672. //{
  673. //}
  674. //等有服装时改为服装
  675. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  676. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  677. int cengji = ziDingYi ? 0 : 1;
  678. //if (ziDingYi)
  679. //{
  680. // CreateZDYFun(parentid, _objPar, ziDingYiBtn);
  681. // //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  682. // //_obj.transform.SetParent(_objPar.transform);
  683. // //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  684. // //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  685. // //_uICustomBtn.id = parentid;
  686. // //_uICustomBtn.eCustomStyple = eCustomStyple;
  687. // //_obj.SetActive(true);
  688. //}
  689. //if (isColor)
  690. //{
  691. // CreateColFun(parentid, _objPar, colItem);
  692. //}
  693. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  694. for (int i = 0; i < dRCustomBodies.Length; i++)
  695. {
  696. Debug.Log(dRCustomBodies[i].Id);
  697. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  698. {
  699. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  700. }
  701. }
  702. ChangeListBotton(_objPar);
  703. }
  704. private void CreateZDYFun(int parentid,GameObject _objPar,GameObject _clone)
  705. {
  706. GameObject _obj = GameObject.Instantiate(_clone);
  707. _obj.transform.SetParent(_objPar.transform);
  708. UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  709. ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  710. }
  711. private void CreateColFun(int parentid, GameObject _objPar, GameObject _clone)
  712. {
  713. GameObject _obj = GameObject.Instantiate(_clone);
  714. _obj.transform.SetParent(_objPar.transform);
  715. UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  716. ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  717. nowChooseColorObj = _obj;
  718. }
  719. //private void CreateColorFun(int parentid, GameObject _objPar, GameObject _clone)
  720. //{
  721. // GameObject _obj = GameObject.Instantiate(_clone);
  722. // _obj.transform.SetParent(_objPar.transform);
  723. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  724. // ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  725. //}
  726. public void ChangeUICustom(UICustomBtn uICustomBtn,int id, ECustomStyple eCustomStyple)
  727. {
  728. uICustomBtn.id = id;
  729. uICustomBtn.eCustomStyple = eCustomStyple;
  730. uICustomBtn.gameObject.SetActive(true);
  731. }
  732. public void CreateBodyImg(int parentid,bool ziDingYi, bool isColor) {
  733. GameObject _objPar = bodyView.transform.GetChild(2).GetChild(0).gameObject;
  734. RemoveAllChildren(_objPar);
  735. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  736. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  737. int cengji = ziDingYi ?0:1;
  738. if (ziDingYi)
  739. {
  740. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  741. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  742. //_obj.transform.SetParent(_objPar.transform);
  743. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  744. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  745. //_uICustomBtn.id = parentid;
  746. //_uICustomBtn.eCustomStyple = eCustomStyple;
  747. //_obj.SetActive(true);
  748. }
  749. if (isColor)
  750. {
  751. CreateColFun(parentid, _objPar, colItem);
  752. }
  753. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  754. for (int i = 0; i < dRCustomBodies.Length; i++)
  755. {
  756. Debug.Log(dRCustomBodies[i].Id);
  757. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  758. {
  759. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  760. }
  761. }
  762. ChangeListBotton(_objPar);
  763. }
  764. /// <summary>
  765. /// 改变列表长短
  766. /// </summary>
  767. public void ChangeListBotton(GameObject _obj) {
  768. //Debug.Log("改变列表"+ _obj.transform.childCount+"");
  769. float _x = _obj.GetComponent<RectTransform>().offsetMin.x;
  770. int _childNum = _obj.transform.childCount;
  771. float _y = _childNum > 7 ? -240 * (_childNum - 7) : 0;
  772. _obj.GetComponent<RectTransform>().offsetMax = new Vector2(_x, 0);
  773. _obj.GetComponent<RectTransform>().offsetMin = new Vector2(_x, _y);
  774. }
  775. //public void OrnamentListOpen()
  776. //{
  777. // HistoryAdd(ECustomStyple.Ornament+"");
  778. //}
  779. //private IEnumerator Tween(Action _action) {
  780. // for (int i = 0; i < 100; i++)
  781. // {
  782. // float _value = i / 100;
  783. // float _right=Mathf.Lerp(tween_rightMax, tween_rightMin, _value);
  784. // float _left= Mathf.Lerp(tween_leftMix, tween_rightMax, _value);
  785. // clothView.GetComponent<RectTransform>().SetPositionX(_right);
  786. // toolView.GetComponent<RectTransform>().SetPositionX(_right);
  787. // bodyView.GetComponent<RectTransform>().SetPositionX(_right);
  788. // nieLianView.GetComponent<RectTransform>().SetPositionX(_right);
  789. // baseView.GetComponent<RectTransform>().SetPositionX(_left);
  790. // }
  791. // yield return null;
  792. //}
  793. protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
  794. {
  795. base.OnUpdate(elapseSeconds, realElapseSeconds);
  796. }
  797. //private void CreateNieLianFun(object[] _objects) {
  798. // ENieLianStyple _eNieLianStyple = (ENieLianStyple)int.Parse(_objects[1].ToString());
  799. // switch (_eNieLianStyple)
  800. // {
  801. // case ENieLianStyple.faxing:
  802. // break;
  803. // case ENieLianStyple.lianxing:
  804. // break;
  805. // case ENieLianStyple.yankuang:
  806. // break;
  807. // case ENieLianStyple.tongkong:
  808. // break;
  809. // case ENieLianStyple.meimao:
  810. // break;
  811. // case ENieLianStyple.bizi:
  812. // break;
  813. // case ENieLianStyple.erduo:
  814. // break;
  815. // case ENieLianStyple.zuiba:
  816. // break;
  817. // case ENieLianStyple.fuse:
  818. // break;
  819. // }
  820. // //switch()
  821. //}
  822. private void CreateButtonFun(string path,string _name, GameObject _parent,int _id,int buttonstyple,ECustomStyple eCustomStyple,int _isactive) {
  823. //Debug.Log(path);
  824. // Debug.Log(_parent);
  825. path = "CustomRole/" + path;
  826. Debug.Log("图片名称" + _name);
  827. GameEntry.Resource.LoadAsset(AssetUtility.GetUISpriteAsset(path), new LoadAssetCallbacks(
  828. (assetName, asset, duration, userData) =>
  829. {
  830. // Debug.Log(path);
  831. // Debug.Log(_parent);
  832. Texture2D tex = (Texture2D)asset;
  833. var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
  834. GameObject _obj = GameObject.Instantiate(buttonItem);
  835. Image _objImg = _obj.transform.GetComponent<Image>();
  836. _obj.SetActive(true);
  837. _objImg.sprite = sprite;
  838. _obj.name = _name+"";
  839. _obj.transform.SetParent(_parent.transform);
  840. if (_isactive != 1)
  841. {
  842. _obj.SetActive(false);
  843. }
  844. UICustomBtn uICustomBtn = _obj.GetComponent<UICustomBtn>();
  845. uICustomBtn.id = _id;
  846. uICustomBtn.eButtonStyple = (EButtonStyple)buttonstyple;
  847. uICustomBtn.eCustomStyple = eCustomStyple;
  848. uICustomBtn.isCreate = false;
  849. //uICustomBtn.part = _part;
  850. //GameObject
  851. //img.sprite = sprite;
  852. //if (nativeSize)
  853. //{
  854. // img.SetNativeSize();
  855. //}
  856. ChangeListBotton(_parent);
  857. }));
  858. }
  859. //public void NieLian() {
  860. //}
  861. public void ClickFaceChangeBtn()
  862. {
  863. GameEntry.Event.Fire(this, CustomRoleFaceEventArgs.Create(EditableFacePart.eye, new Vector3(1, 0, 0)));
  864. }
  865. public void ClickResetBtn()
  866. {
  867. CustomManager.Instance.ResetRole();
  868. }
  869. }
  870. public enum ECustomStyple
  871. {
  872. None,
  873. NieLian,
  874. Body,
  875. Cloth,
  876. Ornament,
  877. }
  878. public enum EButtonStyple
  879. {
  880. Button,
  881. Scroll,
  882. TiaoSe,
  883. NorButton,
  884. Back
  885. }
  886. public enum ENieLianStyple {
  887. None,
  888. faxing,
  889. lianxing,
  890. yankuang,
  891. tongkong,
  892. meimao,
  893. bizi,
  894. erduo,
  895. zuiba,
  896. fuse
  897. }
  898. public enum EButtonShunXu {
  899. None,
  900. First,
  901. Second,
  902. Third
  903. }
  904. public enum ETSStyple {
  905. None,
  906. ViewOpen,
  907. Close,
  908. Sure,
  909. Open,
  910. Button
  911. }
  912. }