//----------------------------------------------------------------------------------------------------------------------

        internal static ImageSequenceImportWindow  Show(ImageFileImporterParam param)
        {
            Rect rect = new Rect(160, 160, 0, 0);
            ImageSequenceImportWindow window = EditorWindow.GetWindow <ImageSequenceImportWindow>();

            window.ShowAsDropDown(rect, new Vector2(640, 480));
            window.m_importerParam = param;
            return(window);
        }
//----------------------------------------------------------------------------------------------------------------------

        /// Import images in the path to create StreamingImageSequence assets with those images
        /// <param name="path"> Can be a directory path or a file path</param>
        /// <param name="targetAsset"> The target asset where the images are assigned to</param>
        /// <param name="askToCopy"> Ask to copy if path is not under StreamingAssets. Default to true</param>
        internal static void ImportImages(string path,
                                          StreamingImageSequencePlayableAsset targetAsset, bool askToCopy = true)
        {
            Assert.IsFalse(string.IsNullOrEmpty(path));

            FindFolderAndImages(path, out string folder, out List <WatchedFileInfo> relFilePaths);
            if (relFilePaths.Count <= 0)
            {
                EditorUtility.DisplayDialog(StreamingImageSequenceConstants.DIALOG_HEADER, @"No files in folder:: " + folder, "OK");
                return;
            }

            //Estimate the asset name. Use the filename without numbers at the end
            string assetName = EstimateAssetName(relFilePaths[0].GetName());

            // set dest folder
            string streamingAssetsPath = AssetUtility.NormalizeAssetPath(Application.streamingAssetsPath);

            //Set importer param
            ImageFileImporterParam importerParam = new ImageFileImporterParam {
                strSrcFolder          = folder,
                ImageFiles            = relFilePaths,
                CopyToStreamingAssets = true,
                TargetAsset           = targetAsset
            };


            //Import immediately if the assets are already under StreamingAssets
            if (folder.StartsWith(streamingAssetsPath) || !askToCopy)
            {
                importerParam.strDstFolder          = importerParam.strSrcFolder;
                importerParam.CopyToStreamingAssets = false;
                ImageSequenceImporter.Import(importerParam);
            }
            else
            {
                importerParam.strDstFolder = Path.Combine(streamingAssetsPath, assetName).Replace("\\", "/");
                ImageSequenceImportWindow.Show(importerParam);
            }
        }
//----------------------------------------------------------------------------------------------------------------------

        internal static void Import(ImageFileImporterParam param)
        {
            string destFolder = null;

            if (!param.CopyToStreamingAssets)
            {
                destFolder = param.strSrcFolder.Replace("\\", "/");
            }
            else
            {
                destFolder = param.strDstFolder.Replace("\\", "/");
                if (destFolder.StartsWith(Application.dataPath) && !destFolder.StartsWith(Path.Combine(Application.dataPath, "StreamingAssets").Replace("\\", "/")))
                {
                    Debug.LogError("Files must be located under StreamingAssets folder.");
                    return;
                }

                foreach (WatchedFileInfo fileInfo in param.ImageFiles)
                {
                    string fileName          = fileInfo.GetName();
                    string strAbsFilePathDst = Path.Combine(destFolder, fileName).Replace("\\", "/");
                    if (File.Exists(strAbsFilePathDst))
                    {
                        File.Delete(strAbsFilePathDst);
                    }
                    string strAbsFilePathSrc = Path.Combine(param.strSrcFolder, fileName).Replace("\\", "/");
                    Directory.CreateDirectory(Path.GetDirectoryName(strAbsFilePathDst));//make sure dir exists
                    FileUtil.CopyFileOrDirectory(strAbsFilePathSrc, strAbsFilePathDst);
                }
            }

            //if possible, convert folder names to relative path.
            string strUnityProjectFolder = null;
            Regex  regAssetFolder        = new Regex("/Assets$");

            strUnityProjectFolder = Application.dataPath;
            strUnityProjectFolder = regAssetFolder.Replace(strUnityProjectFolder, "");

            if (destFolder.StartsWith(strUnityProjectFolder))
            {
                int start = strUnityProjectFolder.Length + 1;
                int end   = destFolder.Length - start;
                destFolder = destFolder.Substring(start, end);
            }

            //StreamingAsset
            StreamingImageSequencePlayableAsset playableAsset = param.TargetAsset;

            if (null == playableAsset)
            {
                string assetName = EstimateAssetName(param.ImageFiles[0].GetName());
                playableAsset = CreateUniqueSISAsset(
                    Path.Combine("Assets", assetName + "_StreamingImageSequence.playable").Replace("\\", "/")

                    );
            }

            playableAsset.InitFolderInEditor(destFolder, param.ImageFiles);
            if (param.CopyToStreamingAssets)
            {
                AssetDatabase.Refresh();
            }
        }