public void SetImageFromTexture2D(Texture2D tex2d) { int collageSize = _Collage.gameBoard.collageSize; Texture2D scaledTex = CollageImage.ScaleTexture(tex2d, collageSize, collageSize); SpriteRenderer spriteRenderer = this.GetComponent <SpriteRenderer>(); spriteRenderer.sprite = Sprite.Create(scaledTex, new Rect(0, 0, collageSize, collageSize), new Vector2(0.5f, 0.5f)); }
IEnumerator DelayStart() { yield return(new WaitForSeconds(1f)); //Debug.Log("DDDDDDDEBUG"); //For debug use Texture2D debugTex = _Collage.currentLevelInfo.GetSketch(); SetImageFromTexture2D(CollageImage.ScaleTexture(debugTex, _Collage.gameBoard.collageSize, _Collage.gameBoard.collageSize)); yield return(null); }
public Texture2D GetSketch() { //Debug.Log("here" + collageFractionInfoList.Count + " " + levelTexture.height + " " + levelTexture.width); Texture2D sketch = new Texture2D(levelTexture.width, levelTexture.height, levelTexture.format, true); foreach (CollageFractionInfo collage in collageFractionInfoList) { int nextIndex = childrenLevelCollageIndexes.IndexOf(collage.collageId); int positionId = collage.positionId; if (positionId != -1) { //Debug.Log("here has some ids"); int xOffset = positionId % gameBoard.gridCountPerLine; int yOffset = positionId / gameBoard.gridCountPerLine; Texture2D tex = collage.currentTexture2d; //Debug.Log("collage texture2d: " + tex.width + " " + tex.height); if (nextIndex != -1) { LevelCollageInfo childLevel = childrenLevelInfo[nextIndex]; if (!childLevel.visited) { tex = CollageImage.ScaleTexture(PlayerInfo.questionTexture, tex.width, tex.height); } else { tex = CollageImage.ScaleTexture(childLevel.GetSketch(), tex.width, tex.height); } } //send picture to sketches for (int i = 0; i < tex.width; i++) { for (int j = 0; j < tex.height; j++) { Color color = tex.GetPixel(i, j); sketch.SetPixel(xOffset * levelCollageSize + i, yOffset * levelCollageSize + j, color); } } } } sketch.Apply(); return(sketch); }