Exemplo n.º 1
0
    public static UIAlert create(string title, string message = "", Layout layout = Layout.HORIZONTAL, int width = 400, int height = 300, string template = null)
    {
        string alertTemplate = "UIAlert-Horizontal-Template";

        if (layout == Layout.VERTICAL)
        {
            alertTemplate = "UIAlert-Vertical-Template";
        }
        if (template != null)
        {
            alertTemplate = template;
        }

        UIRoot root = GameObject.FindObjectOfType(typeof(UIRoot)) as UIRoot;

        if (root != null)
        {
            UIPanel panel = CreatePanel(root);
            UIAlert alert = UIAlert.Instantiate(alertTemplate, panel);
            alert.GetComponent <UISprite>().alpha = 0.0f;
            alert.title   = title;
            alert.message = message;
            alert.layout  = layout;
            alert.panel   = panel;
            alert.width   = width;
            alert.height  = height;

            alert.Hide();
            alert.Block();

            return(alert);
        }
        else
        {
            Debug.Log("UIAlert Warning! UIRoot script not found");
        }
        return(null);
    }