93 lines
2.3 KiB
C#
93 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System.IO;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Video;
|
|
|
|
public class WriteFile : MonoBehaviour
|
|
{
|
|
#region text
|
|
//string filePath = Application.persistentDataPath + "/login.txt";
|
|
string filePath = Path.Combine("/storage/emulated/0/Android/media/com.myrobot/shared/", "login.txt");
|
|
|
|
public bool checkFile()
|
|
{
|
|
if (!File.Exists(filePath))
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public void Error(string error)
|
|
{
|
|
Text txtError = GameObject.Find("txtError").GetComponent<Text>();
|
|
txtError.text = error;
|
|
}
|
|
|
|
public void DeleteFile()
|
|
{
|
|
File.Delete(filePath);
|
|
}
|
|
|
|
public void CreateFile(string usuario, string senha, string reference, string iplocal, string idunit, string userType)
|
|
{
|
|
File.WriteAllText(filePath, reference + ".dbo.;" + usuario + ";" + senha + ";" + iplocal + ";" + idunit + ";" + userType);
|
|
//Debug.Log(reference + ".dbo.; " + usuario + "; " + senha + "; " + iplocal);
|
|
}
|
|
#endregion
|
|
|
|
#region Audio
|
|
public void CreateAudio(AudioClip clip){
|
|
SavWav.Save("tempAudio", clip);
|
|
}
|
|
|
|
public AudioClip audioLoaded;
|
|
|
|
public void GetAudioClip() {
|
|
StartCoroutine(loadAudio());
|
|
}
|
|
|
|
public IEnumerator loadAudio(string NomeArquivo = "tempAudio.wav")
|
|
{
|
|
WWW request = getAudioFile("file://" + Application.persistentDataPath + "/" + NomeArquivo);
|
|
yield return request;
|
|
|
|
audioLoaded = request.GetAudioClip();
|
|
audioLoaded.name = NomeArquivo;
|
|
}
|
|
|
|
public WWW getAudioFile(string path) {
|
|
WWW request = new WWW(path);
|
|
return request;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Video
|
|
|
|
public VideoClip videoLoaded;
|
|
|
|
public IEnumerator loadVideo(string NomeArquivo)
|
|
{
|
|
WWW request = getVideoFile("file://" + Application.persistentDataPath + "/" + NomeArquivo);
|
|
yield return request;
|
|
|
|
//videoLoaded = request.GetAudioClip();
|
|
Debug.Log(videoLoaded.length);
|
|
videoLoaded.name = NomeArquivo;
|
|
}
|
|
|
|
public WWW getVideoFile(string path)
|
|
{
|
|
WWW request = new WWW(path);
|
|
return request;
|
|
}
|
|
|
|
#endregion
|
|
}
|