/// <summary> /// Resets all values under advanced settings to their defaults, /// and asks the user whether to remove all stored bitmaps. /// </summary> public void ResetSettings() { SettingExtender.SaveDefaultSettings(); SettingManager.LoadSettings(); QuestionPopup.ActivatePopup(DeleteBitmapsPrompt, yes => { if (yes) { string path = Path.Combine(BitmapEncoding.PersistentPath, BitmapEncoding.BitmapFileName); if (File.Exists(path)) { File.Delete(path); } print("Deleted bitmaps"); TakePicture.Instance.storedBitmaps = BitmapEncoding.LoadBitmaps(); } }); }
/// <summary> /// Initialization code for the major parts of the application. /// </summary> void Start() { Screen.fullScreen = false; //set up references debugText = DebugTextInstance.GetComponent <Text>(); debugText.enabled = true; Instance = this; Popup.Instance = infoPopup; QuestionPopup.Instance = questionPopup; BitmapEncoding.PersistentPath = Application.persistentDataPath; foreach (var v in WebCamTexture.devices) { print("\"" + v.name + "\"" + (v.isFrontFacing ? " (Front facing)" : "")); } print("Persistent: " + BitmapEncoding.PersistentPath); //load persistent data Status = "Loading Digit Bitmaps"; storedBitmaps = BitmapEncoding.LoadBitmaps(); Status = "Loading Settings"; SettingManager.LoadSettings(); //start camera Status = "Looking for cameras"; try { texture = new WebCamTexture(CameraName); texture.Play(); if (WebCamTexture.devices.Length == 0) { throw new System.Exception(NoCamerasMessage); } } catch (System.Exception e) { Popup.ActivatePopup("Could not start the camera:" + System.Environment.NewLine + e.Message); CameraUI.enabled = OverlayUI.enabled = false; } textureWidth = texture.width; textureHeight = texture.height; side = Mathf.Min(textureWidth, textureHeight) - 10; //create overlay, rotate and stretch images correctly Status = "Assigning images"; Texture2D overlay = CreateOverlay(textureWidth, textureHeight, side); OverlayUI.texture = overlay; CameraUI.texture = texture; CameraUI.GetComponent <AspectRatioFitter>().aspectRatio = textureWidth / (float)textureHeight; if ((texture.videoRotationAngle + 360) % 180 == 90) { int i = textureWidth; textureWidth = textureHeight; textureHeight = i; } CameraUI.transform.parent.localEulerAngles = new Vector3(0, 0, -texture.videoRotationAngle); SudokuPanel.GetComponent <SudokuCreator>().Init(); Status = "Ready to take picture"; debugText.enabled = false; }