123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816 |
- using UnityEngine;
- using UnityEngine.UI;
- using QFramework;
- using System.Collections.Generic;
- using UniRx;
- using System.Linq;
- using System.IO;
- using System;
- using LitJson;
- namespace QFramework.MREditor
- {
- public enum UIEditorEvent
- {
- Start = QMgrID.UI,
- OnUIOpenElenemt,
- OnAddSpoitObj,
- OnSelectObjName,
- OnSaveDataSetting,
- OnRemoveDataSetting,
- OnAddNewMaterial,
- }
- public class OnUIOpenElenemt : QMsg
- {
- public bool state;
- public OnUIOpenElenemt(bool state) : base((int)UIEditorEvent.OnUIOpenElenemt)
- {
- this.state = state;
- }
- }
- public class OnAddSpoitObj : QMsg
- {
- public string path;
- public OnAddSpoitObj(string path) : base((int)UIEditorEvent.OnAddSpoitObj)
- {
- this.path = path;
- }
- }
- public class OnSelectObjName : QMsg
- {
- public string spoitName;
- public string Name;
- public string CMVName;
- public OnSelectObjName(string Name, string CMVName, string spoitName) : base((int)UIEditorEvent.OnSelectObjName)
- {
- this.Name = Name;
- this.CMVName = CMVName;
- this.spoitName = spoitName;
- }
- }
- public class OnSaveDataSetting : QMsg
- {
- public Vector3 pos;
- public Vector3 rot;
- public Vector3 scale;
- public string name;
- public OnSaveDataSetting(string name, Vector3 pos, Vector3 rot, Vector3 scale) : base((int)UIEditorEvent.OnSaveDataSetting)
- {
- this.name = name;
- this.pos = pos;
- this.rot = rot;
- this.scale = scale;
- }
- }
- public class OnRemoveDataSetting : QMsg
- {
- public string name;
- public OnRemoveDataSetting(string name) : base((int)UIEditorEvent.OnRemoveDataSetting)
- {
- this.name = name;
- }
- }
- public class OnAddNewMaterial : QMsg
- {
- public CompositeMaterialValue newMaterial;
- public OnAddNewMaterial(CompositeMaterialValue objValue) : base((int)UIEditorEvent.OnAddNewMaterial)
- {
- this.newMaterial = objValue;
- }
- }
- public class EditorPanelData : UIPanelData
- {
- public SceneValue SceneValue = new SceneValue();
- public List<CompositeMaterialValue> listLocalMaterials = new List<CompositeMaterialValue>();
- public List<CompositeMaterialValue> listUpLoadMaterials = new List<CompositeMaterialValue>();
-
- }
- public partial class EditorPanel : UIPanel
- {
- private Transform selectObj;
- private Transform selectCMVObj;
- private GameObject selectSpoit;
- public Dictionary<string, List<GameObject>> dicObjs;
- public Dictionary<string, List<GameObject>> dicCMVOjbes;
- public Dictionary<string, SelectBJImage> dicSelectBackImage;
- protected override void ProcessMsg(int eventId, QMsg msg)
- {
- Debug.Log(eventId);
- switch ((UIEditorEvent)eventId)
- {
- case UIEditorEvent.Start:
- break;
- case UIEditorEvent.OnUIOpenElenemt:
- var onUIOpenElenemt = msg as OnUIOpenElenemt;
- Debug.Log(onUIOpenElenemt.state);
- OpenElenemt(onUIOpenElenemt.state);
- break;
- case UIEditorEvent.OnAddSpoitObj:
- var OnAddSpoitObj = msg as OnAddSpoitObj;
- Debug.Log(OnAddSpoitObj.path +" ?????");
- break;
- case UIEditorEvent.OnSelectObjName:
- var OnSelectObjName = msg as OnSelectObjName;
- Debug.Log(OnSelectObjName.Name);
- SelectedObj(OnSelectObjName.Name, OnSelectObjName.spoitName);
- Debug.Log("OnSelectObjName");
- break;
- case UIEditorEvent.OnSaveDataSetting:
- var OnSaveDataSetting = msg as OnSaveDataSetting;
- Debug.Log(OnSaveDataSetting.name);
- // SaveData(OnSaveDataSetting.name, OnSaveDataSetting.pos, OnSaveDataSetting.rot, OnSaveDataSetting.scale);
- SaveData(OnSaveDataSetting.name);
- break;
- case UIEditorEvent.OnRemoveDataSetting:
- var OnRemoveDataSetting = msg as OnRemoveDataSetting;
- RemoveData();
- break;
- case UIEditorEvent.OnAddNewMaterial:
- var OnAddNewMaterial = msg as OnAddNewMaterial;
- Debug.Log(OnAddNewMaterial.newMaterial);
- // AddMaterialObj(OnAddNewMaterial.newMaterial);
- AddCMaterialObj(OnAddNewMaterial.newMaterial);
- break;
- }
- }
- protected override void OnInit(IUIData uiData = null)
- {
- mData = uiData as EditorPanelData ?? new EditorPanelData();
- selectObj = null;
- selectCMVObj = null;
- selectSpoit = null;
- dicObjs = new Dictionary<string, List<GameObject>>();
- // dicCMVOjbes = new Dictionary<string, List<GameObject>>();
- dicSelectBackImage = new Dictionary<string, SelectBJImage>();
- RegisterEvent(UIEditorEvent.OnUIOpenElenemt);
- RegisterEvent(UIEditorEvent.OnAddSpoitObj);
- RegisterEvent(UIEditorEvent.OnSelectObjName);
- RegisterEvent(UIEditorEvent.OnSaveDataSetting);
- RegisterEvent(UIEditorEvent.OnRemoveDataSetting);
- RegisterEvent(UIEditorEvent.OnAddNewMaterial);
- Debug.Log(mData.listUpLoadMaterials.Count);
- try
- {
- UIAddMaterial.Initialized(mData.listLocalMaterials, mData.listUpLoadMaterials, SingleMaterial);
- UIEditor.Initialized(mData.SceneValue.listSpoit);
- UISpoits.Initialized(mData.SceneValue.listSpoit, SpoitBtn, MaterialBtn, UIMaterials);
- UISpoits.Hide();
- }
- catch (Exception )
- {
- ErrorLogPanel.Instance.Show(" UI模块出现未知错误 ");
- }
- //UIMaterials.Hide();
- try
- {
- List<SpoitValue> listSpoit = new List<SpoitValue>();
- mData.SceneValue.listSpoit.ForEach(item =>
- {
- // Debug.Log(item.name);
- listSpoit.Add(item);
- // LoadSpoitObj(item.name, item);
- });
- SpoitValue spoit = null;
- for (int i = 0; i < listSpoit.Count; i++)
- {
- for (int j = 0; j < listSpoit.Count; j++)
- {
- if (listSpoit[i].id < listSpoit[j].id)
- {
- spoit = listSpoit[i];
- listSpoit[i] = listSpoit[j];
- listSpoit[j] = spoit;
- spoit = null;
- }
- }
- }
- listSpoit.ForEach(item => { Debug.Log(item.name + " " + item.id); LoadSpoitObj(item.name, item); });
- }
- catch (Exception)
- {
- ErrorLogPanel.Instance.Show(" 初始化场景信息出现错误");
- }
-
- }
- protected override void OnOpen(IUIData uiData = null)
- {
- //transform.parent = GameObject.Find("Canvas").transform;
- //RectTransform rect = transform.GetComponent<RectTransform>();
- //rect.localPosition = Vector3.zero;
- //rect.localScale = Vector3.one;
- transform.parent.eulerAngles = new Vector3(30, 0, 0);
- }
- protected override void OnShow()
- {
- if (selectSpoit != null)
- selectSpoit.SetActive(true);
- gameObject.SetActive(true);
- }
- protected override void OnHide()
- {
- foreach (var item in dicObjs)
- {
- item.Value[0].SetActive(false);
- }
- if (selectSpoit != null)
- selectSpoit.SetActive(false);
- gameObject.SetActive(false);
- }
- protected override void OnClose()
- {
- }
- public void OpenElenemt(bool state)
- {
- if (state)
- {
- UIEditor.Show();
- UIAddMaterial.Close();
- }
- else
- {
- UIEditor.Close();
- UIAddMaterial.Show();
- }
- }
-
- /// <summary>
- /// 加载景点
- /// </summary>
- /// <param name="name"></param>
- /// <param name="spoit"></param>
- public void LoadSpoitObj(string name, SpoitValue spoit)
- {
- dicObjs.Add(spoit.name, new List<GameObject>());
- GameObject target = new GameObject(spoit.name + "Target");
- GameObject targetShow = new GameObject("TargetShowObj");
- GameObject spoitObj = new GameObject(spoit.name);
- spoitObj.transform.parent = target.transform;
- spoitObj.transform.LocalIdentity();
- targetShow.transform.parent = target.transform;
- targetShow.transform.LocalIdentity();
- VuforialTargetMove vuforialTarget = target.AddComponent<VuforialTargetMove>();
- vuforialTarget.isClose = true;
- vuforialTarget.showObjs.Add(spoitObj.transform);
- vuforialTarget.listObjs.Add(targetShow.AddComponent<TargetShowObj>());
- VuforialControl.Instance.list_Target.Add(vuforialTarget);
-
- dicObjs[spoit.name].Add(spoitObj);
- List<CMaterialValueShow> allMaterial = new List<CMaterialValueShow>();
- spoit.material.ForEach(item =>
- {
- Debug.Log(item.name);
- LoadCMaterialObj(item, spoitObj);
- });
- spoitObj.SetActive(false);
- Debug.Log(spoit.name+"AAA");
- //SelectedObj(name, spoit.Name);
- SetObjMaterial(spoitObj, spoit.spoitTf);
- }
- /// <summary>
- /// 加载组合素材
- /// </summary>
- /// <param name="cMValue"></param>
- /// <param name="spoitObj"></param>
- public void LoadCMaterialObj(CompositeMaterialValue cMValue, GameObject spoitObj)
- {
-
- GameObject cMVObj = new GameObject(cMValue.name);
- cMVObj.transform.parent = spoitObj.transform;
- cMVObj.transform.LocalIdentity();
- CMaterialValueShow cMVShow = cMVObj.AddComponent<CMaterialValueShow>();
- cMVShow.spoitname = spoitObj.name;
- cMVShow.cMValue = cMValue;
- Debug.Log(cMVShow.name);
- dicObjs[spoitObj.name].Add(cMVObj);
- SetObjMaterial(cMVObj, cMValue.objectTransform);
- //if (cMValue.objectTransform != null)
- // cMValue.objectTransform.SetObjectTransform(cMVObj.transform);
- //else
- // Debug.LogError(cMValue.name +" ObjectTransform is NULL ");
- }
- public void SetObjMaterial(GameObject obj, ObjectTransform objectData)
- {
- if (objectData == null)
- return;
- if (objectData.nowScale == Vector3.zero)
- {
- if (objectData.startScale == Vector3.zero)
- objectData.startScale = Vector3.one;
- obj.transform.localPosition = Vector3.zero;
- obj.transform.localEulerAngles = Vector3.zero;
- obj.transform.localScale = Vector3.one;
- }
- else
- {
- obj.transform.localPosition = objectData.nowPos;
- obj.transform.localEulerAngles = objectData.nowRot;
- obj.transform.localScale = objectData.nowScale;
- }
- }
- /// <summary>
- /// 选择物体
- /// </summary>
- /// <param name="name"></param>
- /// <param name="spoitName"></param>
- public void SelectedObj(string name, string spoitName)
- {
- if (!dicObjs.ContainsKey(spoitName))
- mData.SceneValue.listSpoit.ForEach(item =>
- {
- Debug.LogError("未找到 景点 "+ spoitName);
- //if (item.Name == spoitName)
- // Loader(name, item);
- });
- else
- {
- //int i = 0;
- //foreach (var item in dicObjs)
- //{
- // item.Value[0].SetActive(false);
- // if (item.Key == spoitName)
- // {
- // item.Value[0].SetActive(true);
- // item.Value[0].transform.parent.position = GameManager.Instance.listEditorBJs[0].transform.position += new Vector3(0, 0, -0.1f);
- // item.Value[0].transform.parent.eulerAngles = new Vector3(item.Value[0].transform.parent.eulerAngles.x, GameManager.Instance.listEditorBJs[0].transform.eulerAngles.y, item.Value[0].transform.parent.eulerAngles.z);
- // GameManager.Instance.SetImageBJ(i);
- // }
- // i++;
- //}
- dicObjs[spoitName].ForEach(item =>
- {
- Debug.Log(item.name + " "+name);
- if (item.name == name)
- {
- //Debug.Log(selectObj.name);
- //if (selectObj != null && selectObj.name != selectSpoit.name)
- //{
- //// selectObj.GetComponent<SelectBJImage>().SelectBj.SetActive(false);
- //}
-
- if(selectObj != null&&dicSelectBackImage.ContainsKey(selectSpoit.name+ selectObj.name))
- {
- dicSelectBackImage[selectSpoit.name + selectObj.name].SelectObj(false);
- }
- selectSpoit = dicObjs[spoitName][0];
- selectObj = item.transform;
- if (selectObj.parent.name == selectSpoit.name)
- selectCMVObj = item.transform;
- else
- selectCMVObj = selectObj.parent;
- Debug.Log(selectSpoit.name + " " + selectObj.name);
- UIEditor.SelectMaterial(item.transform);
- if (dicSelectBackImage.ContainsKey(selectSpoit.name + selectObj.name))
- {
- dicSelectBackImage[selectSpoit.name + selectObj.name].SelectObj(true);
- }
- //if (selectObj.name != selectSpoit.name)
- //{
- // // selectObj.GetComponent<SelectBJImage>().SelectBj.SetActive(true);
- //}
- }
- });
-
- //dicObjs[spoitName].ForEach(item =>
- //{
- // if (item.name == name)
- // {
- // selectSpoit = dicObjs[spoitName][0];
- // selectObj = item.transform;
- // UIEditor.SelectMaterial(item.transform);
- // }
- //});
- }
- }
- public void SelectSpoitObj(string name)
- {
- // Debug.Log(name + "@@@@@@");
- UISpoits.SelectSpoitObj(name);
- SelectedObj(name, name);
- HttpSocket.Instance.SendIpToPointTrigger(name);
-
- }
- /// <summary>
- /// 添加组合素材
- /// </summary>
- /// <param name="value"></param>
- public void AddCMaterialObj(CompositeMaterialValue value)
- {
- if (selectSpoit.IsNull())
- return;
- UIMaterials.AddMaterial(selectSpoit.name, value, MaterialBtn);
- AddData(value);
- LoadCMaterialObj(value, selectSpoit);
-
- }
-
- /// <summary>
- /// 保存数据
- /// </summary>
- /// <param name="name"> 选中的物体名 </param>
- /// <param name="pos"> 位置 </param>
- /// <param name="rot"> 旋转 </param>
- /// <param name="scale"> 尺寸 </param>
- public void SaveData(string name, Vector3 pos, Vector3 rot, Vector3 scale)
- {
- if (selectObj == null || selectSpoit==null)
- return;
- // selectCMVObj = new GameObject("样式测试").transform;
- GameManager.Instance.text2.text = selectObj.name + " " + name + " " + selectCMVObj.name + " " + selectSpoit.name;
- GameManager.Instance.text4.text = "准备保存";
- Debug.Log(name + " " + selectObj.name + " "+selectCMVObj.name +" "+selectSpoit.name);
-
- SpoitValue spoitValue = null;
- //for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- //{
- // if (mData.SceneValue.listSpoit[i].name == selectSpoit.name)
- // {
- // if (selectSpoit.name == selectObj.name) // 保存的是景点属性
- // {
- // Debug.Log(" 景点已保存 ");
- // mData.SceneValue.listSpoit[i].spoitTf.nowPos = pos;
- // mData.SceneValue.listSpoit[i].spoitTf.nowRot = rot;
- // if (scale == Vector3.zero)
- // scale = mData.SceneValue.listSpoit[i].spoitTf.startScale;
- // mData.SceneValue.listSpoit[i].spoitTf.nowScale = scale;
- // // mData.SceneValue.listSpoit[i].updateTime = DateTime.Now;
- // break;
-
- // }
- // spoitValue = mData.SceneValue.listSpoit[i];
- // break;
- // }
- //}
- //if (spoitValue != null)
- //{
- // for (int i = 0; i < spoitValue.material.Count; i++)
- // {
- // if (spoitValue.material[i].name == selectCMVObj.name)
- // {
- // if (spoitValue.material[i].name == selectObj.name)
- // {
- // Debug.Log(" 组合素材属性已保存 ");
- // spoitValue.material[i].objectTransform.nowPos = pos;
- // spoitValue.material[i].objectTransform.nowRot = rot;
- // if (scale == Vector3.zero)
- // scale = spoitValue.material[i].objectTransform.startScale;
- // spoitValue.material[i].objectTransform.nowScale = scale;
- // break;
- // }
- // for (int j = 0; j < spoitValue.material[i].materialList.Count; j++)
- // {
- // if (spoitValue.material[i].materialList[j].name == selectObj.name)
- // {
- // Debug.Log(" 素材已保存 ");
- // spoitValue.material[i].materialList[j].ObjectTransform.nowPos = pos;
- // spoitValue.material[i].materialList[j].ObjectTransform.nowRot = rot;
- // if (scale == Vector3.zero)
- // scale = spoitValue.material[i].materialList[j].ObjectTransform.startScale;
- // spoitValue.material[i].materialList[j].ObjectTransform.nowScale = scale;
- // break;
- // }
- // }
- // break;
- // }
- // }
- // for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- // {
- // if (mData.SceneValue.listSpoit[i].name == spoitValue.name)
- // {
- // mData.SceneValue.listSpoit[i] = spoitValue;
- // break;
- // }
- // }
- //}
- for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- {
- if (mData.SceneValue.listSpoit[i].name == selectSpoit.name)
- {
-
- Debug.Log(" 景点已保存 ");
- mData.SceneValue.listSpoit[i].spoitTf.nowPos = pos;
- mData.SceneValue.listSpoit[i].spoitTf.nowRot = rot;
- if (scale == Vector3.zero)
- scale = mData.SceneValue.listSpoit[i].spoitTf.startScale;
- mData.SceneValue.listSpoit[i].spoitTf.nowScale = scale;
- // mData.SceneValue.listSpoit[i].updateTime = DateTime.Now;
-
-
- spoitValue = mData.SceneValue.listSpoit[i];
- break;
- }
- }
- if (spoitValue != null)
- {
-
- for (int i = 0; i < spoitValue.material.Count; i++)
- {
- if (spoitValue.material[i].name == selectCMVObj.name)
- {
-
- Debug.Log(" 组合素材属性已保存 ");
- spoitValue.material[i].objectTransform.nowPos = pos;
- spoitValue.material[i].objectTransform.nowRot = rot;
- if (scale == Vector3.zero)
- scale = spoitValue.material[i].objectTransform.startScale;
- spoitValue.material[i].objectTransform.nowScale = scale;
- break;
-
- for (int j = 0; j < spoitValue.material[i].materialList.Count; j++)
- {
-
- Debug.Log(" 素材已保存 ");
- spoitValue.material[i].materialList[j].ObjectTransform.nowPos = pos;
- spoitValue.material[i].materialList[j].ObjectTransform.nowRot = rot;
- if (scale == Vector3.zero)
- scale = spoitValue.material[i].materialList[j].ObjectTransform.startScale;
- spoitValue.material[i].materialList[j].ObjectTransform.nowScale = scale;
- break;
-
- }
- break;
- }
- }
- for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- {
- if (mData.SceneValue.listSpoit[i].name == spoitValue.name)
- {
- mData.SceneValue.listSpoit[i] = spoitValue;
- break;
- }
- }
- }
- }
- public void SaveData(string name)
- {
- List<GameObject> list_Material;
- list_Material = dicObjs[selectSpoit.name];
- Debug.Log(" SelectSpoit Name : " + selectSpoit.name);
- // list_Material.ForEach(item =>
- //{
- // SaveData(item.name, item.transform.localPosition, item.transform.localEulerAngles, item.transform.localScale);
- //});
- SaveData(list_Material);
- GameManager.Instance.Save(mData.SceneValue);
- }
- private void SaveData(List<GameObject> list_Material)
- {
- SpoitValue spoitValue = null;
- for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- {
- if (mData.SceneValue.listSpoit[i].name == selectSpoit.name)
- {
- Debug.Log(" 景点已保存 ");
- mData.SceneValue.listSpoit[i].spoitTf.nowPos = list_Material[0].transform.localPosition;
- mData.SceneValue.listSpoit[i].spoitTf.nowRot = list_Material[0].transform.localEulerAngles;
- if (list_Material[0].transform.localScale == Vector3.zero)
- list_Material[0].transform.localScale = mData.SceneValue.listSpoit[i].spoitTf.startScale;
- mData.SceneValue.listSpoit[i].spoitTf.nowScale = list_Material[0].transform.localScale;
- // mData.SceneValue.listSpoit[i].updateTime = DateTime.Now;
- spoitValue = mData.SceneValue.listSpoit[i];
- break;
- }
- }
- Transform material;
- Debug.Log(" ****** "+spoitValue.name);
- if(spoitValue != null)
- {
- for (int i = 0; i < spoitValue.material.Count; i++)
- {
- material = FindMaterial(list_Material, spoitValue.material[i].name);
- if(material!=null)
- {
- Debug.Log(" 组合素材已保存 ");
- spoitValue.material[i].objectTransform.nowPos = material.localPosition;
- spoitValue.material[i].objectTransform.nowRot = material.localEulerAngles;
- spoitValue.material[i].objectTransform.nowScale = material.localScale;
-
- }
- for (int j = 0; j < spoitValue.material[i].materialList.Count; j++)
- {
- material = FindMaterial(list_Material, spoitValue.material[i].materialList[j].name);
- if (material != null)
- {
- Debug.Log(" 素材已保存 ");
- spoitValue.material[i].materialList[j].ObjectTransform.nowPos = material.localPosition;
- spoitValue.material[i].materialList[j].ObjectTransform.nowRot = material.localEulerAngles;
- spoitValue.material[i].materialList[j].ObjectTransform.nowScale = material.localScale;
- }
- }
- }
- }
- }
- private Transform FindMaterial(List<GameObject> list_Material, string name )
- {
- for (int i = 1; i < list_Material.Count; i++)
- {
- Debug.Log(list_Material[i].name + " " + name);
- if (list_Material[i].name == name)
- return list_Material[i].transform;
- }
- return null;
-
- }
- /// <summary>
- /// 移除选中数据
- /// </summary>
- public void RemoveData()
- {
- if (selectObj == null)
- return;
- if (selectSpoit.name == selectObj.name)
- return;
- SpoitValue spoitValue = null;
- for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- {
- if (mData.SceneValue.listSpoit[i].name == selectSpoit.name)
- {
- //if (selectSpoit.name == selectObj.name)
- //{
- // mData.SceneValue.listSpoit.Remove(mData.SceneValue.listSpoit[i]);
- // break;
- //}
- spoitValue = mData.SceneValue.listSpoit[i];
- break;
- }
- }
- if (spoitValue != null)
- {
- for (int i = 0; i < spoitValue.material.Count; i++)
- {
- if (spoitValue.material[i].name == selectObj.name)
- {
- spoitValue.material.Remove(spoitValue.material[i]);
- break;
- }
- for (int j = 0; j < spoitValue.material[i].materialList.Count; j++)
- {
- if (spoitValue.material[i].materialList[j].name == selectObj.name)
- {
- spoitValue.material[i].materialList.Remove(spoitValue.material[i].materialList[j]);
- break;
- }
- }
-
- }
- for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- {
- if (mData.SceneValue.listSpoit[i].name == spoitValue.name)
- {
- mData.SceneValue.listSpoit[i] = spoitValue;
- break;
- }
- }
- }
- UIMaterials.RemoveMaterials(selectSpoit.name+ selectObj.name);
- selectObj.gameObject.SetActive(false);
- selectObj = null;
-
- GameManager.Instance.Save(mData.SceneValue);
- }
- //public void AddData(MaterialObjValue value)
- //{
- // for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- // {
- // if(mData.SceneValue.listSpoit[i].name == selectObj.name)
- // {
- // mData.SceneValue.listSpoit[i].listMaterial.Add(value);
- // GameManager.Instance.Save(mData.SceneValue);
- // break;
- // }
- // }
- //}
- /// <summary>
- /// 新添加数据
- /// </summary>
- /// <param name="value"></param>
- public void AddData(CompositeMaterialValue value)
- {
- for (int i = 0; i < mData.SceneValue.listSpoit.Count; i++)
- {
- if (mData.SceneValue.listSpoit[i].name == selectObj.name)
- {
- Debug.Log(JsonMapper.ToJson( mData.SceneValue.listSpoit[i]));
- mData.SceneValue.listSpoit[i].material.Add(value);
- Debug.Log(JsonMapper.ToJson(mData.SceneValue.listSpoit[i]));
- GameManager.Instance.Save(mData.SceneValue);
- break;
- }
- }
- }
- }
- }
|