Exemple #1
0
        static void UpdateTextureArray(ref Texture2DArray array, Texture2D[] slices, bool linear)
        {
            if (array != null && array.depth != slices.Length)
            {
                Texture2DArray.Destroy(array);
                array = null;
            }

            if (array == null)
            {
                array            = new Texture2DArray(slices[0].width, slices[0].height, slices.Length, slices[0].format, true, linear);
                array.hideFlags |= HideFlags.HideAndDontSave;
            }

            if (slices.Length > 0 && slices[0] != null)
            {
                array.wrapMode   = slices[0].wrapMode;
                array.anisoLevel = slices[0].anisoLevel;
                array.filterMode = slices[0].filterMode;
            }

            for (int i = 0; i != slices.Length; i++)
            {
                if (slices[i] != null)
                {
                    int mipCount = slices[i].mipmapCount;
                    for (int mip = 0; mip != mipCount; mip++)
                    {
                        Graphics.CopyTexture(slices[i], 0, mip, array, i, mip);
                    }
                }
            }
        }