Some more work on theme selection

This commit is contained in:
lvrossem
2023-03-02 15:24:34 +01:00
parent 49b91f062e
commit 359b1db905
2 changed files with 16 additions and 5 deletions

View File

@@ -912,8 +912,8 @@ MonoBehaviour:
m_GameObject: {fileID: 1768150802}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 44fbed5ae228de39b9f727def7578d06, type: 3}
m_Script: {fileID: 11500000, guid: 68caaa5508a4d40448b47630ff86f035, type: 3}
m_Name:
m_EditorClassIdentifier:
image: {fileID: 0}
input: {fileID: 0}
buttonPrefab: {fileID: 0}
parentTransform: {fileID: 0}

View File

@@ -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