|
1 | 1 | using System; |
2 | | -using System.Collections.Generic; |
3 | 2 | using System.IO; |
4 | 3 | using System.Collections; |
5 | 4 | using UnityEngine; |
@@ -33,11 +32,21 @@ public static string ScreenshotDirectory |
33 | 32 | { |
34 | 33 | get |
35 | 34 | { |
36 | | - string directory = OperatingSystem.IsAndroid() ? Environment.GetEnvironmentVariable("STAR_DATA_PATH") : Path.Combine(Application.persistentDataPath, "NewMod", "Screenshots"); |
37 | | - if (!Directory.Exists(directory)) |
| 35 | + string basePath; |
| 36 | + |
| 37 | + if (OperatingSystem.IsAndroid()) |
| 38 | + { |
| 39 | + basePath = Environment.GetEnvironmentVariable("STAR_DATA_PATH")!; |
| 40 | + } |
| 41 | + else |
38 | 42 | { |
39 | | - Directory.CreateDirectory(directory); |
| 43 | + basePath = Application.persistentDataPath; |
40 | 44 | } |
| 45 | + |
| 46 | + string directory = Path.Combine(basePath, "NewMod", "Screenshots"); |
| 47 | + |
| 48 | + Directory.CreateDirectory(directory); |
| 49 | + |
41 | 50 | return directory; |
42 | 51 | } |
43 | 52 | } |
@@ -151,25 +160,6 @@ public static IEnumerator ShowScreenshot(Sprite sprite, DateTime timestamp, floa |
151 | 160 | _showing = false; |
152 | 161 | } |
153 | 162 |
|
154 | | - // <summary> |
155 | | - /// Loads and displays a screenshot from a given file path. |
156 | | - /// If the file does not exist, no action is taken. |
157 | | - /// </summary> |
158 | | - /// <param name="filePath">The full path of the screenshot file to display.</param> |
159 | | - /// <param name="displayDuration">The duration, in seconds, to display the screenshot.</param> |
160 | | - /// <returns>An IEnumerator coroutine for handling display.</returns> |
161 | | - public static IEnumerator ShowScreenshotByPath(string filePath, float displayDuration) |
162 | | - { |
163 | | - if (!File.Exists(filePath)) yield break; |
164 | | - |
165 | | - byte[] data = File.ReadAllBytes(filePath); |
166 | | - Texture2D tex = new(2, 2); |
167 | | - tex.LoadImage(data); |
168 | | - Sprite screenshotSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)); |
169 | | - |
170 | | - yield return ShowScreenshot(screenshotSprite, File.GetCreationTime(filePath), displayDuration); |
171 | | - } |
172 | | - |
173 | 163 | /// <summary> |
174 | 164 | /// Deletes all screenshots from the Visionary screenshot directory. |
175 | 165 | /// </summary> |
|
0 commit comments