com.wallstop-studios.unity-helpers 2.0.0-rc73.4 → 2.0.0-rc73.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.
@@ -437,7 +437,10 @@
437
437
  string sourceRelPath = AssetDatabase.GUIDToAssetPath(guid);
438
438
  if (
439
439
  string.IsNullOrWhiteSpace(sourceRelPath)
440
- || !sourceRelPath.StartsWith(_animationSourcePathRelative)
440
+ || !sourceRelPath.StartsWith(
441
+ _animationSourcePathRelative,
442
+ StringComparison.OrdinalIgnoreCase
443
+ )
441
444
  )
442
445
  {
443
446
  continue;
@@ -506,7 +509,10 @@
506
509
  else
507
510
  {
508
511
  string destHash = CalculateFileHash(destFullPath);
509
- if (string.IsNullOrEmpty(sourceInfo.Hash) || string.IsNullOrEmpty(destHash))
512
+ if (
513
+ string.IsNullOrWhiteSpace(sourceInfo.Hash)
514
+ || string.IsNullOrWhiteSpace(destHash)
515
+ )
510
516
  {
511
517
  this.LogWarn(
512
518
  $"Could not compare '{sourceInfo.FileName}' due to hashing error. Treating as 'Changed'."
@@ -594,8 +600,32 @@
594
600
 
595
601
  int successCount = 0;
596
602
  int errorCount = 0;
597
- AssetDatabase.StartAssetEditing();
603
+ foreach (AnimationFileInfo animInfo in animationsToCopy)
604
+ {
605
+ string destinationAssetPath = animInfo.DestinationRelativePath;
606
+ string destDirectory = Path.GetDirectoryName(destinationAssetPath).SanitizePath();
607
+
608
+ if (
609
+ string.IsNullOrWhiteSpace(destDirectory)
610
+ || AssetDatabase.IsValidFolder(destDirectory)
611
+ )
612
+ {
613
+ continue;
614
+ }
598
615
 
616
+ try
617
+ {
618
+ EnsureDirectoryExists(destDirectory);
619
+ }
620
+ catch (Exception ex)
621
+ {
622
+ this.LogError(
623
+ $"Failed to create destination directory '{destDirectory}' for animation '{animInfo.FileName}'. Error: {ex.Message}. Skipping."
624
+ );
625
+ }
626
+ }
627
+
628
+ AssetDatabase.StartAssetEditing();
599
629
  try
600
630
  {
601
631
  for (int i = 0; i < animationsToCopy.Count; i++)
@@ -616,28 +646,6 @@
616
646
 
617
647
  string sourceAssetPath = animInfo.RelativePath;
618
648
  string destinationAssetPath = animInfo.DestinationRelativePath;
619
- string destDirectory = Path.GetDirectoryName(destinationAssetPath)
620
- .SanitizePath();
621
-
622
- if (
623
- !string.IsNullOrEmpty(destDirectory)
624
- && !AssetDatabase.IsValidFolder(destDirectory)
625
- )
626
- {
627
- try
628
- {
629
- EnsureDirectoryExists(destDirectory);
630
- }
631
- catch (Exception ex)
632
- {
633
- this.LogError(
634
- $"Failed to create destination directory '{destDirectory}' for animation '{animInfo.FileName}'. Error: {ex.Message}. Skipping."
635
- );
636
- errorCount++;
637
- continue;
638
- }
639
- }
640
-
641
649
  bool copySuccessful = AssetDatabase.CopyAsset(
642
650
  sourceAssetPath,
643
651
  destinationAssetPath
@@ -868,28 +876,28 @@
868
876
  return string.Empty;
869
877
  }
870
878
 
871
- private static string CalculateFileHash(string filePath)
879
+ private string CalculateFileHash(string filePath)
872
880
  {
873
881
  try
874
882
  {
875
- using (MD5 md5 = MD5.Create())
876
- using (FileStream stream = File.OpenRead(filePath))
877
- {
878
- byte[] hashBytes = md5.ComputeHash(stream);
879
- return BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();
880
- }
883
+ using MD5 md5 = MD5.Create();
884
+ using FileStream stream = File.OpenRead(filePath);
885
+ byte[] hashBytes = md5.ComputeHash(stream);
886
+ return BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();
881
887
  }
882
888
  catch (IOException ioEx)
883
889
  {
884
- Debug.LogError(
885
- $"[AnimationCopierWindow] IO Error calculating hash for {filePath}: {ioEx.Message}"
890
+ this.LogError(
891
+ $"[AnimationCopierWindow] IO Error calculating hash for {filePath}.",
892
+ ioEx
886
893
  );
887
894
  return string.Empty;
888
895
  }
889
896
  catch (Exception ex)
890
897
  {
891
- Debug.LogError(
892
- $"[AnimationCopierWindow] Error calculating hash for {filePath}: {ex.Message}"
898
+ this.LogError(
899
+ $"[AnimationCopierWindow] Error calculating hash for {filePath}.",
900
+ ex
893
901
  );
894
902
  return string.Empty;
895
903
  }
@@ -901,6 +909,7 @@
901
909
  {
902
910
  return;
903
911
  }
912
+
904
913
  if (!relativeDirectoryPath.StartsWith("Assets/"))
905
914
  {
906
915
  if (relativeDirectoryPath.Equals("Assets", StringComparison.OrdinalIgnoreCase))
@@ -923,15 +932,14 @@
923
932
  }
924
933
 
925
934
  string parentPath = Path.GetDirectoryName(relativeDirectoryPath).SanitizePath();
926
-
927
935
  if (
928
- string.IsNullOrEmpty(parentPath)
936
+ string.IsNullOrWhiteSpace(parentPath)
929
937
  || parentPath.Equals("Assets", StringComparison.OrdinalIgnoreCase)
930
938
  )
931
939
  {
932
940
  string folderNameToCreate = Path.GetFileName(relativeDirectoryPath);
933
941
  if (
934
- !string.IsNullOrEmpty(folderNameToCreate)
942
+ !string.IsNullOrWhiteSpace(folderNameToCreate)
935
943
  && !AssetDatabase.IsValidFolder(relativeDirectoryPath)
936
944
  )
937
945
  {
@@ -941,10 +949,9 @@
941
949
  }
942
950
 
943
951
  EnsureDirectoryExists(parentPath);
944
-
945
952
  string currentFolderName = Path.GetFileName(relativeDirectoryPath);
946
953
  if (
947
- !string.IsNullOrEmpty(currentFolderName)
954
+ !string.IsNullOrWhiteSpace(currentFolderName)
948
955
  && !AssetDatabase.IsValidFolder(relativeDirectoryPath)
949
956
  )
950
957
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc73.4",
3
+ "version": "2.0.0-rc73.5",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -40,3 +40,4 @@
40
40
 
41
41
 
42
42
 
43
+