- Home /
Reading a masked texture?
So I've been working with unity new gui to create a item scroll list, my main concern is to keep calls to a minimum. Each item inside my scroll rect has a image on it, everything fine here, I can have 100 items into that list with only 7 calls. My problem begins when I want to mask those images so they have a rounded edge. For each ugui mask I have into this list, the draw call increases (2 or 3 calls for each mask).
I've been wondering if it's possible to save a masked texture into a file. So that in the end, using Texture2D.PackTextures and ugui raw images I could read all of those images with only 1 call, and keep the rounded edges.
Ps. I cant round the edges manually.
I've been using this code to pack my textures into a single file and then printing them on raw images:
 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class SpriteAtlas : MonoBehaviour {
     public RawImage[] images;
     public Texture2D[] atlasTextures;
     public Rect[] rects;
     public Texture2D atlas;
     void Start() {
         atlasTextures = new Texture2D[images.Length];
         for (int i=0; i < images.Length; i++) {
             atlasTextures[i] = images[i].mainTexture as Texture2D;
         }
         atlas = new Texture2D(8192, 8192);
         rects = atlas.PackTextures(atlasTextures, 2, 8192);
 
         for (int i=0; i < images.Length; i++) {
             images[i].texture = atlas;
             images[i].uvRect = rects[i];
         }
 
     }
 }
Your answer
 
 
             Follow this Question
Related Questions
Adding Mask to Line Renderer 1 Answer
How can you put a text mesh pro under a 2d sprite mask? 1 Answer
Paper Mario Path Effect 0 Answers
Greyscale Shader Removes UI Masking 0 Answers
Assigning UV Map to model at runtime 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                