Some more work on theme selection
This commit is contained in:
@@ -8,6 +8,9 @@ public class SpellingBeeThemeSelectionController : MonoBehaviour {
|
||||
public Button buttonPrefab;
|
||||
public Transform parentTransform;
|
||||
|
||||
private int buttonHeight = 140;
|
||||
private int buttonWidth = 600;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -26,6 +29,13 @@ public class SpellingBeeThemeSelectionController : MonoBehaviour {
|
||||
// Then, add the button component to the game object
|
||||
Button buttonComponent = newButton.AddComponent<Button>();
|
||||
|
||||
GameObject colorBox = new GameObject("Letter box");
|
||||
colorBox.transform.SetParent(newButton.transform);
|
||||
Image background = colorBox.AddComponent<Image>();
|
||||
background.rectTransform.sizeDelta = new Vector2(buttonWidth, buttonHeight);
|
||||
background.color = Color.black;
|
||||
background.sprite = UnityEditor.AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/UIMask.psd");
|
||||
|
||||
// Set the position of the button game object
|
||||
|
||||
// Create the text game object
|
||||
@@ -42,12 +52,13 @@ public class SpellingBeeThemeSelectionController : MonoBehaviour {
|
||||
textComponent.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
// Set the text content and font size
|
||||
textComponent.color = new Color(50, 50, 50);
|
||||
textComponent.text = theme.name;
|
||||
textComponent.rectTransform.sizeDelta = new Vector2(300, 120);
|
||||
textComponent.rectTransform.sizeDelta = new Vector2(buttonWidth, buttonHeight);
|
||||
|
||||
// Set the parent of the text game object to the button game object
|
||||
textComponent.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||
textComponent.fontSize = 42;
|
||||
textComponent.fontSize = 36;
|
||||
buttonComponent.onClick.AddListener(() => OnButtonClick(theme.name));
|
||||
|
||||
// Set the size and position of the text game object
|
||||
|
||||
Reference in New Issue
Block a user