void SetOperationList(List <GameObject> sign) { List <Operation> opers = new List <Operation>(); if (sign.Count != 0) { opers.AddRange(resourceLoad.Operations); } foreach (var t in sign) { var select = t.GetComponentInParent <CLGameObject>(); if (select == null) { Debug.Log("select为空"); continue; } if (EventsManager.AnyObjectSelected != null) { EventsManager.AnyObjectSelected(select.cl_object); } var clobj = resourceLoad.GetObjectInfoByName(select.cl_object.Name); List <Operation> temp = new List <Operation>(); foreach (var s in clobj.Operations) { if (opers.Exists(s1 => s1.Name == s.Name)) { temp.Add(s); } } opers.Clear(); opers = new List <Operation>(temp); } OperationManager.SetOperations(opers); }
public void ReNameSceneObject(string oldname, string newname) { for (int i = 0; i < resourceLoad.SceneObjects.Count; i++) { var temp = resourceLoad.SceneObjects[i]; var clgameobj = temp.GetComponent <CLGameObject>(); if (clgameobj.cl_object.Name == oldname) { CL_Object clobj = resourceLoad.GetObjectInfoByName(newname); clobj.Id = clgameobj.cl_object.Id; clgameobj.Load(resourceLoad, clobj); } } }
private void Update() { if (resourceLoad == null) { return; } if (resourceLoad.IsEdit) { CL_Object clobj = resourceLoad.GetObjectInfoByName(cl_object.Name); if (clobj != null) { clobj.Id = cl_object.Id; Load(resourceLoad, clobj); } } else { if (EventsManager.AnyObjectCompare != null) { EventsManager.AnyObjectCompare(cl_object); } } }
public void ModefyField() { int val = ObjectDataArea.Value; if (val == -1) { return; } KeyValuePair <string, object> keyValue = (KeyValuePair <string, object>)ObjectDataArea.Options[val]; var diabox = DialogBoxManager.dialogBoxManager; var SelectObj = ObjectClassify.SelectObj; if (keyValue.Key == "Name") { DialogStrData dataBase = new DialogStrData(keyValue.Value.ToString()); diabox.EditData("编辑值-字符串", "仪器名称", dataBase, data => { if (SelectObj == null) { throw new Exception("SelectObj为null"); } if (resourceLoad.CL_Objects.ContainsKey(data.GetValue().ToString())) { DialogBoxManager.dialogBoxManager.ShowMessage("修改错误", "名称为" + data.GetValue().ToString() + "的物体已存在,无法修改"); return; } string OldName = SelectObj.Name; string NewName = data.GetValue().ToString(); resourceLoad.CL_Objects.Remove(OldName); SelectObj.Name = NewName; resourceLoad.CL_Objects.Add(NewName, SelectObj); //修改名字时,也要把场景编辑器里的名字替换掉 var sceneEditor = resourceLoad.GetComponent <CLEditorManage>().SceneEditorManager; sceneEditor.ReNameSceneObject(OldName, NewName); ObjectClassify.LoadInfo(resourceLoad); ObjectClassify.Classify.OptionClick((int)SelectObj.Type); int nowval = ObjectClassify.Thumbnail.Options.FindIndex(s => ((CL_Object)s).Name == SelectObj.Name); ObjectClassify.Thumbnail.OptionClick(nowval); }); } else if (keyValue.Key == "Model") { List <string> temp = resourceLoad.GetPrefabsName(); List <DialogBoxDataBase> datas = new List <DialogBoxDataBase>(); foreach (var t in temp) { datas.Add(new DialogStrData(t)); } diabox.ListSelect("选择值-整数索引", "选择模型", SelectObj.Model, datas, index => { if (SelectObj == null) { throw new Exception("SelectObj为null"); } SelectObj.Model = index; resourceLoad.CL_Objects[SelectObj.Name] = SelectObj; ObjectClassify.LoadInfo(resourceLoad); ObjectClassify.Classify.OptionClick((int)SelectObj.Type); int nowval = ObjectClassify.Thumbnail.Options.FindIndex(s => ((CL_Object)s).Name == SelectObj.Name); ObjectClassify.Thumbnail.OptionClick(nowval); }); } else if (keyValue.Key == "Operations") { List <Operation> temp = resourceLoad.Operations; List <DialogBoxDataBase> totaldatas = new List <DialogBoxDataBase>(); foreach (var t in temp) { totaldatas.Add(new DialogOperationData(t)); } temp = resourceLoad.GetObjectInfoByName(SelectObj.Name).Operations; List <DialogBoxDataBase> defaultdatas = new List <DialogBoxDataBase>(); foreach (var t in temp) { defaultdatas.Add(new DialogOperationData(t)); } diabox.EditDataList("编辑值-操作数组", "操作数组", defaultdatas, totaldatas, reslist => { if (SelectObj == null) { throw new Exception("SelectObj为null"); } SelectObj.Operations.Clear(); reslist.ForEach(s => SelectObj.Operations.Add((Operation)s.GetValue())); resourceLoad.CL_Objects[SelectObj.Name] = SelectObj; ObjectClassify.LoadInfo(resourceLoad); ObjectClassify.Classify.OptionClick((int)SelectObj.Type); int nowval = ObjectClassify.Thumbnail.Options.FindIndex(s => ((CL_Object)s).Name == SelectObj.Name); ObjectClassify.Thumbnail.OptionClick(nowval); }); } else if (keyValue.Key == "Type") { string[] temp = Enum.GetNames(typeof(CL_ObjType)); List <DialogBoxDataBase> datas = new List <DialogBoxDataBase>(); foreach (var t in temp) { datas.Add(new DialogStrData(t)); } diabox.ListSelect("选择值-整数索引", "仪器类型", (int)SelectObj.Type, datas, index => { if (SelectObj == null) { throw new Exception("SelectObj为null"); } SelectObj.Type = (CL_ObjType)index; resourceLoad.CL_Objects[SelectObj.Name] = SelectObj; ObjectClassify.LoadInfo(resourceLoad); ObjectClassify.Classify.OptionClick((int)SelectObj.Type); int nowval = ObjectClassify.Thumbnail.Options.FindIndex(s => ((CL_Object)s).Name == SelectObj.Name); ObjectClassify.Thumbnail.OptionClick(nowval); }); } else if (keyValue.Key == "LiquidColor") { Color32 data = (Color32)keyValue.Value; diabox.EditColor("编辑值-颜色", keyValue.Key, data, res => { if (SelectObj == null) { throw new Exception("SelectObj为null"); } SelectObj.LiquidColor = res; resourceLoad.CL_Objects[SelectObj.Name] = SelectObj; ObjectClassify.LoadInfo(resourceLoad); ObjectClassify.Classify.OptionClick((int)SelectObj.Type); int nowval = ObjectClassify.Thumbnail.Options.FindIndex(s => ((CL_Object)s).Name == SelectObj.Name); ObjectClassify.Thumbnail.OptionClick(nowval); }); } else { DialogFloatData dataBase = new DialogFloatData((float)keyValue.Value); diabox.EditData("编辑值-浮点", keyValue.Key, dataBase, data => { if (SelectObj == null) { throw new Exception("SelectObj为null"); } var field = SelectObj.GetType().GetFields()[ObjectDataArea.Value]; field.SetValue(SelectObj, data.GetValue()); resourceLoad.CL_Objects[SelectObj.Name] = SelectObj; ObjectClassify.LoadInfo(resourceLoad); ObjectClassify.Classify.OptionClick((int)SelectObj.Type); int nowval = ObjectClassify.Thumbnail.Options.FindIndex(s => ((CL_Object)s).Name == SelectObj.Name); ObjectClassify.Thumbnail.OptionClick(nowval); }); } }