Some more work on theme selection
This commit is contained in:
@@ -912,8 +912,8 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 1768150802}
|
m_GameObject: {fileID: 1768150802}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 44fbed5ae228de39b9f727def7578d06, type: 3}
|
m_Script: {fileID: 11500000, guid: 68caaa5508a4d40448b47630ff86f035, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
image: {fileID: 0}
|
buttonPrefab: {fileID: 0}
|
||||||
input: {fileID: 0}
|
parentTransform: {fileID: 0}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ public class SpellingBeeThemeSelectionController : MonoBehaviour {
|
|||||||
public Button buttonPrefab;
|
public Button buttonPrefab;
|
||||||
public Transform parentTransform;
|
public Transform parentTransform;
|
||||||
|
|
||||||
|
private int buttonHeight = 140;
|
||||||
|
private int buttonWidth = 600;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -26,6 +29,13 @@ public class SpellingBeeThemeSelectionController : MonoBehaviour {
|
|||||||
// Then, add the button component to the game object
|
// Then, add the button component to the game object
|
||||||
Button buttonComponent = newButton.AddComponent<Button>();
|
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
|
// Set the position of the button game object
|
||||||
|
|
||||||
// Create the text game object
|
// Create the text game object
|
||||||
@@ -42,12 +52,13 @@ public class SpellingBeeThemeSelectionController : MonoBehaviour {
|
|||||||
textComponent.alignment = TextAnchor.MiddleCenter;
|
textComponent.alignment = TextAnchor.MiddleCenter;
|
||||||
|
|
||||||
// Set the text content and font size
|
// Set the text content and font size
|
||||||
|
textComponent.color = new Color(50, 50, 50);
|
||||||
textComponent.text = theme.name;
|
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
|
// Set the parent of the text game object to the button game object
|
||||||
textComponent.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
textComponent.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||||
textComponent.fontSize = 42;
|
textComponent.fontSize = 36;
|
||||||
buttonComponent.onClick.AddListener(() => OnButtonClick(theme.name));
|
buttonComponent.onClick.AddListener(() => OnButtonClick(theme.name));
|
||||||
|
|
||||||
// Set the size and position of the text game object
|
// Set the size and position of the text game object
|
||||||
|
|||||||
Reference in New Issue
Block a user