| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using MainScripts.DCL.AssetsEmbedment.Runtime; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.IO; |
| | 5 | | using System.Linq; |
| | 6 | | using System.Threading.Tasks; |
| | 7 | | using UnityEngine; |
| | 8 | |
|
| | 9 | | namespace MainScripts.DCL.AssetsEmbedment.Editor |
| | 10 | | { |
| | 11 | | public class TextureEmbedder : AssetEmbedder |
| | 12 | | { |
| 0 | 13 | | internal static string texturesPath => Path.Combine(Application.dataPath, "Resources", EmbeddedTextureResourcesP |
| | 14 | |
|
| | 15 | | public static async UniTask EmbedAsync(Dictionary<string, Texture2D> loadedData, string subPath) |
| | 16 | | { |
| 0 | 17 | | var targetPath = string.IsNullOrEmpty(subPath) ? texturesPath : Path.Combine(texturesPath, subPath); |
| 0 | 18 | | ResetTargetPath(targetPath); |
| | 19 | |
|
| 0 | 20 | | var encodedToPng = loadedData.Select(kvp => (kvp.Key, kvp.Value.EncodeToPNG())).ToList(); |
| | 21 | |
|
| 0 | 22 | | await Task.WhenAll(encodedToPng.Select(d => File.WriteAllBytesAsync(Path.Combine(targetPath, d.Key + ".png") |
| 0 | 23 | | await UniTask.SwitchToMainThread(); |
| 0 | 24 | | } |
| | 25 | | } |
| | 26 | | } |