UICustom.cs 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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(eCustomStyple,part, new Vector3(scrollbar.value, 0, 0)));
  245. // GameEntry.Event.Fire(this, CustomRoleBodyEventArgs.Create(part, new Vector3(scrollbar.value, 0, 0)));
  246. }
  247. public void BackBtn_Fun()
  248. {
  249. if (histroyextra)
  250. {
  251. BackExtraFun();
  252. histroyextra = false;
  253. return;
  254. }
  255. int index = this.histroy.Count;
  256. index = eCustomStyple == ECustomStyple.Ornament ? index - 1 : index;
  257. switch (this.histroy.Count)
  258. {
  259. case 0:
  260. Debug.Log("返回上一层");
  261. //GameEntry.UI.CloseUIForm(104);
  262. GameEntry.UI.OpenUIForm(UIFormId.GameMenuForm);
  263. // Close();
  264. break;
  265. case 1:
  266. Debug.Log("返回选择捏脸/身体/服装");
  267. histroy.RemoveAt(histroy.Count - 1);
  268. Back_OneFun();
  269. break;
  270. case 2:
  271. Debug.Log("进入选择界面");
  272. scrollbar.gameObject.SetActive(false);
  273. histroy.RemoveAt(histroy.Count - 1);
  274. Back_TwoFun(true);
  275. break;
  276. default:
  277. Debug.Log("进入自定义或颜色");
  278. // histroy.RemoveAt(histroy.Count - 1);
  279. Back_ThreeFun();
  280. histroy.RemoveAt(histroy.Count - 1);
  281. break;
  282. }
  283. }
  284. public void BackBtnFun()
  285. {
  286. if (isTween)
  287. {
  288. return;
  289. }
  290. //if (histroy.Count == 0)
  291. //{
  292. // GameEntry.UI.OpenUIForm(UIFormId.GameMenuForm);
  293. // Close();
  294. // return;
  295. //}
  296. isTween = true;
  297. leftView.transform.DOLocalMoveX(tween_leftMin, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  298. //whitebg.SetActive(bg);
  299. BackBtn_Fun();
  300. leftView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  301. isTween = false;
  302. Debug.Log("222");
  303. });
  304. });
  305. Debug.Log("333");
  306. rightView.transform.DOLocalMoveX(tween_rightMax, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  307. rightView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
  308. });
  309. });
  310. }
  311. /// <summary>
  312. /// 返回的方法一
  313. /// </summary>
  314. void Back_OneFun() {
  315. ViewSetFalse();
  316. toolView.SetActive(true);
  317. //toolView.SetActive(true);
  318. //bodyView.SetActive(false);
  319. //nieLianView.SetActive(false);
  320. //clothView.SetActive(false);
  321. }
  322. /// <summary>
  323. /// 返回的方法extra
  324. /// </summary>
  325. void BackExtraFun()
  326. {
  327. rightView.SetActive(true);
  328. scrollbar.gameObject.SetActive(false);
  329. }
  330. /// <summary>
  331. /// 面板全部隐藏
  332. /// </summary>
  333. void ViewSetFalse()
  334. {
  335. toolView.SetActive(false);
  336. bodyView.SetActive(false);
  337. nieLianView.SetActive(false);
  338. clothView.SetActive(false);
  339. }
  340. void BackView_Extra(GameObject _obj,bool _bo) {
  341. ViewSetFalse();
  342. _obj.SetActive(_bo);
  343. ViewSetChildTrue(_obj,_bo);
  344. }
  345. void ViewSetChildTrue(GameObject _obj,bool _bo)
  346. {
  347. _obj.transform.GetChild(0).gameObject.SetActive(_bo);
  348. _obj.transform.GetChild(0).gameObject.SetActive(_bo);
  349. _obj.transform.GetChild(2).gameObject.SetActive(!_bo);
  350. }
  351. /// <summary>
  352. /// 返回的方法二
  353. /// </summary>
  354. void Back_TwoFun(bool _bo)
  355. {
  356. // int _choose = int.Parse(histroy[1]);
  357. // switch ((ECustomStyple)_choose)
  358. whitebg.SetActive(false);
  359. switch(eCustomStyple)
  360. {
  361. case ECustomStyple.Body:
  362. BackView_Extra(bodyView,_bo);
  363. break;
  364. case ECustomStyple.Cloth:
  365. BackView_Extra(clothView, _bo);
  366. break;
  367. case ECustomStyple.None:
  368. break;
  369. case ECustomStyple.NieLian:
  370. BackView_Extra(nieLianView, _bo);
  371. break;
  372. case ECustomStyple.Ornament:
  373. // BackView_Extra(ornamentsView, _bo);
  374. BackView_Extra(clothView, _bo);
  375. ornamentsView.SetActive(false);
  376. break;
  377. }
  378. //toolView.SetActive(true);
  379. //bodyView.SetActive(false);
  380. //nieLianView.SetActive(false);
  381. //clothView.SetActive(false);
  382. }
  383. /// <summary>
  384. /// 返回的方法三
  385. /// </summary>
  386. void Back_ThreeFun()
  387. {
  388. string[] _strArrary = histroy[histroy.Count - 1].Split(',');
  389. if (_strArrary[0] == "Color")
  390. {
  391. colorView.SetActive(false);
  392. rightView.SetActive(true);
  393. }
  394. else if (_strArrary[0] == "ziDingyi")
  395. {
  396. scrollbar.gameObject.SetActive(false);
  397. int _chooseId = int.Parse(_strArrary[2]);
  398. hasColorChoose = int.Parse(_strArrary[1]) == 1 ? true : false;
  399. ClickBtnFun(eCustomStyple, _chooseId, true,hasColorChoose);
  400. }
  401. else
  402. {
  403. Debug.Log("缺少当前情况需要添加>>>>");
  404. }
  405. //toolView.SetActive(true);
  406. //bodyView.SetActive(false);
  407. //nieLianView.SetActive(false);
  408. //clothView.SetActive(false);
  409. }
  410. public void PickOnButton(GameObject _obj,int _id) {
  411. if (_obj.transform.childCount <= 0)
  412. {
  413. return;
  414. }
  415. GameObject _nowPickOnImg = _obj.transform.GetChild(0).gameObject;
  416. if (nowPickOnImg==null)
  417. {
  418. nowPickOnImg = _nowPickOnImg;
  419. id = _id;
  420. nowPickOnImg.SetActive(true);
  421. }
  422. else
  423. {
  424. if (_id != id)
  425. {
  426. nowPickOnImg.SetActive(false);
  427. id = _id;
  428. nowPickOnImg = _nowPickOnImg;
  429. _nowPickOnImg.SetActive(true);
  430. }
  431. else
  432. {
  433. nowPickOnImg = _nowPickOnImg;
  434. _nowPickOnImg.SetActive(!_nowPickOnImg.activeSelf);
  435. }
  436. }
  437. scrollbar.gameObject.SetActive(nowPickOnImg.activeSelf);
  438. }
  439. /// <summary>
  440. /// 修改滑块
  441. /// </summary>
  442. public void SetValue(int _part,ECustomStyple eCustomStyple)
  443. {
  444. //scrollbar.value = _value;
  445. part = _part;
  446. Debug.Log(eCustomStyple.ToString());
  447. scrollbar.value = CustomManager.Instance.GetBodyBoneValue(eCustomStyple,part);
  448. }
  449. /// <summary>
  450. /// 获得滑块值
  451. /// </summary>
  452. public float GetValue()
  453. {
  454. return scrollbar.value;
  455. }
  456. /// <summary>
  457. /// 修改颜色
  458. /// </summary>
  459. public void SetColor(int _part, ECustomStyple eCustomStyple)
  460. {
  461. //scrollbar.value = _value;
  462. part = _part;
  463. }
  464. /// <summary>
  465. /// 按钮点击事件
  466. /// </summary>
  467. public void ClickBtnFun(ECustomStyple eCustomStyple,int id,bool zidingyi,bool isColor) {
  468. //if (isTween)
  469. //{
  470. // return;
  471. //}
  472. hasColorChoose = isColor;
  473. whitebg.SetActive(true);
  474. scrollbar.gameObject.SetActive(false);
  475. this.eCustomStyple = eCustomStyple;
  476. //ECustomStyple _eCustomStyple = (ECustomStyple)int.Parse(_objects[0].ToString());
  477. switch (eCustomStyple)
  478. {
  479. case ECustomStyple.None:
  480. break;
  481. case ECustomStyple.NieLian:
  482. XXListShow(nieLianView);
  483. //GameObject _nieLianList = nieLianView.transform.GetChild(0).gameObject;
  484. //_nieLianList.SetActive(false);
  485. //GameObject _nieLianXX = nieLianView.transform.GetChild(2).gameObject;
  486. //_nieLianXX.SetActive(true);
  487. //if (!zidingyi)
  488. //{
  489. // ZiDingYiNeiLian(eCustomStyple, id, _nieLianXX.transform.GetChild(0).gameObject);
  490. // return;
  491. //}
  492. eCustomStyple = ECustomStyple.Cloth;
  493. CreateNieLianImg(id, zidingyi,isColor);
  494. break;
  495. case ECustomStyple.Body:
  496. XXListShow(bodyView);
  497. //GameObject _bodyList = bodyView.transform.GetChild(0).gameObject;
  498. //_bodyList.SetActive(false);
  499. //GameObject _bodyListXX =bodyView.transform.GetChild(2).gameObject;
  500. //_bodyListXX.SetActive(true);
  501. //if (!zidingyi)
  502. //{
  503. // ZiDingYiBody(eCustomStyple, id, _bodyListXX.transform.GetChild(0).gameObject);
  504. // return;
  505. //}
  506. CreateBodyImg(id, zidingyi,isColor);
  507. break;
  508. case ECustomStyple.Cloth:
  509. XXListShow(clothView);
  510. //GameObject _clothList = clothView.transform.GetChild(0).gameObject;
  511. //_clothList.SetActive(false);
  512. //GameObject _clothListXX = clothView.transform.GetChild(2).gameObject;
  513. //_clothListXX.SetActive(true);
  514. //if (!zidingyi)
  515. //{
  516. // ZiDingYiCloth(eCustomStyple, id, _clothListXX.transform.GetChild(0).gameObject);
  517. // return;
  518. //}
  519. CreateClothImg(id, zidingyi,isColor);
  520. break;
  521. case ECustomStyple.Ornament:
  522. XXListShow(ornamentsView);
  523. //GameObject _Ornament = ornamentsView.transform.GetChild(0).gameObject;
  524. //_Ornament.SetActive(false);
  525. //GameObject _OrnamentXX = ornamentsView.transform.GetChild(2).gameObject;
  526. //_OrnamentXX.SetActive(true);
  527. break;
  528. }
  529. }
  530. public void XXListShow(GameObject obj)
  531. {
  532. obj.transform.GetChild(0).gameObject.SetActive(false);
  533. obj.transform.GetChild(2).gameObject.SetActive(true);
  534. }
  535. //public Action ActionFun() {
  536. // return null;
  537. //}
  538. public void ModelMove(Vector2 v2)
  539. {
  540. Debug.Log(v2.x);
  541. //CustomManaget.Instance.RotateModel(v2.x);
  542. }
  543. private void RemoveAllChildren(GameObject parent,int _index=0)
  544. {
  545. Transform transform;
  546. for (int i = _index; i < parent.transform.childCount; i++)
  547. {
  548. transform = parent.transform.GetChild(i);
  549. GameObject.Destroy(transform.gameObject);
  550. }
  551. }
  552. //public void ZiDingYiNeiLian(ECustomStyple eCustomStyple, int id,GameObject _objPar) {
  553. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  554. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  555. // _obj.transform.SetParent(_objPar.transform);
  556. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  557. // _uICustomBtn.id = id;
  558. // _uICustomBtn.eCustomStyple = eCustomStyple;
  559. // _obj.SetActive(true);
  560. //}
  561. //public void ZiDingYiBody(ECustomStyple eCustomStyple, int id, GameObject _objPar)
  562. //{
  563. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  564. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  565. // _obj.transform.SetParent(_objPar.transform);
  566. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  567. // _uICustomBtn.id = id;
  568. // _uICustomBtn.eCustomStyple = eCustomStyple;
  569. // _obj.SetActive(true);
  570. //}
  571. //public void ZiDingYiCloth(ECustomStyple eCustomStyple, int id, GameObject _objPar)
  572. //{
  573. // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
  574. // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  575. // _obj.transform.SetParent(_objPar.transform);
  576. // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  577. // _uICustomBtn.id = id;
  578. // _uICustomBtn.eCustomStyple = eCustomStyple;
  579. // _obj.SetActive(true);
  580. //}
  581. public void CreateNieLianImg(int parentid, bool ziDingYi, bool isColor)
  582. {
  583. GameObject _objPar = nieLianView.transform.GetChild(2).GetChild(0).gameObject;
  584. RemoveAllChildren(_objPar);
  585. //等有捏脸表时改为捏脸
  586. IDataTable<DRCustomFace> _data = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  587. _facedata = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  588. int cengji = ziDingYi ? 0 : 1;
  589. if (ziDingYi)
  590. {
  591. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  592. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  593. //_obj.transform.SetParent(_objPar.transform);
  594. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  595. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  596. //_uICustomBtn.id =parentid;
  597. //_uICustomBtn.eCustomStyple = eCustomStyple;
  598. //_obj.SetActive(true);
  599. }
  600. if (isColor)
  601. {
  602. CreateColFun(parentid, _objPar,colItem);
  603. }
  604. DRCustomFace[] dRCustomBodies = _facedata.GetAllDataRows();
  605. for (int i = 0; i < dRCustomBodies.Length; i++)
  606. {
  607. Debug.Log(dRCustomBodies[i].Id);
  608. if (dRCustomBodies[i].ParentStyple == parentid&&dRCustomBodies[i].Cengji==cengji&& dRCustomBodies[i].IsActive == 1)
  609. {
  610. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.NieLian, dRCustomBodies[i].IsActive);
  611. }
  612. }
  613. ChangeListBotton(_objPar);
  614. }
  615. public void CreateClothImg(int parentid,bool ziDingYi, bool isColor)
  616. {
  617. GameObject _objPar = clothView.transform.GetChild(2).GetChild(0).gameObject;
  618. RemoveAllChildren(_objPar);
  619. //if (parentid == 8)
  620. //{
  621. //}
  622. //等有服装时改为服装
  623. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  624. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  625. int cengji = ziDingYi ? 0 : 1;
  626. if (ziDingYi)
  627. {
  628. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  629. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  630. //_obj.transform.SetParent(_objPar.transform);
  631. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  632. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  633. //_uICustomBtn.id = parentid;
  634. //_uICustomBtn.eCustomStyple = eCustomStyple;
  635. //_obj.SetActive(true);
  636. }
  637. if (isColor)
  638. {
  639. CreateColFun(parentid, _objPar, colItem);
  640. }
  641. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  642. for (int i = 0; i < dRCustomBodies.Length; i++)
  643. {
  644. Debug.Log(dRCustomBodies[i].Id);
  645. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji&& dRCustomBodies[i].IsActive==1)
  646. {
  647. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Cloth, dRCustomBodies[i].IsActive);
  648. }
  649. }
  650. ChangeListBotton(_objPar);
  651. }
  652. public void CreateOrnamentImg(int parentid, bool ziDingYi, bool isColor)
  653. {
  654. GameObject _objPar = ornamentsView.transform.GetChild(2).GetChild(0).gameObject;
  655. RemoveAllChildren(_objPar);
  656. //if (parentid == 8)
  657. //{
  658. //}
  659. //等有服装时改为服装
  660. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  661. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  662. int cengji = ziDingYi ? 0 : 1;
  663. //if (ziDingYi)
  664. //{
  665. // CreateZDYFun(parentid, _objPar, ziDingYiBtn);
  666. // //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  667. // //_obj.transform.SetParent(_objPar.transform);
  668. // //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  669. // //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  670. // //_uICustomBtn.id = parentid;
  671. // //_uICustomBtn.eCustomStyple = eCustomStyple;
  672. // //_obj.SetActive(true);
  673. //}
  674. //if (isColor)
  675. //{
  676. // CreateColFun(parentid, _objPar, colItem);
  677. //}
  678. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  679. for (int i = 0; i < dRCustomBodies.Length; i++)
  680. {
  681. Debug.Log(dRCustomBodies[i].Id);
  682. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  683. {
  684. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Ornament, dRCustomBodies[i].IsActive);
  685. }
  686. }
  687. ChangeListBotton(_objPar);
  688. }
  689. private void CreateZDYFun(int parentid,GameObject _objPar,GameObject _clone)
  690. {
  691. GameObject _obj = GameObject.Instantiate(_clone);
  692. _obj.transform.SetParent(_objPar.transform);
  693. UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  694. ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  695. }
  696. private void CreateColFun(int parentid, GameObject _objPar, GameObject _clone)
  697. {
  698. GameObject _obj = GameObject.Instantiate(_clone);
  699. _obj.transform.SetParent(_objPar.transform);
  700. UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  701. ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  702. nowChooseColorObj = _obj;
  703. }
  704. //private void CreateColorFun(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. public void ChangeUICustom(UICustomBtn uICustomBtn,int id, ECustomStyple eCustomStyple)
  712. {
  713. uICustomBtn.id = id;
  714. uICustomBtn.eCustomStyple = eCustomStyple;
  715. uICustomBtn.gameObject.SetActive(true);
  716. }
  717. public void CreateBodyImg(int parentid,bool ziDingYi, bool isColor) {
  718. GameObject _objPar = bodyView.transform.GetChild(2).GetChild(0).gameObject;
  719. RemoveAllChildren(_objPar);
  720. IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  721. _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  722. int cengji = ziDingYi ?0:1;
  723. if (ziDingYi)
  724. {
  725. CreateZDYFun(parentid, _objPar,ziDingYiBtn);
  726. //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
  727. //_obj.transform.SetParent(_objPar.transform);
  728. //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
  729. //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
  730. //_uICustomBtn.id = parentid;
  731. //_uICustomBtn.eCustomStyple = eCustomStyple;
  732. //_obj.SetActive(true);
  733. }
  734. if (isColor)
  735. {
  736. CreateColFun(parentid, _objPar, colItem);
  737. }
  738. DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
  739. for (int i = 0; i < dRCustomBodies.Length; i++)
  740. {
  741. Debug.Log(dRCustomBodies[i].Id);
  742. if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
  743. {
  744. CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
  745. }
  746. }
  747. ChangeListBotton(_objPar);
  748. }
  749. /// <summary>
  750. /// 改变列表长短
  751. /// </summary>
  752. public void ChangeListBotton(GameObject _obj) {
  753. //Debug.Log("改变列表"+ _obj.transform.childCount+"");
  754. float _x = _obj.GetComponent<RectTransform>().offsetMin.x;
  755. int _childNum = _obj.transform.childCount;
  756. float _y = _childNum > 7 ? -240 * (_childNum - 7) : 0;
  757. _obj.GetComponent<RectTransform>().offsetMax = new Vector2(_x, 0);
  758. _obj.GetComponent<RectTransform>().offsetMin = new Vector2(_x, _y);
  759. }
  760. //public void OrnamentListOpen()
  761. //{
  762. // HistoryAdd(ECustomStyple.Ornament+"");
  763. //}
  764. //private IEnumerator Tween(Action _action) {
  765. // for (int i = 0; i < 100; i++)
  766. // {
  767. // float _value = i / 100;
  768. // float _right=Mathf.Lerp(tween_rightMax, tween_rightMin, _value);
  769. // float _left= Mathf.Lerp(tween_leftMix, tween_rightMax, _value);
  770. // clothView.GetComponent<RectTransform>().SetPositionX(_right);
  771. // toolView.GetComponent<RectTransform>().SetPositionX(_right);
  772. // bodyView.GetComponent<RectTransform>().SetPositionX(_right);
  773. // nieLianView.GetComponent<RectTransform>().SetPositionX(_right);
  774. // baseView.GetComponent<RectTransform>().SetPositionX(_left);
  775. // }
  776. // yield return null;
  777. //}
  778. protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
  779. {
  780. base.OnUpdate(elapseSeconds, realElapseSeconds);
  781. }
  782. //private void CreateNieLianFun(object[] _objects) {
  783. // ENieLianStyple _eNieLianStyple = (ENieLianStyple)int.Parse(_objects[1].ToString());
  784. // switch (_eNieLianStyple)
  785. // {
  786. // case ENieLianStyple.faxing:
  787. // break;
  788. // case ENieLianStyple.lianxing:
  789. // break;
  790. // case ENieLianStyple.yankuang:
  791. // break;
  792. // case ENieLianStyple.tongkong:
  793. // break;
  794. // case ENieLianStyple.meimao:
  795. // break;
  796. // case ENieLianStyple.bizi:
  797. // break;
  798. // case ENieLianStyple.erduo:
  799. // break;
  800. // case ENieLianStyple.zuiba:
  801. // break;
  802. // case ENieLianStyple.fuse:
  803. // break;
  804. // }
  805. // //switch()
  806. //}
  807. private void CreateButtonFun(string path,string _name, GameObject _parent,int _id,int buttonstyple,ECustomStyple eCustomStyple,int _isactive) {
  808. //Debug.Log(path);
  809. // Debug.Log(_parent);
  810. path = "CustomRole/" + path;
  811. Debug.Log("图片名称" + _name);
  812. GameEntry.Resource.LoadAsset(AssetUtility.GetUISpriteAsset(path), new LoadAssetCallbacks(
  813. (assetName, asset, duration, userData) =>
  814. {
  815. // Debug.Log(path);
  816. // Debug.Log(_parent);
  817. Texture2D tex = (Texture2D)asset;
  818. var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
  819. GameObject _obj = GameObject.Instantiate(buttonItem);
  820. Image _objImg = _obj.transform.GetComponent<Image>();
  821. _obj.SetActive(true);
  822. _objImg.sprite = sprite;
  823. _obj.name = _name+"";
  824. _obj.transform.SetParent(_parent.transform);
  825. if (_isactive != 1)
  826. {
  827. _obj.SetActive(false);
  828. }
  829. UICustomBtn uICustomBtn = _obj.GetComponent<UICustomBtn>();
  830. uICustomBtn.id = _id;
  831. uICustomBtn.eButtonStyple = (EButtonStyple)buttonstyple;
  832. uICustomBtn.eCustomStyple = eCustomStyple;
  833. uICustomBtn.isCreate = false;
  834. //uICustomBtn.part = _part;
  835. //GameObject
  836. //img.sprite = sprite;
  837. //if (nativeSize)
  838. //{
  839. // img.SetNativeSize();
  840. //}
  841. ChangeListBotton(_parent);
  842. }));
  843. }
  844. //public void NieLian() {
  845. //}
  846. public void ClickFaceChangeBtn()
  847. {
  848. GameEntry.Event.Fire(this, CustomRoleFaceEventArgs.Create(EditableFacePart.eye, new Vector3(1, 0, 0)));
  849. }
  850. public void ClickResetBtn()
  851. {
  852. CustomManager.Instance.ResetRole();
  853. }
  854. }
  855. public enum ECustomStyple
  856. {
  857. None,
  858. NieLian,
  859. Body,
  860. Cloth,
  861. Ornament,
  862. }
  863. public enum EButtonStyple
  864. {
  865. Button,
  866. Scroll,
  867. TiaoSe,
  868. NorButton,
  869. Back
  870. }
  871. public enum ENieLianStyple {
  872. None,
  873. faxing,
  874. lianxing,
  875. yankuang,
  876. tongkong,
  877. meimao,
  878. bizi,
  879. erduo,
  880. zuiba,
  881. fuse
  882. }
  883. public enum EButtonShunXu {
  884. None,
  885. First,
  886. Second,
  887. Third
  888. }
  889. public enum ETSStyple {
  890. None,
  891. ViewOpen,
  892. Close,
  893. Sure,
  894. Open,
  895. Button
  896. }
  897. }