public void setupImg(string link, int i) { loading.SetActive(true); if (link == "") { return; } idx = i; dtx = new GameObject("DownloadTex"); dTexture = dtx.AddComponent <NewsboardDownloadTexture> (); SpriteTex.SetNewAnchor(0.5f, 1.0f); SpriteTex.AddDownloadTexture(dTexture); dtx.transform.parent = this.transform; dTexture.StartDownload(link); height += SpriteTex.size.y / 100.0f + 0.5f; // Debug.Log ("ContentObject Picture Height : "+pictureHeight); height += pictureHeight + 0.8f; }
void CreateSprite(Texture2D tex, NewsboardDownloadTexture 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); if (cObject != null) { scaleSize = new Vector2(size.x / tex.width, size.x / tex.width); cObject.setpictureHeight(tex.height * size.x / tex.width); } else { scaleSize = new Vector2(size.x / tex.width, size.y / tex.height); cObject.setpictureHeight(size.y / tex.height); } renderer.sprite = sprite; this.transform.localScale = scaleSize; IsSpriteCreate = true; }
public void AddDownloadTexture(NewsboardDownloadTexture dtx) { IsSpriteCreate = false; mTex = dtx; dtx.postDownloaded += CreateSprite; }