public void AddDownloadTexture(DownloadedTexture dtx, string _op = "Content") { // IsSpriteCreate = false; mTex = dtx; op = _op; if (op == "Content") { size.y = 155; } else if (op == "FavThumb") { size.y = 120; } else if (PageDetailGlobal.GetHeaderIndex((int)PageDetailGlobal.type - 1) == "รายชื่อผลิตภัณฑ์" && op == "Detail") { size.y = 900; } else if (PageDetailGlobal.GetHeaderIndex((int)PageDetailGlobal.type - 1) == "Infographic" && op == "Detail") { size.y = 900; } else { size.y = 450; } Debug.Log("AddDownloadTexture : " + op); if (Indecator != null) { Indecator.SetActive(true); } dtx.postDownloaded += CreateSprite; }
protected override void OnGuiBeginSafe(ImageAreaAttribute attribute) { var url = attribute.Url; if (!textures.TryGetValue(url, out var texture)) { textures[url] = texture = new DownloadedTexture(true); EditorCoroutineUtility.StartCoroutineOwnerless(SendGetImageRequest(url, (b, t) => { textures[url] = new DownloadedTexture(false, t); if (b) { InspectorUtility.RepaintInspectors(); } else { ToolboxEditorLog.AttributeUsageWarning(attribute, "Cannot retrive image from the provided URL - " + url); } })); } if (texture.Texture2D != null) { EditorGUILayout.LabelField(new GUIContent(texture.Texture2D), Style.imageStyle, GUILayout.Height(attribute.Height)); } }
void FinishDownload() { if (xmlData.contentList.Length > 0) { for (int i = 0; i < xmlData.contentList.Length; i++) { GameObject dtx = new GameObject("DownloadedTex" + i); DownloadedTexture dtxComp = dtx.AddComponent <DownloadedTexture> (); dtx.transform.parent = this.transform; dtxComp.StartDownload(xmlData.contentList [i].imgthumbnail); mDownloadTexList.Add(dtxComp); } int nextPageSize = Mathf.CeilToInt((float)xmlData.maxPage / PageDetailGlobal.pGlobal.MaxContentPerPage); if (nextPageSize != CurrentPageSize) { CurrentPageSize = nextPageSize; FooterBar.ClearPaging(); FooterBar.CreatePaging(CurrentPageSize); } ShelfDetail.CreateShelfItem(xmlData.contentList, mDownloadTexList, FooterBar.IsFirstPage(), FooterBar.IsLastPage()); FullListDetail.CreateItemDetail(xmlData.contentList, mDownloadTexList); } else { Indecator.SetActive(false); PopupObject.ShowAlertPopup("ไม่พบข้อมูลที่ค้นหา", "กรุณาค้นหาใหม่อีกครั้ง", "ตกลง"); } }
public static DownloadedTexture CreateLoadTexture() { Debug.Log("Create Download Texture"); GameObject dtx = new GameObject("DownloadTex"); DownloadedTexture dTexture = dtx.AddComponent <DownloadedTexture> (); dtx.transform.parent = gPageFile.transform; downloadTextureList.Add(dTexture); return(dTexture); }
void DownloadThumbnail(string path) { if (path.Length <= 0) { return; } DownloadedTexture dTexture = ContentPageFile.CreateLoadTexture(); dTexture.name = ContentPageFile.GetFileName(path); texture.AddDownloadTexture(dTexture, "FavThumb"); dTexture.StartDownload(path); }
void saveFileTexture(Texture2D tex, DownloadedTexture dtx) { string fileName = GetFileName(dtx.www.url); byte[] bytes = tex.EncodeToPNG(); using (FileStream file = new FileStream(Application.persistentDataPath + "/" + fileName, FileMode.Create)) { var binary = new BinaryWriter(file); binary.Write(bytes); } downloadingList.Remove(dtx); Debug.Log("Downloading Count : " + downloadingList.Count); Destroy(dtx.gameObject); }
void DownloadTextureFile(string img) { if (img.Length <= 0) { Debug.Log("No Img Downloaded"); return; } GameObject dtx = new GameObject(GetFileName(img)); DownloadedTexture dTexture = dtx.AddComponent <DownloadedTexture> (); dTexture.postDownloaded += saveFileTexture; dtx.transform.parent = this.transform; dTexture.StartDownload(img); downloadingList.Add(dTexture); }
public void setupImg(string link) { if (link == "") { return; } GameObject dtx = new GameObject("DownloadTex"); dTexture = dtx.AddComponent <DownloadedTexture> (); SpriteTex.SetNewAnchor(0.5f, 1.0f); SpriteTex.AddDownloadTexture(dTexture, "Detail"); // SpriteTex.AddDownloadTexture (dTexture); dtx.transform.parent = this.transform; dTexture.StartDownload(link); Debug.Log("setupImg height : " + SpriteTex.size.y); height += SpriteTex.size.y / 100.0f + 0.5f; }
void CreateSprite(Texture2D tex, DownloadedTexture dtx) { if (Indecator != null) { Indecator.SetActive(false); } SpriteRenderer renderer = gameObject.GetComponent <SpriteRenderer>(); sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), anchor, 100.0f); float sizeheight = tex.height / size.x * tex.width; Debug.Log("Download Image Page : " + op + " :" + PageDetailGlobal.GetHeaderIndex((int)PageDetailGlobal.type - 1)); scaleSize = new Vector2(size.x / tex.width, size.y / tex.height); renderer.sprite = sprite; this.transform.localScale = scaleSize; IsSpriteCreate = true; }