示例#1
0
    public static void CopyToPersistentDataPath(string streamingAssetFilePath, string destinationFilePath, Action onComplete)
    {
        GameObject           obj    = new GameObject(Path.GetFileNameWithoutExtension(destinationFilePath));
        StreamingAssetCopier copier = obj.AddComponent <StreamingAssetCopier>();

        copier.streamingAssetFilePath = streamingAssetFilePath;
        copier.destinationFilePath    = destinationFilePath;
        copier.onComplete             = onComplete;
        copier.StartCoroutine(copier.Copy());
    }
示例#2
0
 void Copy(string fromPath, string toPath, Action onComplete)
 {
     Directory.CreateDirectory(Path.GetDirectoryName(toPath));
     if (fromPath.Contains("://"))
     {
         StreamingAssetCopier.CopyToPersistentDataPath(fromPath, toPath, delegate {
             if (onComplete != null)
             {
                 onComplete();
             }
         });
     }
     else
     {
         File.Copy(fromPath, toPath, true);
         if (onComplete != null)
         {
             onComplete();
         }
     }
 }