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)); } }
// in ScoreboardController.cs void CreateAnchor() { // Create the position of the anchor by raycasting a point towards // the top of the screen. Vector2 pos = new Vector2(Screen.width * .5f, Screen.height * .90f); Ray ray = firstPersonCamera.ScreenPointToRay(pos); Vector3 anchorPosition = ray.GetPoint(5f); StartCoroutine(CodelabUtils.Toast( "Pos vec2: " + pos + " anchor pos vec3: " + anchorPosition, 5)); // Create the anchor at that point. if (anchor != null) { DestroyObject(anchor); } anchor = detectedPlane.CreateAnchor( new Pose(anchorPosition, Quaternion.identity)); // Attach the scoreboard to the anchor. transform.position = anchorPosition; transform.SetParent(anchor.transform); // Record the y offset from the plane. yOffset = transform.position.y - detectedPlane.CenterPose.position.y; // Finally, enable the renderers. foreach (Renderer r in GetComponentsInChildren <Renderer>()) { r.enabled = true; } }
void SetSelectedPlane(DetectedPlane selectedPlane) { //Debug.Log("Selected plane centered at " + selectedPlane.CenterPose.position); StartCoroutine(CodelabUtils.Toast( "Selected plane centered at " + selectedPlane.CenterPose.position, 5)); scoreboard.SetSelectedPlane(selectedPlane); snakeController.SetPlane(selectedPlane); }
void QuitOnConnectionErrors() { if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit("Camera access denied", 5)); } else if (Session.Status.IsError()) { StartCoroutine(CodelabUtils.ToastAndExit("ArCORE not connected", 5)); } }
void QuitOnConnectionErrors() { if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit("Camera permission is needed to run this application.", 5)); } else if (Session.Status.IsError()) { StartCoroutine(CodelabUtils.ToastAndExit("ARCore encountered a problem connecting. Please restart the app", 5)); } }
//Checking errors and exit void QuitConnectionErrors() { if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit("Camera permission not given", 5)); } else if (Session.Status.IsError()) { StartCoroutine(CodelabUtils.ToastAndExit("Error has occured restart the app", 5)); } }
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)); } }
public void OnQuitingConnectionErros() { if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit("Permission needed for openning the app", 5)); } else if (Session.Status.IsError()) { StartCoroutine(CodelabUtils.ToastAndExit("Try ReConnecting", 5)); } }
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 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}"); }
void QuitOnConnectionErrors() { if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit("Camera permission is needed to run this application.", 5)); } else if (Session.Status.IsError()) { // This covers a variety of errors. See reference for details // https://developers.google.com/ar/reference/unity/namespace/GoogleARCore StartCoroutine(CodelabUtils.ToastAndExit("ARCore encountered a problem connecting. Please restart the app.", 5)); } }
void QuitOnConnectionErrors() { // Don't update if ARCore is not trackeing if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit("Camera permission is needed for this app", 5)); } else if (Session.Status.IsError()) { //Covers variety of errors StartCoroutine(CodelabUtils.ToastAndExit("ARCore encountered a problem, please restart", 5)); } }
private void QuitOnConnectionErrors() { // Do not update if ARCore is not tracking. if (Session.ConnectionState == SessionConnectionState.UserRejectedNeededPermission) { StartCoroutine(CodelabUtils.ToastAndExit( "Camera permission is needed to run this application.", 5)); } else if (Session.ConnectionState == SessionConnectionState.ConnectToServiceFailed) { StartCoroutine(CodelabUtils.ToastAndExit( "ARCore encountered a problem connecting. Please start the app again.", 5)); } }
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; }
void QuitOnConnectionErrors() { //Do not update if ARCore is not tracking. if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit( "Camera permission is needed to run this application.", 5)); } else if (Session.Status.IsError()) { //covers variety of errors. StartCoroutine(CodelabUtils.ToastAndExit( "ARCore encountered a problem connecting. Please restart the app.", 5)); } }
void QuitOnConnectionErrors() { if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit( "Woah bro, we need some cam permits..", 5)); } else if (Session.Status.IsError()) { //This covers a variety of errors. See reference for details // https://developers.google.com/ar/reference/unity/namespace/GoogleARCore StartCoroutine(CodelabUtils.ToastAndExit( "ARCore couldn't connect to your thingamuhjig bruh. Restart the app.", 5)); } }
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)); } }
void Start() { FindDataContainer(); firstPersonCamera = container.FirstPersonCamera; spawnRoom = GetComponent <SpawnRoom>(); if (Session.Status == SessionStatus.ErrorPermissionNotGranted) { StartCoroutine(CodelabUtils.ToastAndExit( "Camera permission is needed to run this application.", 5)); } else if (Session.Status.IsError()) { StartCoroutine(CodelabUtils.ToastAndExit( "ARCore encountered a problem connecting. Please restart the app.", 5)); } }
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); } }
// Update is called once per frame void Update() { // The session status must be Tracking in order to access the Frame. try { if (Session.Status != SessionStatus.Tracking) { int lostTrackingSleepTimeout = 15; Screen.sleepTimeout = lostTrackingSleepTimeout; return; } Screen.sleepTimeout = SleepTimeout.NeverSleep; } catch (UnityException except) { StartCoroutine(CodelabUtils.ToastAndExit( "error accured: " + except, 5)); } }
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(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"); }
void S(string msg) { CodelabUtils._ShowAndroidToastMessage(msg); }
public void CaptureScreen() { Texture2D screencapture = ScreenCapture.CaptureScreenshotAsTexture(); CodelabUtils._ShowAndroidToastMessage(screencapture.ToString()); }
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"); }