public override void OnInspectorGUI() { HolderBorn pHolder = target as HolderBorn; EditorGUILayout.Space(); EditorGUILayout.LabelField("出生点设置"); BattleCampType pCamp = (BattleCampType)EditorGUILayout.EnumPopup("选择出生阵营", pHolder.Camp); if (pCamp != pHolder.Camp) { pHolder.Camp = pCamp; } if (GUILayout.Button("添加出生点")) { pHolder.AddElement(); } }
private MapConfig Export() { LevelComponent pHandler = target as LevelComponent; MapConfig data = new MapConfig(); data.Id = pHandler.LevelID; data.MapName = pHandler.MapName; data.MapPath = pHandler.MapPath; List <LevelElement> pList = new List <LevelElement>(); for (int i = 0; i < pHandler.transform.childCount; i++) { Transform child = pHandler.transform.GetChild(i); LevelElement pElem = child.GetComponent <LevelElement>(); if (pElem) { pList.Add(pElem); } } for (int k = 0; k < pList.Count; k++) { string classType = pList[k].GetType().Name; LevelElement current = pList[k]; switch (classType) { case "HolderBorn": { HolderBorn pHolder = current as HolderBorn; if (pHolder != null) { for (int i = 0; i < pHolder.Elements.Count; i++) { LevelElement pElem = pHolder.Elements[i]; switch (pHolder.Elements[i].Camp) { case BattleCampType.Ally: data.Ally = pElem.Export() as MapBorn; break; case BattleCampType.Enemy: data.Enemy = pElem.Export() as MapBorn; break; case BattleCampType.Neutral: data.Neutral = pElem.Export() as MapBorn; break; } } } } break; case "HolderBarrier": { HolderBarrier pHolder = current as HolderBarrier; if (pHolder != null) { for (int i = 0; i < pHolder.Elements.Count; i++) { LevelElement pElem = pHolder.Elements[i]; data.Barriers.Add(pElem.Export() as MapBarrier); } } } break; case "HolderPortal": { HolderPortal pHolder = current as HolderPortal; if (pHolder != null) { for (int i = 0; i < pHolder.Elements.Count; i++) { LevelElement pElem = pHolder.Elements[i]; data.Portals.Add(pElem.Export() as MapPortal); } } } break; case "HolderRegion": { HolderRegion pHolder = current as HolderRegion; if (pHolder != null) { for (int i = 0; i < pHolder.Elements.Count; i++) { LevelElement pElem = pHolder.Elements[i]; data.Regions.Add(pElem.Export() as MapRegion); } } } break; case "HolderWaveSet": { HolderWaveSet pHolder = current as HolderWaveSet; if (pHolder != null) { for (int i = 0; i < pHolder.Elements.Count; i++) { LevelElement pElem = pHolder.Elements[i]; data.WaveSets.Add(pElem.Export() as MapWaveSet); } } } break; case "HolderMonsterGroup": { HolderMonsterGroup pHolder = current as HolderMonsterGroup; if (pHolder != null) { for (int i = 0; i < pHolder.Elements.Count; i++) { LevelElement pElem = pHolder.Elements[i]; data.MonsterGroups.Add(pElem.Export() as MapMonsterGroup); } } } break; case "HolderMineGroup": { HolderMineGroup pHolder = current as HolderMineGroup; if (pHolder != null) { for (int i = 0; i < pHolder.Elements.Count; i++) { LevelElement pElem = pHolder.Elements[i]; data.MineGroups.Add(pElem.Export() as MapMineGroup); } } } break; case "HolderNpc": { HolderNpc pHolder = current as HolderNpc; if (pHolder != null) { for (int i = 0; i < pHolder.Elements.Count; i++) { LevelElement pElem = pHolder.Elements[i]; data.Npcs.Add(pElem.Export() as MapNpc); } } } break; } } return(data); }