Exemple #1
0
    /* Здесь такое вроде не нужно будет
     * public void SetOnClickListener(Predicate<string> onClickAction)
     * {
     *  button.onClick.AddListener(delegate { onClickAction(inputField.text); });
     * }
     */
    public void ShowDialog(string[] elements, string buttonText = "Ok")
    {
        TileEditor te = GameObject.FindObjectOfType <TileEditor>();

        if (te != null)
        {
            te.SetDefault();
        }
        TilePlacer tp = GameObject.FindObjectOfType <TilePlacer>();

        if (tp != null)
        {
            tp.CancelPlacing();
        }

        dialogCanvas.SetActive(true);
        scrollRect.content.sizeDelta        = new Vector2(0, 17 * elements.Length);
        contentText.rectTransform.sizeDelta = new Vector2(160 * 4, 16 * 5 * elements.Length);
        contentText.text = "";
        foreach (string elem in elements)
        {
            contentText.text += elem + "\n";
        }
        button.GetComponentInChildren <Text>().text = buttonText;
    }
Exemple #2
0
    public UIInputBox(Vector2 position)
    {
        TileEditor te = GameObject.FindObjectOfType <TileEditor>();

        te.SetDefault();
        TilePlacer tp = GameObject.FindObjectOfType <TilePlacer>();

        tp.CancelPlacing();

        dialogCanvas = GameObject.Instantiate(Resources.Load("Prefabs/InputBoxPrefab")) as GameObject;
        dialogCanvas.transform.position = new Vector3(position.x, position.y, 0);
        button     = dialogCanvas.GetComponentInChildren <Button>();
        inputField = dialogCanvas.GetComponentInChildren <InputField>();
        title      = dialogCanvas.GetComponentInChildren <Text>();
        HideDialog();
    }
Exemple #3
0
        public void ShowDialog()
        {
            TileEditor te = GameObject.FindObjectOfType <TileEditor>();

            te.SetDefault();
            TilePlacer tp = GameObject.FindObjectOfType <TilePlacer>();

            tp.CancelPlacing();

            List <string> fileNames = GetFilesList();

            dialogCanvas.SetActive(true);

            for (int i = 0; i < fileNames.Count; i++)
            {
                if (!buttons.ContainsKey(fileNames[i]))
                {
                    GameObject newButton = GameObject.Instantiate(Resources.Load("Prefabs/ButtonPrefab")) as GameObject;
                    newButton.transform.position = contentField.transform.position;

                    newButton.transform.position += new Vector3(0.06f, -i * 0.55f - 0.06f, 0);
                    newButton.GetComponent <RectTransform>().SetParent(contentField.transform);
                    newButton.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);

                    newButton.GetComponentInChildren <Text>().text = fileNames[i];

                    newButton.GetComponent <Button>().onClick.AddListener(delegate
                    {
                        ChooseLevelTask(newButton.GetComponentInChildren <Text>().text);
                    });
                    buttons.Add(fileNames[i], newButton);
                }
            }

            scrollRect.content.sizeDelta = new Vector2(0, (float)Math.Max(25 * fileNames.Count, 100.1));

            cancelButton.GetComponentInChildren <Text>().text = "Отмена";
            cancelButton.onClick.AddListener(CancelTask);
        }