public static TextureArrayObject BuildTextureArray()
        {
            // LoadTexturesScanFolder(Fold_ShadowParent);
            // return null;

            TextureArrayCreatorAsset asset = new TextureArrayCreatorAsset();

            // asset.m_allTextures = LoadTextures(Fold_Texrue);
            asset.m_allTextures = LoadTexturesScanFolder(Fold_ShadowParent);
            CreateFolders();
            BuildArray(asset);
            return(textureArrayObject);
        }
        /// <summary>
        /// 生成TextureArrayScriptObject
        /// </summary>
        /// <param name="asset"></param>
        /// <param name="textureArray"></param>
        /// <param name="path"></param>
        private static void CreateTextureArrayObject(TextureArrayCreatorAsset asset, Texture2DArray textureArray,
                                                     string path)
        {
            TextureArrayObject outfile = AssetDatabase.LoadMainAssetAtPath(path) as TextureArrayObject;

            if (outfile != null)
            {
                AssetDatabase.DeleteAsset(path);
                AssetDatabase.Refresh();
            }

            TextureArrayObject arrayObject = ScriptableObject.CreateInstance <TextureArrayObject>();

            for (int i = 0; i < asset.AllTextures.Count; i++)
            {
                // arrayObject.dic.Add( asset.AllTextures[ i ].name,i);
                arrayObject.names.Add(asset.AllTextures[i].name);
                arrayObject.indexs.Add(i);
            }

            arrayObject.texture2DArray = textureArray;
            string textureArrayPath = asset.FolderPath + asset.FileName + "Object.asset";

            AssetDatabase.CreateAsset(arrayObject, Fold_ShadowData + asset.FileName + "Object.asset");
            EditorGUIUtility.PingObject(arrayObject);

            //生成阴影QuadPrefab

            // string shadowQuadPath = asset.FolderPath + asset.FileName;
            // string shadowQuadPath = asset.FolderPath;

            for (int i = 0; i < arrayObject.names.Count; i++)
            {
                CreateShadowQuad(Fold_ShadowPrefab, arrayObject.names[i], arrayObject.indexs[i],
                                 arrayObject.texture2DArray);
            }

            textureArrayObject = arrayObject;
        }
        private static void BuildArray(TextureArrayCreatorAsset asset)
        {
            int     sizeX       = asset.SizeX;
            int     sizeY       = asset.SizeY;
            string  m_message   = "";
            Texture m_lastSaved = null;

            Texture2DArray textureArray = new Texture2DArray(sizeX, sizeY, asset.AllTextures.Count,
                                                             asset.SelectedFormatEnum, asset.MipMaps, asset.LinearMode);

            textureArray.wrapMode   = asset.WrapMode;
            textureArray.filterMode = asset.FilterMode;
            textureArray.anisoLevel = asset.AnisoLevel;
            textureArray.Apply(false);
            RenderTexture cache = RenderTexture.active;
            RenderTexture rt    = new RenderTexture(sizeX, sizeY, 0, RenderTextureFormat.ARGBFloat,
                                                    RenderTextureReadWrite.Default);

            rt.Create();

            // shadowTextureArrayScriptObject shadowTextureArrayScriptObject =ScriptableObject.CreateInstance<shadowTextureArrayScriptObject>();

            for (int i = 0; i < asset.AllTextures.Count; i++)
            {
                // build report
                int widthChanges = asset.AllTextures[i].width <sizeX ? -1 : asset.AllTextures[i].width> sizeX ? 1 : 0;
                int heightChanges = asset.AllTextures[i].height <sizeY ? -1 :
                                                                 asset.AllTextures[i].height> sizeY ? 1 : 0;
                if ((widthChanges < 0 && heightChanges <= 0) || (widthChanges <= 0 && heightChanges < 0))
                {
                    m_message += asset.AllTextures[i].name + " was upscaled\n";
                }
                else if ((widthChanges > 0 && heightChanges >= 0) || (widthChanges >= 0 && heightChanges > 0))
                {
                    m_message += asset.AllTextures[i].name + " was downscaled\n";
                }
                else if ((widthChanges > 0 && heightChanges < 0) || (widthChanges < 0 && heightChanges > 0))
                {
                    m_message += asset.AllTextures[i].name + " changed dimensions\n";
                }

                // blit image to upscale or downscale the image to any size
                RenderTexture.active = rt;

                bool cachedsrgb = GL.sRGBWrite;
                GL.sRGBWrite = !asset.LinearMode;
                Graphics.Blit(asset.AllTextures[i], rt);
                GL.sRGBWrite = cachedsrgb;

                bool          isCompressed          = UncompressedFormats.FindIndex(x => x.Equals(asset.SelectedFormatEnum)) < 0;
                TextureFormat validReadPixelsFormat = isCompressed ? TextureFormat.RGBAFloat : asset.SelectedFormatEnum;
                Texture2D     t2d = new Texture2D(sizeX, sizeY, validReadPixelsFormat, asset.MipMaps, asset.LinearMode);
                t2d.ReadPixels(new Rect(0, 0, sizeX, sizeY), 0, 0, asset.MipMaps);
                RenderTexture.active = null;

                // TextureFormat
                if (isCompressed)
                {
                    EditorUtility.CompressTexture(t2d, asset.SelectedFormatEnum, asset.Quality);
                    t2d.Apply(false);
                }

                if (asset.MipMaps)
                {
                    int maxSize   = Mathf.Max(sizeX, sizeY);
                    int numLevels = 1 + (int)Mathf.Floor(Mathf.Log(maxSize, 2));
                    for (int mip = 0; mip < numLevels; mip++)
                    {
                        CopyToArray(ref t2d, ref textureArray, i, mip, isCompressed);
                    }
                }
                else
                {
                    CopyToArray(ref t2d, ref textureArray, i, 0, isCompressed);
                }
            }

            rt.Release();
            RenderTexture.active = cache;
            if (m_message.Length > 0)
            {
                m_message = m_message.Substring(0, m_message.Length - 1);
            }

            // string path = ParentFold + Fold_ShadowData + asset.FileName + ".asset";
            string         path    = asset.FolderPath + asset.FileName + ".asset";
            Texture2DArray outfile = AssetDatabase.LoadMainAssetAtPath(path) as Texture2DArray;

            if (outfile != null)
            {
                EditorUtility.CopySerialized(textureArray, outfile);
                AssetDatabase.SaveAssets();
                EditorGUIUtility.PingObject(outfile);
                m_lastSaved = outfile;
                // CreateTextureArrayObject(asset, outfile, asset.FolderPath + asset.FileName + "Object.asset");
            }
            else
            {
                AssetDatabase.CreateAsset(textureArray, Fold_ShadowData + asset.FileName + ".asset");
                EditorGUIUtility.PingObject(textureArray);
                m_lastSaved = textureArray;
                // CreateTextureArrayObject(asset, textureArray, asset.FolderPath + asset.FileName + "Object.asset");
            }

            CreateTextureArrayObject(asset, m_lastSaved as Texture2DArray, asset.FolderPath + asset.FileName);
        }