com.wallstop-studios.unity-helpers 2.0.0-rc73.3 → 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.
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
using UnityEditor;
|
|
10
10
|
using UnityEngine;
|
|
11
11
|
using Core.Extension;
|
|
12
|
+
using Core.Helper;
|
|
12
13
|
|
|
13
14
|
public sealed class AnimationCopierWindow : EditorWindow
|
|
14
15
|
{
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
public string DestinationRelativePath { get; set; }
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
[MenuItem("Tools/Wallstop Studios/Unity Helpers/Animation Copier
|
|
62
|
+
[MenuItem("Tools/Wallstop Studios/Unity Helpers/Animation Copier", priority = -2)]
|
|
62
63
|
public static void ShowWindow()
|
|
63
64
|
{
|
|
64
65
|
GetWindow<AnimationCopierWindow>("Animation Copier");
|
|
@@ -185,7 +186,7 @@
|
|
|
185
186
|
if (newRelPath != null)
|
|
186
187
|
{
|
|
187
188
|
relativePath = newRelPath;
|
|
188
|
-
fullPath = selectedPath.
|
|
189
|
+
fullPath = selectedPath.SanitizePath();
|
|
189
190
|
EditorPrefs.SetString(prefKey, relativePath);
|
|
190
191
|
this.Log($"{label} set to: {relativePath}");
|
|
191
192
|
ValidatePaths();
|
|
@@ -436,7 +437,10 @@
|
|
|
436
437
|
string sourceRelPath = AssetDatabase.GUIDToAssetPath(guid);
|
|
437
438
|
if (
|
|
438
439
|
string.IsNullOrWhiteSpace(sourceRelPath)
|
|
439
|
-
|| !sourceRelPath.StartsWith(
|
|
440
|
+
|| !sourceRelPath.StartsWith(
|
|
441
|
+
_animationSourcePathRelative,
|
|
442
|
+
StringComparison.OrdinalIgnoreCase
|
|
443
|
+
)
|
|
440
444
|
)
|
|
441
445
|
{
|
|
442
446
|
continue;
|
|
@@ -460,7 +464,7 @@
|
|
|
460
464
|
FileName = Path.GetFileName(sourceRelPath),
|
|
461
465
|
RelativeDirectory = GetRelativeSubPath(
|
|
462
466
|
_animationSourcePathRelative,
|
|
463
|
-
directoryName.
|
|
467
|
+
directoryName.SanitizePath()
|
|
464
468
|
),
|
|
465
469
|
Hash = CalculateFileHash(sourceFullPath),
|
|
466
470
|
};
|
|
@@ -469,7 +473,7 @@
|
|
|
469
473
|
fileInfo.RelativeDirectory,
|
|
470
474
|
fileInfo.FileName
|
|
471
475
|
)
|
|
472
|
-
.
|
|
476
|
+
.SanitizePath();
|
|
473
477
|
_sourceAnimations.Add(fileInfo);
|
|
474
478
|
|
|
475
479
|
EditorUtility.DisplayProgressBar(
|
|
@@ -505,7 +509,10 @@
|
|
|
505
509
|
else
|
|
506
510
|
{
|
|
507
511
|
string destHash = CalculateFileHash(destFullPath);
|
|
508
|
-
if (
|
|
512
|
+
if (
|
|
513
|
+
string.IsNullOrWhiteSpace(sourceInfo.Hash)
|
|
514
|
+
|| string.IsNullOrWhiteSpace(destHash)
|
|
515
|
+
)
|
|
509
516
|
{
|
|
510
517
|
this.LogWarn(
|
|
511
518
|
$"Could not compare '{sourceInfo.FileName}' due to hashing error. Treating as 'Changed'."
|
|
@@ -593,8 +600,32 @@
|
|
|
593
600
|
|
|
594
601
|
int successCount = 0;
|
|
595
602
|
int errorCount = 0;
|
|
596
|
-
|
|
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
|
+
}
|
|
597
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();
|
|
598
629
|
try
|
|
599
630
|
{
|
|
600
631
|
for (int i = 0; i < animationsToCopy.Count; i++)
|
|
@@ -615,27 +646,6 @@
|
|
|
615
646
|
|
|
616
647
|
string sourceAssetPath = animInfo.RelativePath;
|
|
617
648
|
string destinationAssetPath = animInfo.DestinationRelativePath;
|
|
618
|
-
string destDirectory = Path.GetDirectoryName(destinationAssetPath);
|
|
619
|
-
|
|
620
|
-
if (
|
|
621
|
-
!string.IsNullOrEmpty(destDirectory)
|
|
622
|
-
&& !AssetDatabase.IsValidFolder(destDirectory)
|
|
623
|
-
)
|
|
624
|
-
{
|
|
625
|
-
try
|
|
626
|
-
{
|
|
627
|
-
EnsureDirectoryExists(destDirectory);
|
|
628
|
-
}
|
|
629
|
-
catch (Exception ex)
|
|
630
|
-
{
|
|
631
|
-
this.LogError(
|
|
632
|
-
$"Failed to create destination directory '{destDirectory}' for animation '{animInfo.FileName}'. Error: {ex.Message}. Skipping."
|
|
633
|
-
);
|
|
634
|
-
errorCount++;
|
|
635
|
-
continue;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
649
|
bool copySuccessful = AssetDatabase.CopyAsset(
|
|
640
650
|
sourceAssetPath,
|
|
641
651
|
destinationAssetPath
|
|
@@ -784,7 +794,7 @@
|
|
|
784
794
|
return null;
|
|
785
795
|
}
|
|
786
796
|
|
|
787
|
-
fullPath = fullPath.
|
|
797
|
+
fullPath = fullPath.SanitizePath();
|
|
788
798
|
if (
|
|
789
799
|
fullPath.EndsWith("/Assets", StringComparison.OrdinalIgnoreCase)
|
|
790
800
|
&& Path.GetFileName(fullPath).Equals("Assets", StringComparison.OrdinalIgnoreCase)
|
|
@@ -793,7 +803,7 @@
|
|
|
793
803
|
return "Assets";
|
|
794
804
|
}
|
|
795
805
|
|
|
796
|
-
string assetsPath = Application.dataPath.
|
|
806
|
+
string assetsPath = Application.dataPath.SanitizePath();
|
|
797
807
|
if (fullPath.StartsWith(assetsPath, StringComparison.OrdinalIgnoreCase))
|
|
798
808
|
{
|
|
799
809
|
if (fullPath.Length == assetsPath.Length)
|
|
@@ -828,7 +838,7 @@
|
|
|
828
838
|
|
|
829
839
|
if (relativePath.Equals("Assets", StringComparison.OrdinalIgnoreCase))
|
|
830
840
|
{
|
|
831
|
-
return Application.dataPath.
|
|
841
|
+
return Application.dataPath.SanitizePath();
|
|
832
842
|
}
|
|
833
843
|
|
|
834
844
|
if (relativePath.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase))
|
|
@@ -837,7 +847,7 @@
|
|
|
837
847
|
0,
|
|
838
848
|
Application.dataPath.Length - "Assets".Length
|
|
839
849
|
);
|
|
840
|
-
return (projectRoot + relativePath).
|
|
850
|
+
return (projectRoot + relativePath).SanitizePath();
|
|
841
851
|
}
|
|
842
852
|
return null;
|
|
843
853
|
}
|
|
@@ -866,28 +876,28 @@
|
|
|
866
876
|
return string.Empty;
|
|
867
877
|
}
|
|
868
878
|
|
|
869
|
-
private
|
|
879
|
+
private string CalculateFileHash(string filePath)
|
|
870
880
|
{
|
|
871
881
|
try
|
|
872
882
|
{
|
|
873
|
-
using
|
|
874
|
-
using
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
return BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();
|
|
878
|
-
}
|
|
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();
|
|
879
887
|
}
|
|
880
888
|
catch (IOException ioEx)
|
|
881
889
|
{
|
|
882
|
-
|
|
883
|
-
$"[AnimationCopierWindow] IO Error calculating hash for {filePath}
|
|
890
|
+
this.LogError(
|
|
891
|
+
$"[AnimationCopierWindow] IO Error calculating hash for {filePath}.",
|
|
892
|
+
ioEx
|
|
884
893
|
);
|
|
885
894
|
return string.Empty;
|
|
886
895
|
}
|
|
887
896
|
catch (Exception ex)
|
|
888
897
|
{
|
|
889
|
-
|
|
890
|
-
$"[AnimationCopierWindow] Error calculating hash for {filePath}
|
|
898
|
+
this.LogError(
|
|
899
|
+
$"[AnimationCopierWindow] Error calculating hash for {filePath}.",
|
|
900
|
+
ex
|
|
891
901
|
);
|
|
892
902
|
return string.Empty;
|
|
893
903
|
}
|
|
@@ -899,6 +909,7 @@
|
|
|
899
909
|
{
|
|
900
910
|
return;
|
|
901
911
|
}
|
|
912
|
+
|
|
902
913
|
if (!relativeDirectoryPath.StartsWith("Assets/"))
|
|
903
914
|
{
|
|
904
915
|
if (relativeDirectoryPath.Equals("Assets", StringComparison.OrdinalIgnoreCase))
|
|
@@ -920,17 +931,15 @@
|
|
|
920
931
|
return;
|
|
921
932
|
}
|
|
922
933
|
|
|
923
|
-
string parentPath = Path.GetDirectoryName(relativeDirectoryPath)
|
|
924
|
-
?.Replace(Path.DirectorySeparatorChar, '/');
|
|
925
|
-
|
|
934
|
+
string parentPath = Path.GetDirectoryName(relativeDirectoryPath).SanitizePath();
|
|
926
935
|
if (
|
|
927
|
-
string.
|
|
936
|
+
string.IsNullOrWhiteSpace(parentPath)
|
|
928
937
|
|| parentPath.Equals("Assets", StringComparison.OrdinalIgnoreCase)
|
|
929
938
|
)
|
|
930
939
|
{
|
|
931
940
|
string folderNameToCreate = Path.GetFileName(relativeDirectoryPath);
|
|
932
941
|
if (
|
|
933
|
-
!string.
|
|
942
|
+
!string.IsNullOrWhiteSpace(folderNameToCreate)
|
|
934
943
|
&& !AssetDatabase.IsValidFolder(relativeDirectoryPath)
|
|
935
944
|
)
|
|
936
945
|
{
|
|
@@ -940,10 +949,9 @@
|
|
|
940
949
|
}
|
|
941
950
|
|
|
942
951
|
EnsureDirectoryExists(parentPath);
|
|
943
|
-
|
|
944
952
|
string currentFolderName = Path.GetFileName(relativeDirectoryPath);
|
|
945
953
|
if (
|
|
946
|
-
!string.
|
|
954
|
+
!string.IsNullOrWhiteSpace(currentFolderName)
|
|
947
955
|
&& !AssetDatabase.IsValidFolder(relativeDirectoryPath)
|
|
948
956
|
)
|
|
949
957
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
using System.Runtime.CompilerServices;
|
|
2
2
|
|
|
3
3
|
[assembly: InternalsVisibleTo(assemblyName: "WallstopStudios.UnityHelpers.Styles")]
|
|
4
|
+
[assembly: InternalsVisibleTo(assemblyName: "WallstopStudios.UnityHelpers.Editor")]
|
|
4
5
|
|
|
5
6
|
namespace WallstopStudios.UnityHelpers.Core.Helper
|
|
6
7
|
{
|
|
@@ -8,7 +9,7 @@ namespace WallstopStudios.UnityHelpers.Core.Helper
|
|
|
8
9
|
{
|
|
9
10
|
public static string SanitizePath(this string path)
|
|
10
11
|
{
|
|
11
|
-
return path
|
|
12
|
+
return path?.Replace('\\', '/');
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
Vertical = 1,
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
public const string
|
|
17
|
-
public const string
|
|
18
|
-
public const string
|
|
19
|
-
public const string
|
|
20
|
-
public const string
|
|
21
|
-
public const string
|
|
22
|
-
public const string
|
|
23
|
-
public const string
|
|
24
|
-
public const string
|
|
25
|
-
public const string
|
|
16
|
+
public const string USSClassName = "marching-ants-progress-bar";
|
|
17
|
+
public const string USSTrackClassName = USSClassName + "__track";
|
|
18
|
+
public const string USSFillContainerClassName = USSClassName + "__fill-container";
|
|
19
|
+
public const string USSFillClassName = USSClassName + "__fill";
|
|
20
|
+
public const string USSTrackColorVarName = "--ants-track-color";
|
|
21
|
+
public const string USSProgressColorVarName = "--ants-progress-color";
|
|
22
|
+
public const string USSThicknessVarName = "--ants-thickness";
|
|
23
|
+
public const string USSBorderRadiusVarName = "--ants-border-radius";
|
|
24
|
+
public const string USSDashOnVarName = "--ants-dash-on";
|
|
25
|
+
public const string USSDashOffVarName = "--ants-dash-off";
|
|
26
26
|
|
|
27
27
|
private readonly VisualElement _trackElement;
|
|
28
28
|
private readonly VisualElement _fillContainer;
|
|
@@ -288,9 +288,9 @@
|
|
|
288
288
|
|
|
289
289
|
public MarchingAntsProgressBar()
|
|
290
290
|
{
|
|
291
|
-
AddToClassList(
|
|
291
|
+
AddToClassList(USSClassName);
|
|
292
292
|
_trackElement = new VisualElement { name = "track", pickingMode = PickingMode.Ignore };
|
|
293
|
-
_trackElement.AddToClassList(
|
|
293
|
+
_trackElement.AddToClassList(USSTrackClassName);
|
|
294
294
|
_trackElement.style.position = Position.Absolute;
|
|
295
295
|
_trackElement.style.left = 0;
|
|
296
296
|
_trackElement.style.top = 0;
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
name = "fill-container",
|
|
304
304
|
pickingMode = PickingMode.Ignore,
|
|
305
305
|
};
|
|
306
|
-
_fillContainer.AddToClassList(
|
|
306
|
+
_fillContainer.AddToClassList(USSFillContainerClassName);
|
|
307
307
|
_fillContainer.style.overflow = Overflow.Hidden;
|
|
308
308
|
_fillContainer.style.position = Position.Absolute;
|
|
309
309
|
_fillContainer.style.left = 0;
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
_fillContainer.style.height = Length.Percent(100);
|
|
313
313
|
Add(_fillContainer);
|
|
314
314
|
_fillElement = new VisualElement { name = "fill", pickingMode = PickingMode.Ignore };
|
|
315
|
-
_fillElement.AddToClassList(
|
|
315
|
+
_fillElement.AddToClassList(USSFillClassName);
|
|
316
316
|
_fillElement.style.position = Position.Absolute;
|
|
317
317
|
_fillElement.style.left = 0;
|
|
318
318
|
_fillElement.style.top = 0;
|
|
@@ -453,7 +453,7 @@
|
|
|
453
453
|
{
|
|
454
454
|
if (
|
|
455
455
|
customStyle.TryGetValue(
|
|
456
|
-
new CustomStyleProperty<Color>(
|
|
456
|
+
new CustomStyleProperty<Color>(USSTrackColorVarName),
|
|
457
457
|
out Color tc
|
|
458
458
|
)
|
|
459
459
|
)
|
|
@@ -463,7 +463,7 @@
|
|
|
463
463
|
|
|
464
464
|
if (
|
|
465
465
|
customStyle.TryGetValue(
|
|
466
|
-
new CustomStyleProperty<Color>(
|
|
466
|
+
new CustomStyleProperty<Color>(USSProgressColorVarName),
|
|
467
467
|
out Color pc
|
|
468
468
|
)
|
|
469
469
|
)
|
|
@@ -473,7 +473,7 @@
|
|
|
473
473
|
|
|
474
474
|
if (
|
|
475
475
|
customStyle.TryGetValue(
|
|
476
|
-
new CustomStyleProperty<float>(
|
|
476
|
+
new CustomStyleProperty<float>(USSThicknessVarName),
|
|
477
477
|
out float th
|
|
478
478
|
)
|
|
479
479
|
)
|
|
@@ -483,7 +483,7 @@
|
|
|
483
483
|
|
|
484
484
|
if (
|
|
485
485
|
customStyle.TryGetValue(
|
|
486
|
-
new CustomStyleProperty<float>(
|
|
486
|
+
new CustomStyleProperty<float>(USSBorderRadiusVarName),
|
|
487
487
|
out float br
|
|
488
488
|
)
|
|
489
489
|
)
|
|
@@ -493,7 +493,7 @@
|
|
|
493
493
|
|
|
494
494
|
if (
|
|
495
495
|
customStyle.TryGetValue(
|
|
496
|
-
new CustomStyleProperty<float>(
|
|
496
|
+
new CustomStyleProperty<float>(USSDashOnVarName),
|
|
497
497
|
out float don
|
|
498
498
|
)
|
|
499
499
|
)
|
|
@@ -503,7 +503,7 @@
|
|
|
503
503
|
|
|
504
504
|
if (
|
|
505
505
|
customStyle.TryGetValue(
|
|
506
|
-
new CustomStyleProperty<float>(
|
|
506
|
+
new CustomStyleProperty<float>(USSDashOffVarName),
|
|
507
507
|
out float doff
|
|
508
508
|
)
|
|
509
509
|
)
|
package/package.json
CHANGED