Exemplo n.º 1
0
    //Picture Serialization
    public bool SerializePicture(Picture picture)
    {
        if (picture == null)
        {
            return(false);
        }

        DirectoryInfo pictureDirectory = m_RootPictureDirectory;

        if (m_PictureFolder != "")
        {
            pictureDirectory = FindOrCreateDirectory(m_RootPictureDirectory, m_PictureFolder);
        }

        byte[] bytes = picture.Texture.EncodeToPNG();

        string fileName = string.Format(m_PictureFileName, GameClock.Instance.GetDateTime().ToString("dd-MM-yyyy_HH-mm-ss"));

        fileName = FindUniqueFileName(pictureDirectory, fileName);

        string path = pictureDirectory.FullName + Path.DirectorySeparatorChar + fileName;

        File.WriteAllBytes(path, bytes);

        picture.TextureFilePath = path;

        Debug.Log("Picture succesfully saved!");

        #if UNITY_ANDROID && !UNITY_EDITOR
        DataPathPlugin.RunMediaScanner(path);
        #endif

        return(true);
    }
Exemplo n.º 2
0
    public bool DeleteFile(string path)
    {
        try
        {
            File.Delete(path);

            #if UNITY_ANDROID && !UNITY_EDITOR
            DataPathPlugin.RunMediaScanner(path);
            #endif

            return(true);
        }
        catch (Exception e)
        {
            Debug.LogWarning(e.Message);
            return(false);
        }
    }