// Methods /// <summary> /// Save the <see cref="ImageTexture"/> on a image file in the <see cref="OutputFolder"/> with <see cref="ImageFilename"/> as filename. /// </summary> public virtual void Save() { if (ImageFilename == null || ImageFilename.Length == 0) { ImageFilename = ArucoObject.GenerateName() + ".png"; } string outputFolderPath = Path.Combine((Application.isEditor) ? Application.dataPath : Application.persistentDataPath, OutputFolder); if (!Directory.Exists(outputFolderPath)) { Directory.CreateDirectory(outputFolderPath); } string imageFilePath = outputFolderPath + ImageFilename; File.WriteAllBytes(imageFilePath, ImageTexture.EncodeToPNG()); }
// ArucoObjectDisplayer methods /// <summary> /// Calls <see cref="ArucoObjectDisplayer.UpdateImage"/> then <see cref="SaveImage"/> if <see cref="AutoSaveImage"/> /// is set. Also set <see cref="ImageFilename"/> in the editor. /// </summary> protected override void UpdateImage() { base.UpdateImage(); #if UNITY_EDITOR if (automaticFilename) { ImageFilename = ArucoObject.GenerateName(); } #endif #if UNITY_EDITOR if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) { #endif if (AutoSaveImage) { SaveImage(); } #if UNITY_EDITOR } #endif }