public void ChangeExistingPainterButtonColor(PainterButton painterButton, Color color) { grid.GetComponent <TileTypeLib>().RecolorTileType(painterButton, color); PainterButtons.Remove(PainterButtons.Find(x => x.name.Contains(painterButton.name))); painterButton.buttonColor = color; PainterButtons.Add(painterButton); }
public void RecolorTileType(PainterButton painterButton, Color color) { TileType tileType = GetByName(painterButton.name); tileTypes.Remove(tileTypes.Find(x => x.name.Contains(tileType.name))); tileType.color = color; tileTypes.Add(tileType); }
public void RenameTileType(PainterButton painterButton, string name) { TileType tileType = GetByName(painterButton.name); tileTypes.Remove(tileTypes.Find(x => x.name.Contains(tileType.name))); tileType.name = name; tileTypes.Add(tileType); }
public void ChangeExistingPainterButtonName(PainterButton painterButton, string name) { grid.GetComponent <TileTypeLib>().RenameTileType(painterButton, name); PainterButtons.Remove(PainterButtons.Find(x => x.name.Contains(painterButton.name))); painterButton.name = name; painterButton.displayText = name; PainterButtons.Add(painterButton); }
public void CreateNewButton() { PainterButton newButton = new PainterButton("New Painter Button", "New", Color.white); PainterButtons.Add(newButton); grid.GetComponent <TileTypeLib>().tileTypes.Add(new TileType("New Painter Button", Color.white)); SpawnPainterButton(newButton); }
private void SpawnPainterButton(PainterButton painterButton) { GameObject button = Instantiate(new GameObject(), parent, true); GameObject textObject = Instantiate(new GameObject(), button.transform, true); button.AddComponent <Button>(); button.AddComponent <Image>(); button.AddComponent <Painter>(); button.GetComponent <Image>().color = painterButton.buttonColor; button.name = painterButton.name; textObject.AddComponent <Text>(); textObject.GetComponent <Text>().font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; textObject.GetComponent <Text>().text = painterButton.displayText; textObject.GetComponent <Text>().alignment = TextAnchor.MiddleCenter; textObject.GetComponent <Text>().resizeTextForBestFit = true; textObject.GetComponent <Text>().color = Color.black; }
void Awake() { defaultButton = new PainterButton("Default", "Default", Color.white); if (PlayerPrefs.HasKey(buttonsKey)) { jsonArray = JsonHelper.FromJson <PainterButton>(PlayerPrefs.GetString(buttonsKey)); PainterButtons = jsonArray.ToList(); } else { PainterButtons.Add(new PainterButton("Grass", "Grass", Color.green)); PainterButtons.Add(new PainterButton("Water", "Water", Color.blue)); } foreach (PainterButton painterButton in PainterButtons) { if (painterButton != null) { SpawnPainterButton(painterButton); } } }