void GUI_Wall() { EditorGUILayout.BeginVertical(style_box_marginleft); foreach (KeyValuePair <int, BuildWallConfig> kvp in War.model.buildWallConfigs) { BuildWallConfig wallConfig = kvp.Value; GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); GUILayout.Label(wallConfig.id + "", style_label_wall_id, GUILayout.Width(50), GUILayout.Height(100)); AvatarConfig avatarConfig = Goo.avatar.GetConfig(wallConfig.avatarId); GameObject prefab = null; if (avatarConfig != null) { prefab = WarRes.GetPrefab(avatarConfig.model); } if (prefab) { SpriteAvatar spriteAvatar = prefab.GetComponent <SpriteAvatar>(); Sprite sprite = spriteAvatar.avatarData.avatarActions[0].GetSpriteAnimationClip(wallConfig.angle).frames[0]; Texture2D tex = null; if (!wall_icon_dict.TryGetValue(sprite, out tex)) { tex = new Texture2D((int)sprite.rect.width, (int)sprite.rect.height, TextureFormat.RGBA32, false); Color[] pixels = sprite.texture.GetPixels((int)sprite.rect.xMin, (int)sprite.rect.yMin, (int)sprite.rect.width, (int)sprite.rect.height); tex.SetPixels(pixels); tex.Apply(); wall_icon_dict.Add(sprite, tex); } if (GUILayout.Button(tex, GUILayout.Width(100), GUILayout.Height(100))) { Click_Wall(wallConfig); } } else { GUILayout.Button("没有资源", GUILayout.Width(100), GUILayout.Height(100)); if (avatarConfig != null) { WarEditor.LoadRes(avatarConfig.model); } } GUILayout.Label(wallConfig.name, style_label_wall_line, GUILayout.Width(100), GUILayout.Height(100)); GUILayout.Label(wallConfig.wallType == WallType.Cube ? "立方体" : "球", style_label_wall_line, GUILayout.Width(50), GUILayout.Height(100)); if (wallConfig.wallType == WallType.Cube) { GUILayout.Label("角度:" + wallConfig.angle, style_label_wall_line, GUILayout.Width(100), GUILayout.Height(100)); GUILayout.Label("大小:" + wallConfig.size.x + "x" + wallConfig.size.z, style_label_wall_line, GUILayout.Width(100), GUILayout.Height(100)); } else { GUILayout.Label("半径:" + wallConfig.radius, style_label_wall_line, GUILayout.Width(100), GUILayout.Height(100)); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } EditorGUILayout.EndVertical(); }
void Init() { prefab = WarRes.GetPrefab(WarRes.Unit_Hun); }
void GUI_Build(int buildTypeValue, string name) { EditorGUILayout.BeginVertical(style_box_marginleft); buildSwitchs[buildTypeValue] = GUILayout.Toggle(buildSwitchs[buildTypeValue], name, style_label_type, GUILayout.ExpandWidth(true)); if (buildSwitchs[buildTypeValue]) { GUIContent iconContent = new GUIContent(""); GUILayout.BeginHorizontal(iconContent, style_box_key); int column = 0; for (int i = 0; i < colorEnables.Length; i++) { if (colorEnables[i]) { GUILayout.Space(10); GUILayout.Label(colorNames[i], style_box_key, GUILayout.Width(100), GUILayout.Height(18)); GUILayout.Space(10); column++; } } GUILayout.EndHorizontal(); foreach (KeyValuePair <int, BuildConfig> kvp in War.model.buildConfigs) { BuildConfig buildConfig = kvp.Value; if ((int)buildConfig.buildType != buildTypeValue + 1) { continue; } GUILayout.Space(20); foreach (KeyValuePair <int, BuildLevelConfig> levelKVP in buildConfig.levels) { BuildLevelConfig levelConfig = levelKVP.Value; if (levelEnables[levelConfig.level - 1] == false) { continue; } EditorGUILayout.BeginHorizontal(GUILayout.Width(column * 120)); for (int i = 0; i < colorEnables.Length; i++) { if (colorEnables[i]) { AvatarConfig avatarConfig = Goo.avatar.GetConfig(levelConfig.avatarId); string file = avatarConfig.GetModelPath(colorIds[i]); GameObject prefab = WarRes.GetPrefab(file); if (prefab) { GUILayout.Space(10); EditorGUILayout.BeginVertical(); SpriteAvatar spriteAvatar = prefab.GetComponent <SpriteAvatar>(); Sprite sprite = spriteAvatar.avatarData.avatarActions[0].clips[0].frames[0]; if (GUILayout.Button(sprite.texture, GUILayout.Width(100), GUILayout.Height(100))) { Click_Build(colorIds[i], levelConfig.level, buildConfig); } GUILayout.Label(buildConfig.id + " " + levelConfig.name, style_label_icon_hasbg, GUILayout.Width(100)); if (levelConfig.basepropId > 0) { GUILayout.Label("<color=#55AAAA><b>#" + levelConfig.basepropId + " 基本属性</b></color>", style_label_prop); foreach (Prop prop in levelConfig.basepropConfig.props) { GUILayout.Label("<color=#88AAAA>" + prop.id + " " + prop.Name + ":" + prop.ValueStr + "</color>", style_label_prop, GUILayout.Width(150)); } } if (levelConfig.produceId > 0) { GUILayout.Space(5); GUILayout.Label("<color=#55AA55><b>#" + levelConfig.produceId + " 生产属性</b></color>", style_label_prop); foreach (Prop prop in levelConfig.produceConfig.props) { GUILayout.Label("<color=#88AA88>" + prop.id + " " + prop.Name + ":" + prop.ValueStr + "</color>", style_label_prop, GUILayout.Width(150)); } } if (levelConfig.turretId > 0) { GUILayout.Space(5); GUILayout.Label("<color=#AA5555><b>#" + levelConfig.turretId + " 箭塔属性</b></color>", style_label_prop); foreach (Prop prop in levelConfig.turretConfig.props) { GUILayout.Label("<color=#AA8888>" + prop.id + " " + prop.Name + ":" + prop.ValueStr + "</color>", style_label_prop, GUILayout.Width(150)); } } if (levelConfig.spotId > 0) { GUILayout.Space(5); GUILayout.Label("<color=#5555AA><b>#" + levelConfig.spotId + " 据点属性</b></color>", style_label_prop); foreach (Prop prop in levelConfig.spotConfig.props) { GUILayout.Label("<color=#8888AA>" + prop.id + " " + prop.Name + ":" + prop.ValueStr + "</color>", style_label_prop, GUILayout.Width(150)); } } EditorGUILayout.EndVertical(); GUILayout.Space(10); } else { GUILayout.Space(10); GUILayout.Button("没有资源", GUILayout.Width(100), GUILayout.Height(100)); GUILayout.Space(10); WarEditor.LoadRes(file); } } } EditorGUILayout.EndHorizontal(); } GUILayout.Space(20); } } EditorGUILayout.EndVertical(); }