/// <summary> /// Either create new ImageDatas representing the passed texture array or if this texture has already /// been converted return the ImageDatas from the cache /// </summary> /// <param name="texture"></param> /// <returns>ImageData representing the texture</returns> public static ImageData[] GetOrCreateImageData(Texture2DArray texture) { if (_imageDataCache.ContainsKey(texture.GetInstanceID())) { List <ImageData> datas = new List <ImageData>(); for (int i = 0; i < texture.depth; i++) { int id = texture.GetInstanceID() * (i + 1); datas.Add(_imageDataCache[id]); } return(datas.ToArray()); } return(CreateImageDatas(texture)); }
/// <summary> /// Create an array of new image data representing the passed texture array /// </summary> /// <param name="texture"></param> /// <returns>ImageData array representing the texture array</returns> public static ImageData[] CreateImageDatas(Texture2DArray texture, bool addToCache = true) { List <ImageData> texdatas = new List <ImageData>(); TextureSupportIssues issues = GetSupportIssuesForTexture(texture); if (issues != TextureSupportIssues.None) { texdatas.Add(CreateImageData(Texture2D.whiteTexture)); NativeLog.WriteLine(GetTextureSupportReport(issues, texture)); return(texdatas.ToArray()); } for (int i = 0; i < texture.depth; i++) { ImageData texdata = new ImageData(); PopulateImageData(texture, i, ref texdata); texdata.id = texture.GetInstanceID() * (i + 1); // hack some kind of id for the texture texdatas.Add(texdata); // add to the cache (double check it doesn't exist already) if (!_imageDataCache.ContainsKey(texdata.id) && addToCache) { _imageDataCache[texdata.id] = texdata; } } return(texdatas.ToArray()); }
static public VFXValue <int> Constant(Texture2DArray value) { return(new VFXTexture2DArrayValue(value.GetInstanceID(), Mode.Constant)); }