コード例 #1
0
    public void ShowEndMenu(GameObject parent, float panelX, float panelY, Sprite panelImage, float buttonSize, float offset,
                            Sprite retryImage, Sprite menuImage)
    {
        endMenuPanel = guiScript.CreatePanel(parent, "EndMenuPanel", new Vector2(0.5f, 1), new Vector2(0.5f, 1),
                                             new Vector2(0.5f, 1), new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(panelX, panelY),
                                             new Vector2(0, -offset), panelImage, new Color32(255, 255, 255, 0));
        guiScript.CreateText(endMenuPanel, "EndText", new Vector2(0.5f, 1), new Vector2(0.5f, 1), new Vector2(0.5f, 1),
                             new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(panelX, panelY * 0.5f), new Vector2(0, 0), "GAME OVER",
                             new Color32(0, 0, 0, 255));
        endMenuButton = guiScript.CreateButton(endMenuPanel, "MenuButton", new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0),
                                               new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(buttonSize, buttonSize),
                                               new Vector2(-0.55f * buttonSize, 0.1f * buttonSize), menuImage, new Color32(255, 255, 255, 255));
        endRetryButton = guiScript.CreateButton(endMenuPanel, "RetryButton", new Vector2(0.5f, 0), new Vector2(0.5f, 0),
                                                new Vector2(0.5f, 0), new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(buttonSize, buttonSize),
                                                new Vector2(0.55f * buttonSize, 0.1f * buttonSize), retryImage, new Color32(255, 255, 255, 255));

        endMenuButton.GetComponent <Button>().onClick.AddListener(delegate
        {
            Destroy(SettingsScript.instance.gameObject);
            SceneManager.LoadScene("MenuScene");
        });
        endRetryButton.GetComponent <Button>().onClick.AddListener(delegate { SceneManager.LoadScene(SceneManager.GetActiveScene().name); });
    }