Beispiel #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="from">file inside streaming assets folder</param>
    /// <param name="to">create or override file at</param>
    /// <returns></returns>
    private IEnumerator CopyFileOnAndroid(string from, string to)
    {
        UnityWebRequest loader = UnityWebRequest.Get(UnityPath.Combinate(from, UnityPath.AssetPath.StreamingAsset));

        yield return(loader.SendWebRequest());

        byte[] readbytes = loader.downloadHandler.data;
        loader.Dispose();

        UnityPath.CreateFileAnywhere(to);
        DirectoryInfo dirInfo = new DirectoryInfo(UnityPath.GetDirectory(to))
        {
            Attributes = FileAttributes.Hidden
        };


        if (UnityPath.FileOrDirectory(to) == 0) // target path is file
        {
            File.WriteAllBytes(to, readbytes);
            Debugger.Log("Copy from: " + from + " to: " + to + " data size: " + readbytes.Length);
        }
    }
Beispiel #2
0
    public IEnumerator Action()
    {
        IsDone   = false;
        Progress = 0.0f;

        string configFilePath = PlayerPrefs.GetString(localPathKey);

        if (string.IsNullOrEmpty(configFilePath))
        {
            string streamingPath   = UnityPath.Combinate(Constants.ConfigFilePath, UnityPath.AssetPath.StreamingAsset);
            string localConfigPath =
                UnityPath.GetDirectory(Constants.ConfigFilePath) + @"\" +
                Guid.NewGuid().ToString() +
                UnityPath.GetExtension(Constants.ConfigFilePath);

            yield return(CopyAssets.Copy
                             (streamingPath, UnityPath.Combinate(localConfigPath, UnityPath.AssetPath.Persistent)));

            PlayerPrefs.SetString(localPathKey, localConfigPath);
        }
        IsDone   = true;
        Progress = 1.0f;
    }