private IEnumerator Register(string email, string password) { var auth = FirebaseAuth.DefaultInstance; var registerTask = auth.CreateUserWithEmailAndPasswordAsync(email, password); yield return(new WaitUntil(() => registerTask.IsCompleted)); if (registerTask.Exception != null) { Debug.LogWarning($"Failed to register user with {registerTask.Exception}"); CodelabUtils._ShowAndroidToastMessage($"Failed to register user with {registerTask.Exception}"); } else { Debug.LogWarning($"Successfully Registered user {registerTask.Result.Email}"); CodelabUtils._ShowAndroidToastMessage($"Successfully Registered user {registerTask.Result.Email}"); currentUser = registerTask.Result; User user = new User(currentUser.UserId, name.text, email, company.text); string json = JsonUtility.ToJson(user); _reference.Child(currentUser.UserId).SetRawJsonValueAsync(json); CodelabUtils._ShowAndroidToastMessage("User saved to Database"); StartCoroutine(SceneWaitLoader(3f)); } }
public void SaveButton() { if (String.IsNullOrEmpty(Name.text) || String.IsNullOrEmpty(Lat.text) || String.IsNullOrEmpty(Lng.text) || String.IsNullOrEmpty(Info.text)) { CodelabUtils._ShowAndroidToastMessage("Please fill-in the missing details"); } else { StartCoroutine(AddToFirebase(Name.text, Double.Parse(Lat.text), Double.Parse(Lng.text), VideoUrl.text, Info.text)); } }
private IEnumerator GetFileUri(StorageMetadata storageMetadata) { var uritask = storageMetadata.Reference.GetDownloadUrlAsync(); yield return(new WaitUntil(() => uritask.IsCompleted)); String uri = uritask.Result.ToString(); imageURLs.Add(uri); CodelabUtils._ShowAndroidToastMessage($"Successfully stored Uri to list : {uri}"); }
public void PreviewItemClick(PreviewItem previewItem) { CodelabUtils._ShowAndroidToastMessage("Preview Image is clicked"); overpreview.texture = previewItem.preview; Texture2D texture = previewItem.preview; Sprite image = Sprite.Create(texture, new Rect(0f, 0f, 512f, 512f), new Vector2(0, 0)); imagepreview.sprite = image; }
private IEnumerator LoadUser(DatabaseReference reference) { var userasync = Load(reference); yield return(new WaitUntil(() => userasync.IsCompleted)); user = userasync.Result; CodelabUtils._ShowAndroidToastMessage($" normal {user.Name} or prop {user.Name1} and normal {user.Company} or prop {user.Company1}"); name.text = user.Name; company.text = user.Company; //_coroutine = null; }
public void signUp() { CodelabUtils._ShowAndroidToastMessage("SignUp pressed"); CodelabUtils._ShowAndroidToastMessage("This are the entrys : " + name.text + " " + email.text + " " + password.text + " " + company.text); if (string.IsNullOrEmpty(name.text) && string.IsNullOrEmpty(email.text) && string.IsNullOrEmpty(password.text) && string.IsNullOrEmpty(company.text)) { CodelabUtils._ShowAndroidToastMessage("Please fill in the missing entries"); } else { StartCoroutine(Register(email.text, password.text)); } }
public void signIn() { CodelabUtils._ShowAndroidToastMessage("SignIn clicked"); _emailtext = email.text; _passwordtext = password.text; if (string.IsNullOrEmpty(_emailtext) && string.IsNullOrEmpty(_passwordtext)) { CodelabUtils._ShowAndroidToastMessage("Please fill the Email and Password entry"); } else { CodelabUtils._ShowAndroidToastMessage("This are the entered details: " + _emailtext + " " + _passwordtext); StartCoroutine(Login(_emailtext, _passwordtext)); } }
private IEnumerator downloadTexture(string imagestring) { Texture2D texture = new Texture2D(512, 512); //var handler = UnityWebRequestTexture.GetTexture(asset.images[0]).downloadHandler; UnityWebRequest www = UnityWebRequestTexture.GetTexture(imagestring); // yield return new WaitUntil(() => handler.isDone); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { CodelabUtils._ShowAndroidToastMessage($"Something went wrong : {www.error}"); } else { texture = ((DownloadHandlerTexture)www.downloadHandler).texture; // ---------------------- or ------------------------- // texture = DownloadHandlerTexture.GetContent(www); CodelabUtils._ShowAndroidToastMessage($"Texture is got"); } PreviewItem previewItem = new PreviewItem(texture, imagestring); CodelabUtils._ShowAndroidToastMessage($"downloadtexture : Adding Item {previewItem.id}"); // TODO: check if the itemchild is contain in the Itemchildren. use a method to loop through the itemchildren and check // Add to the preview list and spawn the image object if (!isPreviewInList.Contains(previewItem.id)) { previewItems.Add(previewItem); SpawnPreview(previewItems); isPreviewInList.Add(previewItem.id); } }
private IEnumerator Login(string email, string password) { var auth = FirebaseAuth.DefaultInstance; var registerTask = auth.SignInWithEmailAndPasswordAsync(email, password); yield return(new WaitUntil(() => registerTask.IsCompleted)); if (registerTask.Exception != null) { Debug.LogWarning($"Failed to Login user with {registerTask.Exception}"); CodelabUtils._ShowAndroidToastMessage($"Failed to Login user with {registerTask.Exception}"); } else { Debug.LogWarning($"Successfully logged in user {registerTask.Result.Email}"); CodelabUtils._ShowAndroidToastMessage($"Successfully logged in User {registerTask.Result.Email}"); SceneManager.LoadScene("Main"); } }
// Start is called before the first frame update void Start() { //RegisterManager.FireInitializer(); FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://augmentedestate.firebaseio.com/"); var auth = FirebaseAuth.DefaultInstance; if (auth.CurrentUser != null) { currentUser = auth.CurrentUser; CodelabUtils._ShowAndroidToastMessage(currentUser.UserId); } CodelabUtils._ShowAndroidToastMessage(PathString.Users); userreference = FirebaseDatabase.DefaultInstance.RootReference.Child(PathString.Users).Child(currentUser.UserId); StartCoroutine(LoadUser(userreference)); }
public void RetrieveImage() { if (NativeGallery.CheckPermission() != NativeGallery.Permission.Granted) { NativeGallery.Permission permission = NativeGallery.RequestPermission(); CodelabUtils._ShowAndroidToastMessage("Please Grant the permission before you continue"); } //else //{ NativeGallery.Permission permissionr = NativeGallery.GetImageFromGallery((path) => { if (path != null) { CodelabUtils._ShowAndroidToastMessage($"Image path {path}"); // Create Texture from selected image Texture2D texture = NativeGallery.LoadImageAtPath(path, 512); if (texture == null) { CodelabUtils._ShowAndroidToastMessage($"Could not load texturee from {path}"); CodelabUtils._ShowAndroidToastMessage($"Could not load texturee from {path}"); return; } // add to the list of texture item AddItem(new Item(texture, path)); refreshList(); /*StartCoroutine(StoreImages(new Item(texture, path), * path.Substring(path.Length - 10, path.Length)));*/ } }, "Select an Image", "image/*"); //} }
private IEnumerator StoreImages(StorageReference storageReference, Item item, string name) { String path = item.id; string id = path.Substring(path.LastIndexOf("/", StringComparison.Ordinal), path.Length); StorageReference reference = storageReference.Child(PathString.Images).Child(name).Child(id); var storagetask = reference.PutFileAsync(path); yield return(new WaitUntil(() => storagetask.IsCompleted)); CodelabUtils._ShowAndroidToastMessage("Upload completed Successfully"); var uritask = storagetask.Result.Reference.GetDownloadUrlAsync(); yield return(new WaitUntil(() => uritask.IsCompleted)); String uri = uritask.Result.ToString(); imageURLs.Add(uri); CodelabUtils._ShowAndroidToastMessage($"Successfully stored Uri to list : {uri}"); //StartCoroutine(GetFileUri(storagetask.Result)); }
IEnumerator AddToFirebase(string name, double lat, double lng, string videourl, string textcontent) { DatabaseReference pushReference = dataReference.Push(); string key = pushReference.Key; HistoricStreet historicStreet = new HistoricStreet(name, lat, lng, videourl, textcontent, key); string json = JsonUtility.ToJson(historicStreet); var pushtask = pushReference.SetRawJsonValueAsync(json); yield return(new WaitUntil(() => pushtask.IsCompleted)); if (pushtask.Exception != null) { CodelabUtils._ShowAndroidToastMessage("Something went wrong while uploading data"); } else { CodelabUtils._ShowAndroidToastMessage("Data Successfully uploaded"); SceneManager.LoadScene(ConstantString.MAINSCENE, LoadSceneMode.Additive); } }
private IEnumerator StoreImages(Item item, string namee) { String path = item.id; string id = path; //path.Substring(path.LastIndexOf("/", StringComparison.Ordinal), path.Length); CodelabUtils._ShowAndroidToastMessage($"The ID : {id}"); var storage = FirebaseStorage.DefaultInstance; var referenced = storage.GetReferenceFromUrl("gs://augmentedestate.appspot.com");//storage.GetReference($"/{PathString.Assets}/{namee}/{id}"); var reference = referenced.Child(PathString.Assets).Child(namee).Child(id); CodelabUtils._ShowAndroidToastMessage("Storage reference got"); //var bytes = item.image.EncodeToPNG(); CodelabUtils._ShowAndroidToastMessage("byte encoded"); //var uploadTask = reference.PutBytesAsync(bytes); Stream stream = new FileStream(path, FileMode.Open); //var uploadTask = reference.PutFileAsync(path); var uploadTask = reference.PutStreamAsync(stream); yield return(new WaitUntil(() => uploadTask.IsCompleted)); CodelabUtils._ShowAndroidToastMessage("Image uploaded successfully"); // check errors if (uploadTask.Exception != null) { CodelabUtils._ShowAndroidToastMessage($"Failed to upload image {uploadTask.Exception}"); yield break; } // get the download uri var getUriTask = reference.GetDownloadUrlAsync(); yield return(new WaitUntil(() => getUriTask.IsCompleted)); if (getUriTask.Exception != null) { CodelabUtils._ShowAndroidToastMessage($"Failed to upload image {getUriTask.Exception}"); yield break; } String uri = getUriTask.Result.ToString(); imageURLs.Add(uri); CodelabUtils._ShowAndroidToastMessage($"Successfully stored Uri to list : {uri}"); string namestring = name.text; string labelstring = label.text; string describestring = description.text; Asset asset = new Asset(namestring, labelstring, describestring, imageURLs); string json = JsonUtility.ToJson(asset); database.Child(namestring).SetRawJsonValueAsync(json); CodelabUtils._ShowAndroidToastMessage("Successfully uploaded the Asset"); // clear all the data collected name.text = " "; label.text = " "; description.text = " "; items.Clear(); //RemoveImages(); CodelabUtils._ShowAndroidToastMessage("Cleared all data"); }
public void CaptureScreen() { Texture2D screencapture = ScreenCapture.CaptureScreenshotAsTexture(); CodelabUtils._ShowAndroidToastMessage(screencapture.ToString()); }
void S(string msg) { CodelabUtils._ShowAndroidToastMessage(msg); }
private IEnumerator StoreImages(List <Item> items, string namee) { foreach (Item item in items) { String path = item.id; //string id = path; //path.Substring(path.LastIndexOf("/"), path.Length); CodelabUtils._ShowAndroidToastMessage($"The ID : {path}"); string id = $"{namee}as{DateTime.Now.Millisecond}"; CodelabUtils._ShowAndroidToastMessage(id); var storage = FirebaseStorage.DefaultInstance; var referenced = storage.GetReferenceFromUrl("gs://augmentedestate.appspot.com"); var reference = referenced.Child(PathString.Assets).Child(namee).Child(id); CodelabUtils._ShowAndroidToastMessage("Storage reference got"); CodelabUtils._ShowAndroidToastMessage("byte encoded"); Stream stream = new FileStream(path, FileMode.Open); var uploadTask = reference.PutStreamAsync(stream); yield return(new WaitUntil(() => uploadTask.IsCompleted)); CodelabUtils._ShowAndroidToastMessage("Image uploaded successfully"); // check errors if (uploadTask.Exception != null) { CodelabUtils._ShowAndroidToastMessage($"Failed to upload image {uploadTask.Exception}"); yield break; } // get the download uri var getUriTask = reference.GetDownloadUrlAsync(); yield return(new WaitUntil(() => getUriTask.IsCompleted)); if (getUriTask.Exception != null) { CodelabUtils._ShowAndroidToastMessage($"Failed to upload image {getUriTask.Exception}"); yield break; } String uri = getUriTask.Result.ToString(); imageURLs.Add(uri); CodelabUtils._ShowAndroidToastMessage($"Successfully stored Uri to list : {uri}"); } string namestring = name.text; string labelstring = label.text; string describestring = description.text; DatabaseReference referec = database.Push(); string key = referec.Key; Asset asset = new Asset(namestring, labelstring, key, describestring, imageURLs); string json = JsonUtility.ToJson(asset); referec.SetRawJsonValueAsync(json); CodelabUtils._ShowAndroidToastMessage("Successfully uploaded the Asset"); // clear all the data collected name.text.Remove(0); label.text.Remove(0); description.text.Remove(0); items.Clear(); //RemoveImages(); CodelabUtils._ShowAndroidToastMessage("Cleared all data"); }