private void drawAction(StoryActionNode action) { action.type = EditorGUILayout.TextField("类型:", action.type); action.args = EditorGUILayout.TextField("参数:", action.args); // monsters { StoryMonster[] monsters = action.Monster; if (monsters.Length > 0) { if (bShowMonsters.Count <= 0) { foreach (var monster in monsters) { bShowMonsters.Add(true); } } EditorGUILayout.BeginVertical(subGroupStyle); int removeIndex = -1; for (int i = 0; i < monsters.Length; ++i) { //bShowMonsters[i] = EditorGUILayout.Foldout(bShowMonsters[i], "Monsters(" + (i + 1) + ")"); //if (bShowMonsters[i]) EditorGUILayout.Foldout(true, "Monsters(" + (i + 1) + ")"); { EditorGUILayout.BeginVertical(subGroupStyle); var monster = monsters[i]; drawMonster(monster); EditorGUILayout.EndVertical(); } if (enableAddAndRemove && GUILayout.Button("删除这一个Monster")) { removeIndex = i; } } EditorGUILayout.EndVertical(); if (removeIndex >= 0) { var tempList = new List <StoryMonster>(monsters); tempList.RemoveAt(removeIndex); action.Monster = tempList.ToArray(); } } if (enableAddAndRemove && StyledButton("添加Monster")) { List <StoryMonster> tempActionList = new List <StoryMonster>(monsters); StoryMonster v = new StoryMonster(); tempActionList.Add(v); action.Monster = tempActionList.ToArray(); } } // photos { var photos = action.Photo; if (photos.Length > 0) { if (bShowPhotos.Count <= 0) { foreach (var photo in photos) { bShowPhotos.Add(true); } } int removeIndex = -1; EditorGUILayout.BeginVertical(subGroupStyle); for (int i = 0; i < photos.Length; ++i) { //bShowPhotos[i] = EditorGUILayout.Foldout(bShowPhotos[i], "Photos(" + (i + 1) + ")"); //if (bShowPhotos[i]) EditorGUILayout.Foldout(true, "Photos(" + (i + 1) + ")"); { EditorGUILayout.BeginVertical("GroupBox"); var photo = photos[i]; drawPhotos(photo); EditorGUILayout.EndVertical(); } if (enableAddAndRemove && GUILayout.Button("删除这个Photo")) { removeIndex = i; } } EditorGUILayout.EndVertical(); if (removeIndex >= 0) { var tempList = new List <PhotoVo>(photos); tempList.RemoveAt(removeIndex); action.Photo = tempList.ToArray(); } } if (enableAddAndRemove && StyledButton("添加Photo")) { List <PhotoVo> tempActionList = new List <PhotoVo>(photos); PhotoVo v = new PhotoVo(); tempActionList.Add(v); action.Photo = tempActionList.ToArray(); } } // talks { var talks = action.Talk; if (talks.Length > 0) { if (bShowTalks.Count <= 0) { foreach (var talk in talks) { bShowTalks.Add(true); } } int removeIndex = -1; EditorGUILayout.BeginVertical(subGroupStyle); for (int i = 0; i < talks.Length; ++i) { //bShowTalks[i] = EditorGUILayout.Foldout(bShowTalks[i], "Talks(" + (i + 1) + ")"); //if (bShowTalks[i]) EditorGUILayout.Foldout(true, "Talks(" + (i + 1) + ")"); { EditorGUILayout.BeginVertical("GroupBox"); var talk = talks[i]; drawTalk(talk); EditorGUILayout.EndVertical(); } if (enableAddAndRemove && GUILayout.Button("删除这个Talk")) { removeIndex = i; } } EditorGUILayout.EndVertical(); if (removeIndex >= 0) { var tempList = new List <TalkVo>(talks); tempList.RemoveAt(removeIndex); action.Talk = tempList.ToArray(); } } if (enableAddAndRemove && StyledButton("添加Talk")) { List <TalkVo> tempActionList = new List <TalkVo>(talks); TalkVo v = new TalkVo(); tempActionList.Add(v); action.Talk = tempActionList.ToArray(); } } // NPCTalks { var npcTalks = action.NpcTalk; if (npcTalks.Length > 0) { if (bShowNPCTalks.Count <= 0) { foreach (var v in npcTalks) { bShowNPCTalks.Add(true); } } int removeIndex = -1; EditorGUILayout.BeginVertical(subGroupStyle); for (int i = 0; i < npcTalks.Length; ++i) { //bShowNPCTalks[i] = EditorGUILayout.Foldout(bShowNPCTalks[i], "NPCTalks(" + (i+1)+ ")"); //if (bShowNPCTalks[i]) EditorGUILayout.Foldout(true, "NPCTalks(" + (i + 1) + ")"); { EditorGUILayout.BeginVertical("GroupBox"); drawNPCTalk(npcTalks[i]); EditorGUILayout.EndVertical(); } if (enableAddAndRemove && GUILayout.Button("删除这个NpcTalk")) { removeIndex = i; } } EditorGUILayout.EndVertical(); if (removeIndex >= 0) { var tempList = new List <NpcTalkVo>(npcTalks); tempList.RemoveAt(removeIndex); action.NpcTalk = tempList.ToArray(); } } if (enableAddAndRemove && StyledButton("添加NpcTalk")) { List <NpcTalkVo> tempActionList = new List <NpcTalkVo>(npcTalks); NpcTalkVo v = new NpcTalkVo(); tempActionList.Add(v); action.NpcTalk = tempActionList.ToArray(); } } }
private void drawSteps() { var steps = currenStory.step; if (bShowSteps.Count <= 0) { foreach (var step in steps) { bShowSteps.Add(true); } } EditorGUILayout.BeginVertical(rootGroupStyle); int removeIndex = -1; stepListScrollPos = EditorGUILayout.BeginScrollView(stepListScrollPos); for (int i = 0; i < steps.Length; ++i) { EditorGUILayout.BeginVertical(subGroupStyle); StoryXMLNode stepNode = steps[i]; using (var h = new EditorGUILayout.HorizontalScope()) { bShowSteps[i] = EditorGUILayout.Foldout(bShowSteps[i], "步骤(" + (i + 1) + ")"); stepNode.lastTime = EditorGUILayout.FloatField("步骤结束时间:", stepNode.lastTime); } var actions = stepNode.node; if (bShowSteps[i]) { int removeActionIndex = -1; for (int j = 0; j < actions.Length; ++j) { EditorGUILayout.BeginVertical(subGroupStyle); var action = actions[j]; drawAction(action); if (enableAddAndRemove && GUILayout.Button("删除这个Action")) { removeActionIndex = j; } EditorGUILayout.EndVertical(); } if (removeActionIndex >= 0) { List <StoryActionNode> tempActionList = new List <StoryActionNode>(actions); tempActionList.RemoveAt(removeActionIndex); stepNode.node = tempActionList.ToArray(); } } using (var h = new EditorGUILayout.HorizontalScope()) { if (enableAddAndRemove && GUILayout.Button("添加Action")) { List <StoryActionNode> tempActionList = new List <StoryActionNode>(actions); StoryActionNode action = new StoryActionNode(); tempActionList.Add(action); stepNode.node = tempActionList.ToArray(); } if (enableAddAndRemove && GUILayout.Button("删除这一步骤")) { removeIndex = i; } } EditorGUILayout.EndVertical(); } if (removeIndex >= 0) { List <StoryXMLNode> tempList = new List <StoryXMLNode>(steps); tempList.RemoveAt(removeIndex); currenStory.step = tempList.ToArray(); bShowSteps.Clear(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }