1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityGameFramework.Runtime;
- using GameFramework;
- using GameFramework.DataTable;
- using GameFramework.Sound;
- using GameFramework.Download;
- using GameFramework.FileSystem;
- using GameFramework.ObjectPool;
- using GameFramework.Resource;
- using System;
- using DG.Tweening;
- namespace MetaClient
- {
- public class UICustom : UGuiForm
- {
- // Start is called before the first frame update
- [Header("初始界面")]
- public GameObject toolView;
- [Header("基础按钮界面")]
- public GameObject baseView;
- [Header("保存按钮")]
- public GameObject saveBtn;
- [Header("捏脸界面")]
- public GameObject nieLianView;
- [Header("身体界面")]
- public GameObject bodyView;
- [Header("自定义")]
- public GameObject ziDingYiBtn;
- [Header("衣服界面")]
- public GameObject clothView;
- [Header("饰品界面")]
- public GameObject ornamentsView;
- [Header("左边界面")]
- public GameObject leftView;
- [Header("右边界面")]
- public GameObject rightView;
- //[Header("点击后生成的按钮列表")]
- //public GameObject buttonList;
- [Header("白底背景")]
- public GameObject whitebg;
- [Header("按钮预制体")]
- public GameObject buttonItem;
- [Header("滑块")]
- public Scrollbar scrollbar;
- [Header("颜色选择界面")]
- public GameObject colorView;
- [Header("调色版界面")]
- public GameObject tiaoSeBanView;
- // [Header("顺序")]
- private EButtonShunXu eButtonShunXu = EButtonShunXu.None;
-
- [Header("颜色演示预制体")]
- public GameObject colItem;
- public bool hasColorChoose = false;
- public float tween_leftMax = 0;
- public float tween_leftMin = -250;
- public float tween_rightMin = 0;
- public float tween_rightMax = 223;
- //private float tween_saveBtnMax = 119;
- //private float tween_saveBtnMin = -108;
- private float tweenTime = 0.5f;
- //private float tweenTime = 10;
- //private float tweenLeastTime = 0;
- private GameObject nowChooseColorObj;
- public bool isTween = false;
- [Header("选择界面分支")]
- [SerializeField]
- private ECustomStyple eCustomStyple = ECustomStyple.None;
- [Header("历史记录用于回退")]
- [SerializeField]
- private List<string> histroy;
- //用来判断是否是例如颜色框 调色板等额外的弹窗;
- private bool histroyextra;
- private int part = 0;
- private int id = -1;
- private GameObject nowPickOnImg=null;
- private Vector3 colorV3 = new Vector3(0, 0, 0);
- //[Header("接受到的数据")]
- //[SerializeField]
- private IDataTable<DRCustomBody> _bodydata;
- private IDataTable<DRCustomFace> _facedata;
- public void ChangeECustomStyple(ECustomStyple ec) {
- eCustomStyple = ec;
- }
- protected override void OnOpen(object userData)
- {
- base.OnOpen(userData);
- IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
- _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
- _facedata = GameEntry.DataTable.GetDataTable<DRCustomFace>();
- }
- public void ColorChange(Vector3 _v3) {
- colorV3 = _v3;
- }
- public void SaveColorChange()
- {
- var a = new UIColorData(eCustomStyple,id,colorV3);
- String str = JsonUtility.ToJson(a);
- // var obj = JsonUtility.FromJson<PartData>(str);
- SaveColorAdd(3);
- SaveColorAdd(2);
- GameEntry.Setting.SetString("savecolor"+eCustomStyple+"/"+id+"/"+1, str);
- GameEntry.Setting.Save();
- ChooseColorChange();
- //GameEntry.Setting.HasSetting("savecolor");
- //GameEntry.Setting.GetString("");
- }
- public void SaveColorAdd(int _Index)
- {
- if (GameEntry.Setting.HasSetting("savecolor" + eCustomStyple + "/" + id + "/"+_Index))
- {
- String _saveStr=GameEntry.Setting.GetString("savecolor" + eCustomStyple + "/" + id + "/" + (_Index-1));
- GameEntry.Setting.SetString("savecolor" + eCustomStyple + "/" + id + "/" +_Index, _saveStr);
- }
- }
- public void ColorHuaDong(Vector3 _v3)
- {
- colorV3 = _v3;
- }
- public void ChooseColorChange()
- {
- Debug.Log(nowChooseColorObj.transform.parent.name);
- if (nowChooseColorObj!=null)
- {
- Image _img=nowChooseColorObj.transform.GetComponent<Image>();
- _img.color = new Color(colorV3.x,colorV3.y,colorV3.z);
- }
- }
- protected override void OnClose(bool isShutdown, object userData)
- {
- base.OnClose(isShutdown, userData);
- }
- public void ClickBotton(ECustomStyple eCustomStyple,int id,bool ziDingYi,bool isColor)
- {
- if (isTween)
- {
- return;
- }
- isTween = true;
- leftView.transform.DOLocalMoveX(tween_leftMin, tweenTime).SetEase(Ease.InOutBack).OnComplete(()=> {
- //whitebg.SetActive(bg);
-
- ClickBtnFun(eCustomStyple,id,ziDingYi,isColor);
- leftView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
- isTween = false;
- Debug.Log("222");
- });
- });
- Debug.Log("333");
- rightView.transform.DOLocalMoveX(tween_rightMax, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
- rightView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
- });
- });
- }
- /// <summary>
- /// 调色界面打开
- /// </summary>
- public void TiaoSeViewOpenFun() {
- HistoryAdd("Color");
- rightView.SetActive(false);
- colorView.SetActive(true);
- }
- /// <summary>
- /// 调色板的调色板打开或关闭
- /// </summary>
- public void TiaoSeBanOpenStyple(bool _bo)
- {
- colorView.SetActive(!_bo);
- tiaoSeBanView.SetActive(_bo);
-
- }
- /// <summary>
- /// 调色板确认按钮
- /// </summary>
- public void TiaoSeSure()
- {
- SaveColorChange();
- TiaoSeBanOpenStyple(false);
- }
- /// <summary>
- /// 调色板取消按钮
- /// </summary>
- public void TiaoSeBanCloseFun() {
-
- }
- /// <summary>
- /// 自定义调色板
- /// </summary>
- public void TiaoSeBanCustom() {
- }
- public void TiaoSeViewRefesh() {
- GameObject _obj = tiaoSeBanView.transform.GetChild(0).GetChild(0).gameObject;
- RemoveAllChildren(_obj, 1);
- }
- public void TiaoSeAddItem(GameObject _par) {
- if (GameEntry.Setting.HasSetting("savecolor" + eCustomStyple + "/" + id + "/" + 3))
- {
- }
- GameObject _clone = GameObject.Instantiate(colItem);
- _clone.transform.SetParent(_par.transform);
-
- }
- public bool HasCustomColor(int _index)
- {
- bool _has = GameEntry.Setting.HasSetting("savecolor" + eCustomStyple + "/" + id + "/" + _index+"");
- return _has;
- }
- //public UIColorData GetUIColorData(int _index) {
- // String _str= GameEntry.Setting.GetString("savecolor" + eCustomStyple + "/" + id + "/" + _index+"");
- // return
- //}
- /// <summary>
- /// 设置是否已在缓动
- /// </summary>
- public void SetTween(bool _bo) {
- isTween = _bo;
- }
- /// <summary>
- /// 获取是否缓动
- /// </summary>
- public bool GetTween()
- {
- return isTween;
- }
- public void HistoryAdd(string _str) {
- histroy.Add(_str);
- }
- /// <summary>
- /// 滑块改变
- /// </summary>
- public void ScrollValueChange()
- {
- //Debug.Log(scrollbar.value);
- switch (eCustomStyple)
- {
- case ECustomStyple.None:
- break;
- case ECustomStyple.Body:
- GameEntry.Event.Fire(this, CustomRoleBodyEventArgs.Create(part, new Vector3(scrollbar.value, 0, 0)));
- break;
- case ECustomStyple.NieLian:
- break;
- case ECustomStyple.Cloth:
- break;
- }
- // GameEntry.Event.Fire(this, CustomRoleBodyEventArgs.Create(part, new Vector3(scrollbar.value, 0, 0)));
- }
- public void BackBtn_Fun()
- {
- if (histroyextra)
- {
- BackExtraFun();
- histroyextra = false;
- return;
- }
- int index = this.histroy.Count;
- index = eCustomStyple == ECustomStyple.Ornament ? index - 1 : index;
- switch (this.histroy.Count)
- {
- case 0:
- Debug.Log("返回上一层");
- //GameEntry.UI.CloseUIForm(104);
-
- GameEntry.UI.OpenUIForm(UIFormId.GameMenuForm);
- // Close();
- break;
- case 1:
- Debug.Log("返回选择捏脸/身体/服装");
- histroy.RemoveAt(histroy.Count - 1);
- Back_OneFun();
- break;
- case 2:
- Debug.Log("进入选择界面");
- scrollbar.gameObject.SetActive(false);
- histroy.RemoveAt(histroy.Count - 1);
- Back_TwoFun(true);
- break;
- default:
- Debug.Log("进入自定义或颜色");
- // histroy.RemoveAt(histroy.Count - 1);
- Back_ThreeFun();
- histroy.RemoveAt(histroy.Count - 1);
- break;
- }
- }
- public void BackBtnFun()
- {
- if (isTween)
- {
- return;
- }
- //if (histroy.Count == 0)
- //{
- // GameEntry.UI.OpenUIForm(UIFormId.GameMenuForm);
- // Close();
- // return;
- //}
- isTween = true;
- leftView.transform.DOLocalMoveX(tween_leftMin, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
- //whitebg.SetActive(bg);
- BackBtn_Fun();
- leftView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
- isTween = false;
- Debug.Log("222");
- });
- });
- Debug.Log("333");
- rightView.transform.DOLocalMoveX(tween_rightMax, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
- rightView.transform.DOLocalMoveX(0, tweenTime).SetEase(Ease.InOutBack).OnComplete(() => {
- });
- });
- }
- /// <summary>
- /// 返回的方法一
- /// </summary>
- void Back_OneFun() {
- ViewSetFalse();
- toolView.SetActive(true);
- //toolView.SetActive(true);
- //bodyView.SetActive(false);
- //nieLianView.SetActive(false);
- //clothView.SetActive(false);
- }
- /// <summary>
- /// 返回的方法extra
- /// </summary>
- void BackExtraFun()
- {
- rightView.SetActive(true);
- scrollbar.gameObject.SetActive(false);
- }
- /// <summary>
- /// 面板全部隐藏
- /// </summary>
- void ViewSetFalse()
- {
- toolView.SetActive(false);
- bodyView.SetActive(false);
- nieLianView.SetActive(false);
- clothView.SetActive(false);
- }
- void BackView_Extra(GameObject _obj,bool _bo) {
- ViewSetFalse();
- _obj.SetActive(_bo);
- ViewSetChildTrue(_obj,_bo);
- }
- void ViewSetChildTrue(GameObject _obj,bool _bo)
- {
- _obj.transform.GetChild(0).gameObject.SetActive(_bo);
- _obj.transform.GetChild(0).gameObject.SetActive(_bo);
- _obj.transform.GetChild(2).gameObject.SetActive(!_bo);
- }
- /// <summary>
- /// 返回的方法二
- /// </summary>
- void Back_TwoFun(bool _bo)
- {
- // int _choose = int.Parse(histroy[1]);
- // switch ((ECustomStyple)_choose)
- whitebg.SetActive(false);
- switch(eCustomStyple)
- {
- case ECustomStyple.Body:
- BackView_Extra(bodyView,_bo);
- break;
- case ECustomStyple.Cloth:
- BackView_Extra(clothView, _bo);
- break;
- case ECustomStyple.None:
- break;
- case ECustomStyple.NieLian:
- BackView_Extra(nieLianView, _bo);
- break;
- case ECustomStyple.Ornament:
- // BackView_Extra(ornamentsView, _bo);
- BackView_Extra(clothView, _bo);
- ornamentsView.SetActive(false);
- break;
- }
- //toolView.SetActive(true);
- //bodyView.SetActive(false);
- //nieLianView.SetActive(false);
- //clothView.SetActive(false);
- }
- /// <summary>
- /// 返回的方法三
- /// </summary>
- void Back_ThreeFun()
- {
- string[] _strArrary = histroy[histroy.Count - 1].Split(',');
- if (_strArrary[0] == "Color")
- {
- colorView.SetActive(false);
- rightView.SetActive(true);
- }
- else if (_strArrary[0] == "ziDingyi")
- {
- scrollbar.gameObject.SetActive(false);
- int _chooseId = int.Parse(_strArrary[2]);
- hasColorChoose = int.Parse(_strArrary[1]) == 1 ? true : false;
- ClickBtnFun(eCustomStyple, _chooseId, true,hasColorChoose);
- }
- else
- {
- Debug.Log("缺少当前情况需要添加>>>>");
- }
- //toolView.SetActive(true);
- //bodyView.SetActive(false);
- //nieLianView.SetActive(false);
- //clothView.SetActive(false);
- }
- public void PickOnButton(GameObject _obj,int _id) {
- if (_obj.transform.childCount <= 0)
- {
- return;
- }
- GameObject _nowPickOnImg = _obj.transform.GetChild(0).gameObject;
-
- if (nowPickOnImg==null)
- {
-
- nowPickOnImg = _nowPickOnImg;
- id = _id;
- nowPickOnImg.SetActive(true);
- }
- else
- {
-
- if (_id != id)
- {
- nowPickOnImg.SetActive(false);
- id = _id;
- nowPickOnImg = _nowPickOnImg;
- _nowPickOnImg.SetActive(true);
- }
- else
- {
- nowPickOnImg = _nowPickOnImg;
- _nowPickOnImg.SetActive(!_nowPickOnImg.activeSelf);
- }
- }
- scrollbar.gameObject.SetActive(nowPickOnImg.activeSelf);
- }
- /// <summary>
- /// 修改滑块
- /// </summary>
- public void SetValue(int _part,ECustomStyple eCustomStyple)
- {
- //scrollbar.value = _value;
- part = _part;
- scrollbar.value = CustomManager.Instance.GetBodyBoneValue(part);
- }
- /// <summary>
- /// 获得滑块值
- /// </summary>
- public float GetValue()
- {
- return scrollbar.value;
- }
- /// <summary>
- /// 修改颜色
- /// </summary>
- public void SetColor(int _part, ECustomStyple eCustomStyple)
- {
- //scrollbar.value = _value;
- part = _part;
-
- }
- /// <summary>
- /// 按钮点击事件
- /// </summary>
- public void ClickBtnFun(ECustomStyple eCustomStyple,int id,bool zidingyi,bool isColor) {
- //if (isTween)
- //{
- // return;
- //}
- hasColorChoose = isColor;
- whitebg.SetActive(true);
- scrollbar.gameObject.SetActive(false);
- this.eCustomStyple = eCustomStyple;
-
- //ECustomStyple _eCustomStyple = (ECustomStyple)int.Parse(_objects[0].ToString());
- switch (eCustomStyple)
- {
- case ECustomStyple.None:
- break;
- case ECustomStyple.NieLian:
- XXListShow(nieLianView);
- //GameObject _nieLianList = nieLianView.transform.GetChild(0).gameObject;
- //_nieLianList.SetActive(false);
- //GameObject _nieLianXX = nieLianView.transform.GetChild(2).gameObject;
- //_nieLianXX.SetActive(true);
- //if (!zidingyi)
- //{
- // ZiDingYiNeiLian(eCustomStyple, id, _nieLianXX.transform.GetChild(0).gameObject);
- // return;
- //}
- CreateNieLianImg(id, zidingyi,isColor);
- break;
- case ECustomStyple.Body:
- XXListShow(bodyView);
- //GameObject _bodyList = bodyView.transform.GetChild(0).gameObject;
- //_bodyList.SetActive(false);
- //GameObject _bodyListXX =bodyView.transform.GetChild(2).gameObject;
- //_bodyListXX.SetActive(true);
- //if (!zidingyi)
- //{
- // ZiDingYiBody(eCustomStyple, id, _bodyListXX.transform.GetChild(0).gameObject);
- // return;
- //}
- CreateBodyImg(id, zidingyi,isColor);
- break;
- case ECustomStyple.Cloth:
- XXListShow(clothView);
- //GameObject _clothList = clothView.transform.GetChild(0).gameObject;
- //_clothList.SetActive(false);
- //GameObject _clothListXX = clothView.transform.GetChild(2).gameObject;
- //_clothListXX.SetActive(true);
- //if (!zidingyi)
- //{
- // ZiDingYiCloth(eCustomStyple, id, _clothListXX.transform.GetChild(0).gameObject);
- // return;
- //}
- CreateClothImg(id, zidingyi,isColor);
- break;
- case ECustomStyple.Ornament:
- XXListShow(ornamentsView);
- //GameObject _Ornament = ornamentsView.transform.GetChild(0).gameObject;
- //_Ornament.SetActive(false);
- //GameObject _OrnamentXX = ornamentsView.transform.GetChild(2).gameObject;
- //_OrnamentXX.SetActive(true);
- break;
- }
- }
- public void XXListShow(GameObject obj)
- {
- obj.transform.GetChild(0).gameObject.SetActive(false);
- obj.transform.GetChild(2).gameObject.SetActive(true);
- }
- //public Action ActionFun() {
- // return null;
- //}
- public void ModelMove(Vector2 v2)
- {
- Debug.Log(v2.x);
- //CustomManaget.Instance.RotateModel(v2.x);
- }
- private void RemoveAllChildren(GameObject parent,int _index=0)
- {
- Transform transform;
- for (int i = _index; i < parent.transform.childCount; i++)
- {
- transform = parent.transform.GetChild(i);
- GameObject.Destroy(transform.gameObject);
- }
- }
- //public void ZiDingYiNeiLian(ECustomStyple eCustomStyple, int id,GameObject _objPar) {
- // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
- // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
- // _obj.transform.SetParent(_objPar.transform);
- // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- // _uICustomBtn.id = id;
- // _uICustomBtn.eCustomStyple = eCustomStyple;
- // _obj.SetActive(true);
- //}
- //public void ZiDingYiBody(ECustomStyple eCustomStyple, int id, GameObject _objPar)
- //{
- // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
- // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
- // _obj.transform.SetParent(_objPar.transform);
- // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- // _uICustomBtn.id = id;
- // _uICustomBtn.eCustomStyple = eCustomStyple;
- // _obj.SetActive(true);
- //}
- //public void ZiDingYiCloth(ECustomStyple eCustomStyple, int id, GameObject _objPar)
- //{
- // RemoveAllChildren(bodyView.transform.GetChild(2).GetChild(0).gameObject);
- // GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
- // _obj.transform.SetParent(_objPar.transform);
- // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- // _uICustomBtn.id = id;
- // _uICustomBtn.eCustomStyple = eCustomStyple;
- // _obj.SetActive(true);
- //}
- public void CreateNieLianImg(int parentid, bool ziDingYi, bool isColor)
- {
- GameObject _objPar = nieLianView.transform.GetChild(2).GetChild(0).gameObject;
- RemoveAllChildren(_objPar);
- //等有捏脸表时改为捏脸
- IDataTable<DRCustomFace> _data = GameEntry.DataTable.GetDataTable<DRCustomFace>();
- _facedata = GameEntry.DataTable.GetDataTable<DRCustomFace>();
- int cengji = ziDingYi ? 0 : 1;
- if (ziDingYi)
- {
- CreateZDYFun(parentid, _objPar,ziDingYiBtn);
- //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
- //_obj.transform.SetParent(_objPar.transform);
- //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
- //_uICustomBtn.id =parentid;
- //_uICustomBtn.eCustomStyple = eCustomStyple;
- //_obj.SetActive(true);
- }
- if (isColor)
- {
- CreateColFun(parentid, _objPar,colItem);
- }
- DRCustomFace[] dRCustomBodies = _facedata.GetAllDataRows();
- for (int i = 0; i < dRCustomBodies.Length; i++)
- {
- Debug.Log(dRCustomBodies[i].Id);
- if (dRCustomBodies[i].ParentStyple == parentid&&dRCustomBodies[i].Cengji==cengji)
- {
- CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
- }
- }
-
- ChangeListBotton(_objPar);
- }
- public void CreateClothImg(int parentid,bool ziDingYi, bool isColor)
- {
- GameObject _objPar = clothView.transform.GetChild(2).GetChild(0).gameObject;
- RemoveAllChildren(_objPar);
- //if (parentid == 8)
- //{
-
- //}
- //等有服装时改为服装
- IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
- _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
- int cengji = ziDingYi ? 0 : 1;
- if (ziDingYi)
- {
- CreateZDYFun(parentid, _objPar,ziDingYiBtn);
- //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
- //_obj.transform.SetParent(_objPar.transform);
- //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
- //_uICustomBtn.id = parentid;
- //_uICustomBtn.eCustomStyple = eCustomStyple;
- //_obj.SetActive(true);
- }
- if (isColor)
- {
- CreateColFun(parentid, _objPar, colItem);
-
- }
- DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
- for (int i = 0; i < dRCustomBodies.Length; i++)
- {
- Debug.Log(dRCustomBodies[i].Id);
- if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
- {
- CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
- }
- }
- ChangeListBotton(_objPar);
- }
- public void CreateOrnamentImg(int parentid, bool ziDingYi, bool isColor)
- {
- GameObject _objPar = ornamentsView.transform.GetChild(2).GetChild(0).gameObject;
- RemoveAllChildren(_objPar);
- //if (parentid == 8)
- //{
- //}
- //等有服装时改为服装
- IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
- _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
- int cengji = ziDingYi ? 0 : 1;
- //if (ziDingYi)
- //{
- // CreateZDYFun(parentid, _objPar, ziDingYiBtn);
- // //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
- // //_obj.transform.SetParent(_objPar.transform);
- // //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- // //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
- // //_uICustomBtn.id = parentid;
- // //_uICustomBtn.eCustomStyple = eCustomStyple;
- // //_obj.SetActive(true);
- //}
- //if (isColor)
- //{
- // CreateColFun(parentid, _objPar, colItem);
- //}
- DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
- for (int i = 0; i < dRCustomBodies.Length; i++)
- {
- Debug.Log(dRCustomBodies[i].Id);
- if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
- {
- CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
- }
- }
- ChangeListBotton(_objPar);
- }
- private void CreateZDYFun(int parentid,GameObject _objPar,GameObject _clone)
- {
- GameObject _obj = GameObject.Instantiate(_clone);
- _obj.transform.SetParent(_objPar.transform);
- UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
- }
- private void CreateColFun(int parentid, GameObject _objPar, GameObject _clone)
- {
- GameObject _obj = GameObject.Instantiate(_clone);
- _obj.transform.SetParent(_objPar.transform);
- UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
- nowChooseColorObj = _obj;
- }
- //private void CreateColorFun(int parentid, GameObject _objPar, GameObject _clone)
- //{
- // GameObject _obj = GameObject.Instantiate(_clone);
- // _obj.transform.SetParent(_objPar.transform);
- // UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- // ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
- //}
- public void ChangeUICustom(UICustomBtn uICustomBtn,int id, ECustomStyple eCustomStyple)
- {
- uICustomBtn.id = id;
- uICustomBtn.eCustomStyple = eCustomStyple;
- uICustomBtn.gameObject.SetActive(true);
- }
- public void CreateBodyImg(int parentid,bool ziDingYi, bool isColor) {
- GameObject _objPar = bodyView.transform.GetChild(2).GetChild(0).gameObject;
- RemoveAllChildren(_objPar);
- IDataTable<DRCustomBody> _data = GameEntry.DataTable.GetDataTable<DRCustomBody>();
- _bodydata = GameEntry.DataTable.GetDataTable<DRCustomBody>();
- int cengji = ziDingYi ?0:1;
- if (ziDingYi)
- {
- CreateZDYFun(parentid, _objPar,ziDingYiBtn);
- //GameObject _obj = GameObject.Instantiate(ziDingYiBtn);
- //_obj.transform.SetParent(_objPar.transform);
- //UICustomBtn _uICustomBtn = _obj.GetComponent<UICustomBtn>();
- //ChangeUICustom(_uICustomBtn, parentid, eCustomStyple);
- //_uICustomBtn.id = parentid;
- //_uICustomBtn.eCustomStyple = eCustomStyple;
- //_obj.SetActive(true);
- }
- if (isColor)
- {
- CreateColFun(parentid, _objPar, colItem);
- }
- DRCustomBody[] dRCustomBodies = _bodydata.GetAllDataRows();
- for (int i = 0; i < dRCustomBodies.Length; i++)
- {
- Debug.Log(dRCustomBodies[i].Id);
- if (dRCustomBodies[i].ParentStyple == parentid && dRCustomBodies[i].Cengji == cengji)
- {
- CreateButtonFun(dRCustomBodies[i].Icon, dRCustomBodies[i].Name, _objPar, dRCustomBodies[i].Id, dRCustomBodies[i].ButtonStyple, ECustomStyple.Body, dRCustomBodies[i].IsActive);
- }
- }
- ChangeListBotton(_objPar);
- }
- /// <summary>
- /// 改变列表长短
- /// </summary>
- public void ChangeListBotton(GameObject _obj) {
- //Debug.Log("改变列表"+ _obj.transform.childCount+"");
-
- float _x = _obj.GetComponent<RectTransform>().offsetMin.x;
- int _childNum = _obj.transform.childCount;
- float _y = _childNum > 7 ? -240 * (_childNum - 7) : 0;
- _obj.GetComponent<RectTransform>().offsetMax = new Vector2(_x, 0);
- _obj.GetComponent<RectTransform>().offsetMin = new Vector2(_x, _y);
- }
- //public void OrnamentListOpen()
- //{
- // HistoryAdd(ECustomStyple.Ornament+"");
- //}
- //private IEnumerator Tween(Action _action) {
- // for (int i = 0; i < 100; i++)
- // {
- // float _value = i / 100;
- // float _right=Mathf.Lerp(tween_rightMax, tween_rightMin, _value);
- // float _left= Mathf.Lerp(tween_leftMix, tween_rightMax, _value);
- // clothView.GetComponent<RectTransform>().SetPositionX(_right);
- // toolView.GetComponent<RectTransform>().SetPositionX(_right);
- // bodyView.GetComponent<RectTransform>().SetPositionX(_right);
- // nieLianView.GetComponent<RectTransform>().SetPositionX(_right);
- // baseView.GetComponent<RectTransform>().SetPositionX(_left);
- // }
- // yield return null;
- //}
- protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
- {
- base.OnUpdate(elapseSeconds, realElapseSeconds);
- }
- //private void CreateNieLianFun(object[] _objects) {
- // ENieLianStyple _eNieLianStyple = (ENieLianStyple)int.Parse(_objects[1].ToString());
- // switch (_eNieLianStyple)
- // {
- // case ENieLianStyple.faxing:
- // break;
- // case ENieLianStyple.lianxing:
- // break;
- // case ENieLianStyple.yankuang:
- // break;
- // case ENieLianStyple.tongkong:
- // break;
- // case ENieLianStyple.meimao:
- // break;
- // case ENieLianStyple.bizi:
- // break;
- // case ENieLianStyple.erduo:
- // break;
- // case ENieLianStyple.zuiba:
- // break;
- // case ENieLianStyple.fuse:
- // break;
- // }
- // //switch()
- //}
- private void CreateButtonFun(string path,string _name, GameObject _parent,int _id,int buttonstyple,ECustomStyple eCustomStyple,int _isactive) {
- //Debug.Log(path);
- // Debug.Log(_parent);
- path = "CustomRole/" + path;
- Debug.Log("图片名称" + _name);
- GameEntry.Resource.LoadAsset(AssetUtility.GetUISpriteAsset(path), new LoadAssetCallbacks(
- (assetName, asset, duration, userData) =>
- {
- // Debug.Log(path);
- // Debug.Log(_parent);
- Texture2D tex = (Texture2D)asset;
- var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
- GameObject _obj = GameObject.Instantiate(buttonItem);
- Image _objImg = _obj.transform.GetComponent<Image>();
- _obj.SetActive(true);
- _objImg.sprite = sprite;
- _obj.name = _name+"";
- _obj.transform.SetParent(_parent.transform);
- if (_isactive != 1)
- {
- _obj.SetActive(false);
- }
- UICustomBtn uICustomBtn = _obj.GetComponent<UICustomBtn>();
- uICustomBtn.id = _id;
- uICustomBtn.eButtonStyple = (EButtonStyple)buttonstyple;
- uICustomBtn.eCustomStyple = eCustomStyple;
- uICustomBtn.isCreate = false;
- //uICustomBtn.part = _part;
- //GameObject
- //img.sprite = sprite;
- //if (nativeSize)
- //{
- // img.SetNativeSize();
- //}
- ChangeListBotton(_parent);
- }));
- }
- //public void NieLian() {
-
- //}
- public void ClickFaceChangeBtn()
- {
- GameEntry.Event.Fire(this, CustomRoleFaceEventArgs.Create(EditableFacePart.eye, new Vector3(1, 0, 0)));
- }
- }
- public enum ECustomStyple
- {
- None,
- NieLian,
- Body,
- Cloth,
- Ornament,
- }
- public enum EButtonStyple
- {
- Button,
- Scroll,
- TiaoSe,
- NorButton,
- Back
- }
- public enum ENieLianStyple {
- None,
- faxing,
- lianxing,
- yankuang,
- tongkong,
- meimao,
- bizi,
- erduo,
- zuiba,
- fuse
- }
- public enum EButtonShunXu {
-
- None,
- First,
- Second,
- Third
- }
- public enum ETSStyple {
- None,
- ViewOpen,
- Close,
- Sure,
- Open,
- Button
- }
- }
|