UICustom.cs 36 KB

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