UICustom.cs 23 KB

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