AddObject() публичный Метод

public AddObject ( GameObject go ) : void
go UnityEngine.GameObject
Результат void
Пример #1
0
        public void DrawScreen(XsollaTranslations translations, XsollaStatus xsollaStatus)
        {
            ResizeToParent();
            XsollaStatus.Group group = xsollaStatus.GetGroup();
            switch (group)
            {
            case XsollaStatus.Group.DONE:
                linerLayout.AddObject(GetOkStatus(xsollaStatus.GetStatusText().GetState()));
                break;

            case XsollaStatus.Group.TROUBLED:
                linerLayout.AddObject(GetErrorByString(xsollaStatus.GetStatusText().GetState()));
                break;

            case XsollaStatus.Group.INVOICE:
            case XsollaStatus.Group.UNKNOWN:
            default:
                linerLayout.AddObject(GetWaitingStatus(xsollaStatus.GetStatusText().GetState()));
                StartCoroutine(TryIt(xsollaStatus.GetInvoice()));
                break;
            }
            linerLayout.AddObject(GetError(null));
            linerLayout.AddObject(GetEmpty());
            adapter.SetElements(xsollaStatus.GetStatusText().GetStatusTextElements());
            GameObject list = GetList(adapter);

            list.GetComponent <ListView> ().DrawList(GetComponent <RectTransform> ());
            linerLayout.AddObject(list);
            linerLayout.AddObject(GetEmpty());
            if (group == XsollaStatus.Group.INVOICE || group == XsollaStatus.Group.UNKNOWN)
            {
                linerLayout.AddObject(GetButton("Start again", delegate { StartAgain(); }));
                linerLayout.AddObject(GetEmpty());
            }
            linerLayout.Invalidate();
        }
        public void InitView(XsollaTranslations translations, XsollaSummary summary)
        {
            _translations = translations;
            _summary      = summary;

            if (this.gameObject.GetComponent <VerticalLayoutGroup>() == null)
            {
                this.gameObject.AddComponent <VerticalLayoutGroup>();
                VerticalLayoutGroup obj = this.GetComponent <VerticalLayoutGroup>();
                obj.childForceExpandHeight = false;
            }
            GameObject header = Instantiate(orderSummaryPrefab);

            header.GetComponentsInChildren <Text> () [0].text = translations.Get(XsollaTranslations.PAYMENT_SUMMARY_HEADER);
            linearLayout.AddObject(header);
            foreach (IXsollaSummaryItem purchase in _summary.GetPurchases())
            {
                linearLayout.AddObject(GetSummaryItem(purchase));
            }
            XsollaFinance finance = _summary.GetFinance();

            linearLayout.AddObject(GetItem(subTotalPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_SUBTOTAL), PriceFormatter.Format(finance.subTotal.amount, finance.subTotal.currency)));
            if (finance.discount != null && finance.discount.amount > 0)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_DISCOUNT), "- " + PriceFormatter.Format(finance.discount.amount, finance.discount.currency)));
            }
            if (finance.fee != null)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_FEE), PriceFormatter.Format(finance.fee.amount, finance.fee.currency)));
            }
            if (finance.xsollaCredits != null && finance.xsollaCredits.amount > 0)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_XSOLLA_CREDITS), PriceFormatter.Format(finance.xsollaCredits.amount, finance.xsollaCredits.currency)));
            }
            linearLayout.AddObject(GetItem(totalPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_TOTAL), PriceFormatter.Format(finance.total.amount, finance.total.currency)));
            if (finance.vat != null && finance.vat.amount > 0)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, "VAT", PriceFormatter.Format(finance.vat.amount, finance.vat.currency)));
            }
            linearLayout.Invalidate();
        }
