private void CreatePremiseBtn(NodePremiseJson premiseJson) { if (premiseJson == null) { return; } EDButton.CreateBtn("(" + premiseJson.TrueValue.ToString() + ")" + premiseJson.Name + "(" + premiseJson.Type.ToString() + ")", 250, 40, () => { EDPopMenu.CreatePopMenu(new List <string> { "删除前提", "改变真值" }, (int sel) => { if (sel == 0) { RemovePremise(premiseJson); } if (sel == 1) { premiseJson.TrueValue = !premiseJson.TrueValue; } }); }); if (premiseJson.OtherPremise != null) { CreatePremiseBtn(premiseJson.OtherPremise); } }
private void DrawAnimList(float width, float height) { if (SelSkill == null) { return; } EDLayout.CreateVertical("", width, height, (float wid, float hei) => { if (SelSkill.AnimClips.Count != 0) { EDLayout.CreateScrollView(ref animPos, "box", wid, hei * 0.7f, (float wid01, float hei01) => { //动画列表 for (int i = 0; i < SelSkill.AnimClips.Count; i++) { int selIndex = i; if (CheckAnimatorHasClip(SelAnim, SelSkill.AnimClips[i].AnimName)) { EDLayout.CreateHorizontal("box", 210, 30, (float wid02, float hei02) => { EDTypeField.CreateLableField(string.Format("动画名:{0}", SelSkill.AnimClips[i].AnimName), "", wid02 * 0.7f, hei02); EDButton.CreateBtn("删除动画", wid02 * 0.3f, hei02, () => { SelSkill.AnimClips.RemoveAt(selIndex); UpdateAnimClipsTime(); }); }); } else { SelSkill.AnimClips.RemoveAt(selIndex); UpdateAnimClipsTime(); } } }); } //添加动画 if (RunningClip.Count == 0) { return; } List <string> showClips = new List <string>(); for (int i = 0; i < RunningClip.Count; i++) { showClips.Add(RunningClip[i].name); } EDButton.CreateBtn("添加动画", 180, 25, () => { EDPopMenu.CreatePopMenu(showClips, (string str) => { SkillAnimJson animJson = new SkillAnimJson(); animJson.AnimName = str; SelSkill.AnimClips.Add(animJson); UpdateAnimClipsTime(); }); }); }); }
private void ShowSystemList(bool isUpdate, float width) { List <SortJson> sorts = isUpdate == true ? MSystemSortJson.UpdateList : MSystemSortJson.FixedUpdateList; sorts.Sort((left, right) => { if (left.Sort == right.Sort) { return(0); } else if (left.Sort < right.Sort) { return(-1); } else { return(1); } }); for (int i = 0; i < sorts.Count; i++) { string sysName = sorts[i].TypeName; string showName = sysName + string.Format("({0})", sorts[i].Sort); EDButton.CreateBtn(showName, width, 30, () => { EDPopMenu.CreatePopMenu(new List <string>() { "上升", "下降" }, (int sel) => { if (sel == 0) { UPSystem(sysName, isUpdate); } else if (sel == 1) { DOWNSystem(sysName, isUpdate); } }); }); } }
//实体编辑界面 private void ShowSelEntityWindow(float width) { //基础配置只读 EDTypeField.CreateLableField("实体名:", SelEntity.EntityName, width, 20); object tipobj = SelEntity.TipStr; EDTypeField.CreateTypeField("描述信息:", ref tipobj, typeof(string), width, 20); SelEntity.TipStr = tipobj.ToString(); //决策分组 SelEntity.Group = (EntityDecGroup)EditorGUILayout.EnumPopup("实体决策分组", SelEntity.Group); EditorGUILayout.Space(); //预制体路径 EditorGUILayout.LabelField("选择预制体:"); GameObject prefab = null; prefab = EditorGUILayout.ObjectField(prefab, typeof(GameObject), false) as GameObject; if (prefab != null) { SelEntity.PrefabPath = AssetDatabase.GetAssetPath(prefab); } EditorGUILayout.LabelField("预制体路径:"); EditorGUILayout.LabelField(SelEntity.PrefabPath, "", "box"); EditorGUILayout.Space(); //组件列表 EditorGUILayout.LabelField("组件列表:"); EDLayout.CreateScrollView(ref ComListPos, "box", width, 150, () => { for (int i = 0; i < SelEntity.Coms.Count; i++) { //按钮名 string btnName = SelEntity.Coms[i].ComName; Type comType = LCReflect.GetType(SelEntity.Coms[i].ComName); if (comType != null) { ComAttribute comAttribute = LCReflect.GetTypeAttr <ComAttribute>(comType); if (comAttribute != null) { btnName = comAttribute.ViewName; } } else { SelEntity.Coms.RemoveAt(i); continue; } EDButton.CreateBtn(btnName, width * 0.8f, 20, () => { int comIndex = i; EDPopMenu.CreatePopMenu(new List <string>() { "编辑组件", "删除组件" }, (int index) => { if (index == 0) { SelCom = LCReflect.GetType(SelEntity.Coms[comIndex].ComName); } else if (index == 1) { SelEntity.Coms.RemoveAt(comIndex); } }); }); EditorGUILayout.Space(); } }); //添加组件 EDButton.CreateBtn("添加组件", 200, 50, () => { List <Type> comTyps = LCReflect.GetClassByType <BaseCom>(); List <string> showList = new List <string>(); List <Type> showTyps = new List <Type>(); for (int j = 0; j < comTyps.Count; j++) { if (CheckContainCom(comTyps[j].FullName)) { continue; } showTyps.Add(comTyps[j]); ComAttribute comAttribute = LCReflect.GetTypeAttr <ComAttribute>(comTyps[j]); if (comAttribute != null) { if (comAttribute.GroupName == "") { comAttribute.GroupName = "Default"; } showList.Add(comAttribute.GroupName + "/" + comAttribute.ViewName); } else { showList.Add(comTyps[j].FullName); } } EDPopMenu.CreatePopMenu(showList, (int index) => { Type comType = showTyps[index]; if (CheckContainCom(comType.FullName)) { Debug.LogError("重复的组件>>>>>>>>" + comType.FullName); return; } EntityComJson comJson = new EntityComJson() { ComName = comType.FullName, }; SelEntity.Coms.Add(comJson); }); }); //保存配置 EDButton.CreateBtn("保存配置", 200, 50, SaveEntityJsonList); //删除实体 EDButton.CreateBtn("删除实体", 200, 30, () => { EDDialog.CreateDialog("删除", "确认删除该实体吗?", (() => { MEntityJsonList.List.Remove(SelEntity); SelEntityChange(null); })); }); }
private void DrawPopMenu() { List <string> showStrs = new List <string>() { "连接父节点", "删除节点", "删除连接", }; //前提条件 List <Type> premiseTypes = LCReflect.GetClassByType <NodePremise>(); List <Type> premiseShowTypes = new List <Type>(); for (int i = 0; i < premiseTypes.Count; i++) { if (GetPremise(premiseTypes[i].FullName, Json.Premise) != null) { continue; } NodePremiseAttribute nodeAttribute = LCReflect.GetTypeAttr <NodePremiseAttribute>(premiseTypes[i]); if (nodeAttribute == null || nodeAttribute.GroupName == "") { showStrs.Add("添加前提/默认前提/" + nodeAttribute.ViewName); premiseShowTypes.Add(premiseTypes[i]); } else { showStrs.Add("添加前提/" + nodeAttribute.GroupName + "/" + nodeAttribute.ViewName); premiseShowTypes.Add(premiseTypes[i]); } } EDPopMenu.CreatePopMenu(showStrs, (int index) => { Debug.Log("CreatePopMenu》》" + index); if (index == 2 && ParEditor == null) { Debug.Log("没有父节点》》无法删除!!"); return; } if (index == 0 && ParEditor != null) { Debug.Log("已经有父节点》》无法连接!!"); return; } if (index <= 2) { CallBack(index, this); } else { index = index - 3; NodePremiseJson nullPremise = GetNullPremise(Json.Premise); string viewName = ""; Type premiseType = premiseShowTypes[index]; NodePremiseAttribute nodeAttribute = LCReflect.GetTypeAttr <NodePremiseAttribute>(premiseType); if (nodeAttribute == null) { viewName = premiseType.FullName; } else { viewName = nodeAttribute.ViewName; } NodePremiseJson addJson = new NodePremiseJson(); addJson.Name = viewName; addJson.Type = Core.Tree.PremiseType.AND; addJson.TypeFullName = premiseType.FullName; if (nullPremise == null) { Json.Premise = addJson; } else { nullPremise.OtherPremise = addJson; } } }); }
private void ShowCreateNodeMenu() { List <string> showStrs = new List <string>(); //控制节点 List <Type> controlTypes = LCReflect.GetClassByType <NodeControl>(); for (int i = 0; i < controlTypes.Count; i++) { NodeAttribute nodeAttribute = LCReflect.GetTypeAttr <NodeAttribute>(controlTypes[i]); if (nodeAttribute != null) { showStrs.Add("控制节点/" + nodeAttribute.ViewName); } else { showStrs.Add("控制节点/" + controlTypes[i].FullName); } } //行为节点 List <Type> actionTypes = LCReflect.GetClassByType <NodeAction>(); List <Type> actionShowTypes = new List <Type>(); for (int i = 0; i < actionTypes.Count; i++) { NodeAttribute nodeAttribute = LCReflect.GetTypeAttr <NodeAttribute>(actionTypes[i]); if (nodeAttribute == null) { showStrs.Add("基础行为节点/" + nodeAttribute.ViewName); actionShowTypes.Add(actionTypes[i]); } else { if (nodeAttribute.IsCommonAction) { showStrs.Add("基础行为/" + nodeAttribute.ViewName); actionShowTypes.Add(actionTypes[i]); } else { if (ShowDec) { if (nodeAttribute.IsBevNode == false) { showStrs.Add("扩展行为/" + nodeAttribute.ViewName); actionShowTypes.Add(actionTypes[i]); } } else { if (nodeAttribute.IsBevNode) { showStrs.Add("扩展行为/" + nodeAttribute.ViewName); actionShowTypes.Add(actionTypes[i]); } } } } } EDPopMenu.CreatePopMenu(showStrs, (int index) => { Debug.Log("创建节点》》》》》》》》》" + index + " " + controlTypes.Count + " >>" + actionShowTypes.Count); //创建控制 if (index <= controlTypes.Count - 1) { NodeDataJson node = CreateNodeJson(NodeType.Control, controlTypes[index].FullName, showStrs[index], curMousePos); //创建显示 NodeEditor nodeEditor = new NodeEditor(new Rect(new Vector2((float)node.PosX, (float)node.PosY), new Vector2(200, 100)), node, null, NodeEventCallBack); showNodeEditor.Add(nodeEditor); GUI.changed = true; } //创建行为 else { Debug.Log("创建行为节点》》》》》》》》》" + (index - controlTypes.Count)); NodeDataJson node = CreateNodeJson(NodeType.Action, actionShowTypes[index - controlTypes.Count].FullName, showStrs[index], curMousePos); //创建显示 NodeEditor nodeEditor = new NodeEditor(new Rect(new Vector2((float)node.PosX, (float)node.PosY), new Vector2(200, 100)), node, null, NodeEventCallBack); showNodeEditor.Add(nodeEditor); GUI.changed = true; } }); }