void CreateCubeArrayAsset()
    {
        //Texture2DArray array = new Texture2DArray(textures[0].width, textures[0].height, textures.Length, GraphicsFormatUtility.GetGraphicsFormat(TextureFormat.ARGB32, false), TextureCreationFlags.None);
        TextureFormat tf       = cubeMaps[0].format;
        int           mipLevel = cubeMaps[0].mipmapCount;

        CubemapArray array = new CubemapArray(cubeMaps[0].width, cubeMaps.Length, texFormat, mipmaps);


        for (int i = 0; i < 6; i++) //iterate for each cube face
        {
            for (int j = 0; j < cubeMaps.Length; j++)
            {
                for (int m = 0; m < mipLevel; m++)
                {
                    CubemapFace face = (CubemapFace)i;
                    array.SetPixels(cubeMaps[j].GetPixels(face), face, j, m);
                }
            }
        }

        for (int j = 0; j < 6; j++)
        {
            //CubemapFace face = (CubemapFace)i;
            // array.SetPixels(textures[j].GetPixels(), face, j);
            for (int i = 0; i < mipLevel; i++)
            {
                //for()
                // Graphics.CopyTexture(textures[j], 0, i, array, j, i);
            }
        }

        array.Apply();
        AssetDatabase.CreateAsset(array, "Assets/CubemapArray.asset");
    }
    void Create()
    {
#if UNITY_EDITOR
        CubemapArray textureArray = new CubemapArray(6, textureList.Length, TextureFormat.RGB24, false);
        for (int i = 0; i < textureList.Length; i++)
        {
            Texture2D tex = (Texture2D)textureList[i];
            textureArray.SetPixels(tex.GetPixels(0), CubemapFace.PositiveX, 0);
        }
        textureArray.Apply();

        AssetDatabase.CreateAsset(textureArray, savePath);
        Debug.Log("Saved asset to " + savePath);
#endif
    }
    public static int SetPixels(IntPtr l)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(l);
            if (num == 4)
            {
                CubemapArray cubemapArray = (CubemapArray)LuaObject.checkSelf(l);
                Color[]      colors;
                LuaObject.checkArray <Color>(l, 2, out colors);
                CubemapFace face;
                LuaObject.checkEnum <CubemapFace>(l, 3, out face);
                int arrayElement;
                LuaObject.checkType(l, 4, out arrayElement);
                cubemapArray.SetPixels(colors, face, arrayElement);
                LuaObject.pushValue(l, true);
                result = 1;
            }
            else if (num == 5)
            {
                CubemapArray cubemapArray2 = (CubemapArray)LuaObject.checkSelf(l);
                Color[]      colors2;
                LuaObject.checkArray <Color>(l, 2, out colors2);
                CubemapFace face2;
                LuaObject.checkEnum <CubemapFace>(l, 3, out face2);
                int arrayElement2;
                LuaObject.checkType(l, 4, out arrayElement2);
                int miplevel;
                LuaObject.checkType(l, 5, out miplevel);
                cubemapArray2.SetPixels(colors2, face2, arrayElement2, miplevel);
                LuaObject.pushValue(l, true);
                result = 1;
            }
            else
            {
                LuaObject.pushValue(l, false);
                LuaDLL.lua_pushstring(l, "No matched override function SetPixels to call");
                result = 2;
            }
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }