public override void OnInspectorGUI() { LevelMineGroup pElem = target as LevelMineGroup; int pId = EditorGUILayout.IntField("Id", pElem.Id); if (pElem.Id != pId) { pElem.Id = pId; pElem.SetName(); } int pMineID = EditorGUILayout.IntField("创建矿物ID", pElem.MineID); if (pMineID != pElem.MineID) { pElem.MineID = pMineID; for (int i = 0; i < pElem.Elements.Count; i++) { LevelMine mine = pElem.Elements[i]; mine.Id = pMineID; mine.SetName(); mine.Build(); } } float pRebornCD = EditorGUILayout.FloatField("矿物重生时间", pElem.RebornCD); if (pRebornCD != pElem.RebornCD) { pElem.RebornCD = pRebornCD; } if (GUILayout.Button("添加矿物")) { LevelMine pMine = pElem.AddElement(); pMine.Id = pMineID; pMine.SetName(); pMine.Build(); } EditorGUILayout.Space(); LevelRegion pRegion = (LevelRegion)EditorGUILayout.ObjectField("传送门触发器", pElem.Region, typeof(LevelRegion), true); if (pRegion != pElem.Region) { pElem.Region = pRegion; } EditorGUILayout.LabelField("使用触发器ID", pElem.RegionID.ToString()); }
private void Import() { LevelComponent levelCom = target as LevelComponent; levelCom.transform.DestroyChildren(); levelCom.InitHolder(); string fsPath = AssetUtility.GetLevelConfigAsset(levelCom.LevelID.ToString()); MapConfig data = new MapConfig(); data.EditorLoad(fsPath); levelCom.MapName = data.MapName; for (int i = 0; i < data.Regions.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Region); GameObject go = pHolder.gameObject.AddChild(); LevelRegion pRegion = go.AddComponent <LevelRegion>(); pRegion.Import(data.Regions[i], true); } for (int i = 0; i < data.Barriers.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Barrier); GameObject go = pHolder.gameObject.AddChild(); LevelBarrier pBarrier = go.AddComponent <LevelBarrier>(); pBarrier.Import(data.Barriers[i], true); } for (int i = 0; i < data.WaveSets.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.WaveSet); GameObject go = pHolder.gameObject.AddChild(); LevelWaveSet pWaveSet = go.AddComponent <LevelWaveSet>(); pWaveSet.Import(data.WaveSets[i], true); } for (int i = 0; i < data.MonsterGroups.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.MonsterGroup); GameObject go = pHolder.gameObject.AddChild(); LevelMonsterGroup pGroup = go.AddComponent <LevelMonsterGroup>(); pGroup.Import(data.MonsterGroups[i], true); } for (int i = 0; i < data.MineGroups.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.MineGroup); GameObject go = pHolder.gameObject.AddChild(); LevelMineGroup pGroup = go.AddComponent <LevelMineGroup>(); pGroup.Import(data.MineGroups[i], true); } for (int i = 0; i < data.Portals.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Portal); GameObject go = pHolder.gameObject.AddChild(); LevelPortal pPortal = go.AddComponent <LevelPortal>(); pPortal.Import(data.Portals[i], true); } for (int i = 0; i < data.Npcs.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Npc); GameObject go = pHolder.gameObject.AddChild(); LevelNpc pNpc = go.AddComponent <LevelNpc>(); pNpc.Import(data.Npcs[i], true); } { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Born); if (data.Ally != null) { GameObject gA = pHolder.gameObject.AddChild(); LevelBorn pBornA = gA.AddComponent <LevelBorn>(); pBornA.Import(data.Ally, true); } if (data.Enemy != null) { GameObject gB = pHolder.gameObject.AddChild(); LevelBorn pBornB = gB.AddComponent <LevelBorn>(); pBornB.Import(data.Enemy, true); } if (data.Neutral != null) { GameObject gC = pHolder.gameObject.AddChild(); LevelBorn pBornC = gC.AddComponent <LevelBorn>(); pBornC.Import(data.Neutral, true); } } Debug.Log("导入关卡数据:" + fsPath); }