com.wallstop-studios.unity-helpers 2.0.0-rc74.3 → 2.0.0-rc74.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,8 @@
3
3
  "isRoot": true,
4
4
  "tools": {
5
5
  "CSharpier": {
6
- "version": "0.30.6",
7
- "commands": ["dotnet-csharpier"]
6
+ "version": "1.0.1",
7
+ "commands": ["csharpier"]
8
8
  }
9
9
  }
10
10
  }
@@ -15,7 +15,7 @@ repos:
15
15
  description: Install the .NET tools listed at .config/dotnet-tools.json.
16
16
  - id: csharpier
17
17
  name: Run CSharpier on C# files
18
- entry: dotnet tool run dotnet-csharpier
18
+ entry: dotnet tool run Csharpier format
19
19
  language: system
20
20
  types:
21
21
  - c#
@@ -816,6 +816,7 @@
816
816
  int errorCount = 0;
817
817
  HashSet<string> processedAssetPaths = new();
818
818
 
819
+ List<TextureImporter> importers = new();
819
820
  AssetDatabase.StartAssetEditing();
820
821
  try
821
822
  {
@@ -901,6 +902,7 @@
901
902
  if (settingsActuallyModified)
902
903
  {
903
904
  importer.SaveAndReimport();
905
+ importers.Add(importer);
904
906
  modifiedCount++;
905
907
  this.Log(
906
908
  $"Set import settings for texture: {assetPath} (from sprite: {sprite.name}) to uncompressed ({targetFormat})."
@@ -914,8 +916,14 @@
914
916
  EditorUtility.ClearProgressBar();
915
917
  }
916
918
 
919
+ foreach (TextureImporter importer in importers)
920
+ {
921
+ importer.SaveAndReimport();
922
+ }
923
+
917
924
  if (modifiedCount > 0 || errorCount > 0)
918
925
  {
926
+ AssetDatabase.SaveAssets();
919
927
  AssetDatabase.Refresh();
920
928
  }
921
929
 
@@ -559,6 +559,7 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
559
559
  return;
560
560
  }
561
561
 
562
+ List<TextureImporter> importers = new();
562
563
  AssetDatabase.StartAssetEditing();
563
564
  try
564
565
  {
@@ -591,6 +592,7 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
591
592
  try
592
593
  {
593
594
  importer.SaveAndReimport();
595
+ importers.Add(importer);
594
596
  }
595
597
  catch (Exception ex)
596
598
  {
@@ -604,6 +606,11 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
604
606
  {
605
607
  AssetDatabase.StopAssetEditing();
606
608
  EditorUtility.ClearProgressBar();
609
+ foreach (TextureImporter importer in importers)
610
+ {
611
+ importer.SaveAndReimport();
612
+ }
613
+
607
614
  this.Log($"Processed {spriteCount} sprites.");
608
615
  if (0 < spriteCount)
609
616
  {
@@ -0,0 +1,77 @@
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
+ {
3
+ using System;
4
+ using System.IO;
5
+ using System.Threading;
6
+ using System.Threading.Tasks;
7
+ using UnityEngine;
8
+
9
+ public static class FileHelper
10
+ {
11
+ public static bool InitializePath(string path, byte[] contents = null)
12
+ {
13
+ if (File.Exists(path))
14
+ {
15
+ return false;
16
+ }
17
+
18
+ string directory = Path.GetDirectoryName(path);
19
+ if (!string.IsNullOrWhiteSpace(directory))
20
+ {
21
+ Directory.CreateDirectory(directory);
22
+ }
23
+
24
+ try
25
+ {
26
+ using FileStream fileStream = new(
27
+ path,
28
+ FileMode.CreateNew,
29
+ FileAccess.Write,
30
+ FileShare.None
31
+ );
32
+ contents ??= Array.Empty<byte>();
33
+ fileStream.Write(contents, 0, contents.Length);
34
+ return true;
35
+ }
36
+ catch (IOException e)
37
+ {
38
+ Debug.LogError($"File {path} already exists, not creating.\n{e}");
39
+ return false;
40
+ }
41
+ }
42
+
43
+ public static async ValueTask<bool> CopyFileAsync(
44
+ string sourcePath,
45
+ string destinationPath,
46
+ int bufferSize = 81920,
47
+ CancellationToken cancellationToken = default
48
+ )
49
+ {
50
+ try
51
+ {
52
+ await using FileStream sourceStream = new(
53
+ sourcePath,
54
+ FileMode.Open,
55
+ FileAccess.Read,
56
+ FileShare.Read,
57
+ bufferSize,
58
+ useAsync: true
59
+ );
60
+ await using FileStream destinationStream = new(
61
+ destinationPath,
62
+ FileMode.Create,
63
+ FileAccess.Write,
64
+ FileShare.None,
65
+ bufferSize,
66
+ useAsync: true
67
+ );
68
+ await sourceStream.CopyToAsync(destinationStream, bufferSize, cancellationToken);
69
+ return true;
70
+ }
71
+ catch
72
+ {
73
+ return false;
74
+ }
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: ee3c8e7a4b4e493db7e9fb5c9f1fc18d
3
+ timeCreated: 1747784384
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc74.3",
3
+ "version": "2.0.0-rc74.5",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -56,6 +56,8 @@
56
56
 
57
57
 
58
58
 
59
+
60
+
59
61
 
60
62
 
61
63