public override void OnCreateGUI() { String[] resources = new String[] { "Metal", "Gold", "Silicon", "CPU", "Power", "TileHP", "Water", "Research" }; ScrollView view = new ScrollView(); GUIStyle captionStyle = new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }; foreach (EntityCost cost in Costs.GetEntityCosts()) { if (!_fields.ContainsKey(cost.Internal_Name)) { _fields[cost.Internal_Name] = new List <TextField>(); } Group costGroup = new Group(GUIItem.Direction.Vertical) { Tag = cost.Internal_Name }; costGroup.Items.Add(new Label(cost.Name) { Style = captionStyle }); foreach (String resource in resources) { Group resGroup = new Group(GUIItem.Direction.Horizontal); resGroup.Items.Add(new Label(resource == "TileHP" ? "Structure" : resource)); TextField resField = new TextField(cost.GetCost(resource).ToString()) { Tag = resource, MaxWidth = 200 }; _fields[cost.Internal_Name].Add(resField); resField.TextChanged += ResField_TextChanged; resGroup.Items.Add(resField); costGroup.Items.Add(resGroup); } Button resBtn = new Button("Save") { Tag = costGroup }; resBtn.Clicked += ResBtn_Clicked; costGroup.Items.Add(resBtn); view.Items.Add(costGroup); } ModWindow.Rect = new Rect(ModWindow.Rect.x, ModWindow.Rect.y, ModWindow.Rect.width, 200); ModWindow.Items.Add(view); }
private void GameEvents_GameSaved(object sender, Events.GameEvents.SaveLoadEventArgs e) { ES2.Save <EntityCost>(Costs.GetEntityCosts(), e.savePath + "?tag=CostTweaking_Costs"); }