Ejemplo n.º 1
0
        /// <summary>
        /// Show the specified template, msg, confirmCallback and cancelCallback.
        /// </summary>
        /// <param name="template">Template.</param>
        /// <param name="msg">Message.</param>
        /// <param name="confirmCallback">Confirm callback.</param>
        /// <param name="cancelCallback">Cancel callback.</param>
        public static void Show(GameObject template, string msg, ConfirmButtonPressedDelegate confirmCallback = null, CancelButtonPressedDelegate cancelCallback = null)
        {
            // Get the Canvas
            GameObject canvas = GameObject.Find("Canvas") as GameObject;

            if (canvas != null && template != null)
            {
                GameObject    obj             = Instantiate(template);
                RectTransform dialogTransform = obj.GetComponent <RectTransform>();
                RectTransform canvasTransform = canvas.GetComponent <RectTransform>();

                if (dialogTransform != null && canvasTransform != null)
                {
                    IAPDialog dialog = obj.AddComponent <IAPDialog>();
                    dialogTransform.SetParent(canvasTransform);
                    dialogTransform.offsetMin  = new Vector2(0, 0);
                    dialogTransform.offsetMax  = new Vector2(0, 0);
                    dialogTransform.localScale = new Vector3(1, 1, 1);

                    Text[] txts = obj.GetComponentsInChildren <Text>();
                    foreach (Text txt in txts)
                    {
                        if (txt.name == "message")
                        {
                            txt.text = msg;
                        }
                    }

                    if (confirmCallback != null)
                    {
                        dialog.OnConfirmButtonPressed += confirmCallback;
                    }

                    if (cancelCallback != null)
                    {
                        dialog.OnCancelButtonPressed += cancelCallback;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void handleCancelButtonPressed(IAPDialog dialog)
 {
     dialog.OnCancelButtonPressed -= handleCancelButtonPressed;
 }
Ejemplo n.º 3
0
 private void handleConfirmButtonPressed(IAPDialog dialog)
 {
     dialog.OnConfirmButtonPressed -= handleConfirmButtonPressed;
 }