Пример #3
0
        public void InitView(XsollaTranslations pTranslations, XsollaForm form)
        {
            _form = form;
            // if have skipCheckout and this checkout form
            if ((form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) && form.GetSkipChekout())
            {
                string checkoutToken  = _form.GetCheckoutToken();
                bool   isLinkRequired = checkoutToken != null &&
                                        !"".Equals(checkoutToken) &&
                                        !"null".Equals(checkoutToken) &&
                                        !"false".Equals(checkoutToken);
                if (isLinkRequired)
                {
                    OnClickPay(isLinkRequired);
                    return;
                }
            }

            string pattern = "{{.*?}}";
            Regex  regex   = new Regex(pattern);
            string title   = regex.Replace(pTranslations.Get(XsollaTranslations.PAYMENT_PAGE_TITLE_VIA), form.GetTitle(), 1);

            layout.AddObject(GetTitle(title));
            layout.AddObject(GetError(form.GetError()));
            layout.AddObject(GetInfo(form.GetMessage()));
            if (form.GetVisible().Count > 0)
            {
                GameObject formView = GetFormView(form, pTranslations);
                layout.AddObject(formView);
            }
            if (form.GetAccountXsolla() != null && !"".Equals(form.GetAccountXsolla()) && !"null".Equals(form.GetAccountXsolla()))
            {
                layout.AddObject(GetTwoTextPlate("Xsolla number", form.GetAccountXsolla()));
            }
            if (form.GetAccount() != null && !"".Equals(form.GetAccount()) && !"null".Equals(form.GetAccount()))
            {
                layout.AddObject(GetTwoTextPlate("2pay number", form.GetAccount()));
            }
            if (form.IsValidPaymentSystem())
            {
                layout.AddObject(GetTextPlate(pTranslations.Get(XsollaTranslations.FORM_CC_EULA)));
            }
            GameObject footerInstance = Instantiate(footer);

            Text[] footerTexts = footerInstance.GetComponentsInChildren <Text> ();
//			footerTexts [0].text = "back";//back
            string nextStep = form.GetNextStepString();

            footerTexts [2].text = nextStep;            //translations.Get (XsollaTranslations.FORM_CONTINUE);//pay now
            Button[] footerButtons = footerInstance.GetComponentsInChildren <Button> ();
            if (OnClickBack != null)
            {
                footerButtons [0].onClick.AddListener(() => {
                    OnBack();
                });
            }
            else
            {
                footerButtons [0].gameObject.SetActive(false);
            }

            if (form.GetCurrentCommand() == XsollaForm.CurrentCommand.ACCOUNT ||
                form.GetCurrentCommand() == XsollaForm.CurrentCommand.CREATE ||
                form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) //
            {
                footerTexts [1].text = "";                                      //total
                RectTransform buttonRect = footerButtons [1].GetComponent <RectTransform>();
                Vector2       vecMin     = buttonRect.anchorMin;
                vecMin.x             = vecMin.x - (buttonRect.anchorMax.x - vecMin.x) / 2;
                buttonRect.anchorMin = vecMin;
            }
            else
            {
                footerTexts [1].text = pTranslations.Get(XsollaTranslations.TOTAL) + " " + form.GetSumTotal();                  //total
            }

            layout.AddObject(footerInstance);
            layout.Invalidate();

            if (!"".Equals(nextStep) && form.GetCurrentCommand() != XsollaForm.CurrentCommand.ACCOUNT)
            {
                string checkoutToken  = _form.GetCheckoutToken();
                bool   isLinkRequired = checkoutToken != null &&
                                        !"".Equals(checkoutToken) &&
                                        !"null".Equals(checkoutToken) &&
                                        !"false".Equals(checkoutToken);
                string link = "https://secure.xsolla.com/pages/checkout/?token=" + _form.GetCheckoutToken();
                if (isLinkRequired && Application.platform == RuntimePlatform.WebGLPlayer)
                {
                    RectTransform buttonRect = footerButtons [1].GetComponent <RectTransform>();
                    int           width      = (int)(buttonRect.rect.xMax - buttonRect.rect.xMin);
                    int           height     = (int)(buttonRect.rect.yMax - buttonRect.rect.yMin);
                    height = height * 8;
                    Vector3[] vec = new Vector3[4];
                    buttonRect.GetWorldCorners(vec);
                    int xPos = (int)vec[0].x;
                    int yPos = (int)vec[0].y;
                    yPos = yPos / 2;
                    CreateLinkButtonWebGl(xPos, yPos, width, height, link, "CardPaymeentForm", "Next");
                    footerButtons [1].onClick.AddListener(() => {
                        OnClickPay(false);
                    });
                }
                else
                {
                    footerButtons [1].onClick.AddListener(() => {
                        OnClickPay(isLinkRequired);
                    });
                }
            }
            else
            {
                footerButtons [1].gameObject.SetActive(false);
            }
        }
Пример #4
0
 public void DrawScreen(XsollaError error)
 {
     linerLayout.AddObject(GetError(error));
     linerLayout.Invalidate();
 }