void Update() { if (appInstallAdLoaded) { appInstallAdLoaded = false; // update o day isReadyToShow = true; try { if (iconObj != null) { DestroyImmediate(iconObj); } if (adChoicesObj != null) { DestroyImmediate(adChoicesObj); } if (headLineObj != null) { DestroyImmediate(headLineObj); } if (priceObj != null) { DestroyImmediate(priceObj); } if (storeObj != null) { DestroyImmediate(storeObj); } if (calToActionObj != null) { DestroyImmediate(calToActionObj); } if (log != null) { log.text = "Destroy done"; } string headlineText = this.appInstallAd.GetHeadlineText(); if (log != null) { log.text = "Fetch headline done"; } Texture2D iconTexture = this.appInstallAd.GetIconTexture(); if (log != null) { log.text = "Fetch iconTexture done"; } Texture2D img = appInstallAd.GetImageTextures()[0]; if (log != null) { log.text = "Fetch ImageTextures done"; } string callToActionText = this.appInstallAd.GetCallToActionText(); if (log != null) { log.text = "Fetch CallToAction done"; } Texture2D adchoices = null; try { adchoices = appInstallAd.GetAdChoicesLogoTexture(); } catch (Exception e) { adchoices = null; } if (log != null) { log.text = "Fetch AdChoices done"; } string bodyText = null; try { bodyText = this.appInstallAd.GetBodyText(); } catch (Exception e) { bodyText = null; } if (log != null) { log.text = "Fetch BodyText done"; } string price = null; try { price = this.appInstallAd.GetPrice(); } catch (Exception e) { price = null; } if (log != null) { log.text = "Fetch Price done"; } string store = null; try { store = this.appInstallAd.GetStore(); } catch (Exception e) { store = null; } if (log != null) { log.text = "Fetch Store done"; } Vector3 localS = transform.localScale; Image icon = transform.Find("Icon").gameObject.GetComponent <Image>(); Image choices = transform.Find("Adchoice").gameObject.GetComponent <Image>(); Text name = transform.Find("Name").gameObject.GetComponent <Text>(); Text priceT = transform.Find("Price").gameObject.GetComponent <Text>(); Image storeI = transform.Find("Store").gameObject.GetComponent <Image>(); Button play = transform.Find("Button").gameObject.GetComponent <Button>(); if (log != null) { log.text = "Find Component done"; } iconObj = GameObject.CreatePrimitive(PrimitiveType.Quad); iconObj.transform.position = new Vector3(icon.transform.position.x, icon.transform.position.y, -1); Material material = new Material(unlitShader); iconObj.GetComponent <Renderer>().material = material; material.mainTexture = iconTexture; standardlize(new Vector3(icon.rectTransform.sizeDelta.x, icon.rectTransform.sizeDelta.y), iconObj.GetComponent <Renderer>().bounds.size, iconObj, localS); appInstallAd.RegisterIconImageGameObject(iconObj); if (log != null) { log.text = "Icon done"; } name.text = headlineText; headLineObj = new GameObject(); TextMesh mesh = headLineObj.AddComponent <TextMesh>(); mesh.characterSize = 0.25f; mesh.anchor = TextAnchor.MiddleCenter; mesh.color = new Color(1f, 1f, 1f, 0); mesh.text = callToActionText;//"Nhi"; headLineObj.AddComponent <BoxCollider>().size = ScreenToWorldSize2D(new Vector3(name.rectTransform.sizeDelta.x, name.rectTransform.sizeDelta.y)); headLineObj.transform.localScale = localS; headLineObj.transform.position = new Vector3(name.transform.position.x, name.transform.position.y, -1); appInstallAd.RegisterHeadlineTextGameObject(headLineObj); if (log != null) { log.text = "HeadLine done"; } if (price != null) { priceT.text = price; priceObj = new GameObject(); mesh = priceObj.AddComponent <TextMesh>(); mesh.characterSize = 0.25f; mesh.anchor = TextAnchor.MiddleCenter; mesh.color = new Color(1f, 1f, 1f, 0); mesh.text = price;//"Nhi"; priceObj.AddComponent <BoxCollider>().size = ScreenToWorldSize2D(new Vector3(priceT.rectTransform.sizeDelta.x, priceT.rectTransform.sizeDelta.y)); priceObj.transform.localScale = localS; priceObj.transform.position = new Vector3(priceT.transform.position.x, priceT.transform.position.y, -1);; appInstallAd.RegisterPriceGameObject(priceObj); } else { priceT.text = ""; } if (log != null) { log.text = "Price done"; } if (store != null) { if (store == "Google Play") { storeI.sprite = Resources.Load <Sprite>("Viguys/appstore2"); } else { storeI.sprite = Resources.Load <Sprite>("Viguys/appstore1"); } storeObj = new GameObject(); mesh = storeObj.AddComponent <TextMesh>(); mesh.characterSize = 0.25f; mesh.anchor = TextAnchor.MiddleCenter; mesh.color = new Color(1f, 1f, 1f, 0); mesh.text = store;//"Nhi"; storeObj.AddComponent <BoxCollider>().size = ScreenToWorldSize2D(new Vector3(storeI.rectTransform.sizeDelta.x, storeI.rectTransform.sizeDelta.y)); storeObj.transform.localScale = localS; storeObj.transform.position = new Vector3(storeI.transform.position.x, storeI.transform.position.y, -1);; appInstallAd.RegisterStoreGameObject(storeObj); } if (log != null) { log.text = "Store done"; } play.transform.Find("Text").gameObject.GetComponent <Text>().text = callToActionText; calToActionObj = new GameObject(); mesh = calToActionObj.AddComponent <TextMesh>(); mesh.characterSize = 0.25f; mesh.anchor = TextAnchor.MiddleCenter; mesh.color = new Color(1f, 1f, 1f, 0f); mesh.text = callToActionText;//"Nhi"; calToActionObj.AddComponent <BoxCollider>().size = ScreenToWorldSize2D(new Vector3(play.GetComponent <RectTransform>().sizeDelta.x, play.GetComponent <RectTransform>().sizeDelta.y)); calToActionObj.transform.localScale = localS; calToActionObj.transform.position = new Vector3(play.transform.position.x, play.transform.position.y, -1);// play.transform.position; appInstallAd.RegisterCallToActionGameObject(calToActionObj); if (log != null) { log.text = "CallAction done"; } if (adchoices != null) { adChoicesObj = GameObject.CreatePrimitive(PrimitiveType.Quad); adChoicesObj.transform.position = new Vector3(choices.transform.position.x, choices.transform.position.y, -1);// choices.transform.position; material = new Material(unlitShader); adChoicesObj.GetComponent <Renderer>().material = material; material.mainTexture = adchoices; standardlize(new Vector3(choices.rectTransform.sizeDelta.x, choices.rectTransform.sizeDelta.y), adChoicesObj.GetComponent <Renderer>().bounds.size, adChoicesObj, localS); appInstallAd.RegisterAdChoicesLogoGameObject(adChoicesObj); } if (log != null) { log.text = "Adchoice done"; } if (canShow) { Show(); } else { Hide(); } if (log != null) { log.text = "Finish done"; } } catch (Exception e) { if (text != null) { text.text = "" + e.Message; } } } }