static public int SetPixels(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (argc == 3) { UnityEngine.Texture2DArray self = (UnityEngine.Texture2DArray)checkSelf(l); UnityEngine.Color[] a1; checkArray(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); self.SetPixels(a1, a2); pushValue(l, true); return(1); } else if (argc == 4) { UnityEngine.Texture2DArray self = (UnityEngine.Texture2DArray)checkSelf(l); UnityEngine.Color[] a1; checkArray(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); self.SetPixels(a1, a2, a3); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function SetPixels to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
Texture2DArray GenerateTextureArray(Texture2D[] textures) { Texture2DArray textureArray = new Texture2DArray( // width, height, depth, format, mipmap textureSize, textureSize, textures.Length, textureFormat, true ); for(int i = 0; i < textures.Length; i++) { textureArray.SetPixels(textures[i].GetPixels(), i); } textureArray.Apply(); return textureArray; }
static void GifImport() { string path = AssetDatabase.GetAssetPath(Selection.activeObject); List <Texture2D> array = GetGifFrames(path); Texture2DArray arrayTexture = new Texture2DArray(array.First().width, array.First().height, array.Count, TextureFormat.RGBA32, true, false); for (int i = 0; i < array.Count; i++) { arrayTexture.SetPixels(array[i].GetPixels(0), i, 0); } arrayTexture.Apply(); AssetDatabase.CreateAsset(arrayTexture, path.Replace(".gif", ".asset")); }
static public int SetPixels(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 3) { UnityEngine.Texture2DArray self = (UnityEngine.Texture2DArray)checkSelf(l); UnityEngine.Color[] a1; checkArray(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); self.SetPixels(a1, a2); pushValue(l, true); return(1); } else if (argc == 4) { UnityEngine.Texture2DArray self = (UnityEngine.Texture2DArray)checkSelf(l); UnityEngine.Color[] a1; checkArray(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); self.SetPixels(a1, a2, a3); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
void BuildTextureArray(TextureFormat format = TextureFormat.RGBA32, Color defaultColor = default(Color), bool linear = false) { int maxWidth = 0; int maxHeight = 0; foreach (var texture in textureList) { maxWidth = Mathf.Max(maxWidth, texture.width); maxHeight = Mathf.Max(maxHeight, texture.height); } textureArray = new Texture2DArray(maxWidth, maxHeight, textureList.Count, format, true, linear); for (int i = 0; i < textureList.Count; i++) { if (textureList[i].width < maxWidth || textureList[i].height < maxHeight) TextureScale.Bilinear(textureList[i], maxWidth, maxHeight); textureArray.SetPixels(textureList[i].GetPixels(), i); } textureArray.Apply(); }