Example #1
0
    void WriteFile(string path, string filename)
    {
        string f;

        f = FileBrowserHelpers.CreateFileInDirectory(path, filename + ".waterline");
        Designer.SaveToString();
        FileBrowserHelpers.WriteTextToFile(f, Designer.PGdata);

        f = FileBrowserHelpers.CreateFileInDirectory(path, filename + ".png");
        byte[] bt = Designer.MakeThumbBytes(512);
        FileBrowserHelpers.WriteBytesToFile(f, bt);
    }
Example #2
0
    IEnumerator ShowSaveDialogCoroutine(string data)
    {
        // Show a Save Dialog and wait for response from users
        yield return(FileBrowser.WaitForSaveDialog(false, false, null, "Save", "Save"));

        // Dialog is closed
        Debug.Log(FileBrowser.Success);

        if (FileBrowser.Success)
        {
            Debug.Log(FileBrowser.Result[0]);
            FileBrowserHelpers.WriteTextToFile(FileBrowser.Result[0], data);
        }
    }
Example #3
0
        public void SaveFile(FileData file, string text = null)
        {
            if (file == null)
            {
                string name = DateTime.Now.ToShortDateString() + "_" + DateTime.Now.ToLongTimeString().Replace(":", "_");
                string path = Application.persistentDataPath + _targetFolder;

                try
                {
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }
                catch (IOException ex)
                {
                    Debug.Log(ex.Message);
                }

                path  = path.Replace("/", "\\");
                path += name + ".txt";

                file = new FileData(name, path, String.Empty, FileData.FileType.UserFile);
            }

            try
            {
                if (text != null)
                {
                    FileBrowserHelpers.WriteTextToFile(file.Path, text);
                }

                if (!FilesData.Files.Contains(file))
                {
                    FilesData.Files.Add(file);
                }

                SaveFilesData();

                filesListChanged?.Invoke();

                Debug.Log("File is saved. Path: " + file.Path);
            }
            catch
            {
                Debug.Log("Saving file is end error.");
            }
        }