コード例 #1
0
    public void SetDialog(string title, string text, string buttonText, bool pause, bool endGame, GameObject prefab = null)
    {
        if (prefab != null)
        {
            guiCamera      = (GameObject)Instantiate(guiCameraPrefab, Vector3.zero, Quaternion.identity);
            guiCameraLight = (GameObject)Instantiate(guiCameraLightPrefab, Vector3.zero, Quaternion.identity);
            renderObject   = (GameObject)Instantiate(prefab, guiCamera.transform.position + guiCamera.transform.forward * 32, Quaternion.identity);
            renderObject.transform.Translate(guiCamera.transform.up * -9);
            Building b = renderObject.GetComponent <Building>();
            if (b != null)
            {
                text = text + "\n\n" + b.StatsText();
            }
            //renderObject.transform.Rotate(100, 0, 0);
            timestamp = System.DateTime.Now;
            dialogImage.Parent.Show();
            dialogImage.Show();
        }
        else
        {
            dialogImage.Parent.Hide();
            dialogImage.Hide();
        }

        dialogTitle.Text  = title;
        dialogText.Text   = text;
        dialogButton.Text = buttonText;


        dialogButton.Focus();
        //show the dialog and pause time if desired
        dialogPanel.Show();
        if (pause)
        {
            Time.timeScale = 0;
        }
        this.endGame = endGame;
    }