com.wallstop-studios.unity-helpers 2.0.0-rc73.8 → 2.0.0-rc74.0
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.
- package/Editor/AnimationEventEditor.cs +4 -5
- package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +1 -1
- package/Editor/CustomEditors/PersistentDirectoryGUI.cs +796 -0
- package/Editor/CustomEditors/PersistentDirectoryGUI.cs.meta +3 -0
- package/Editor/CustomEditors/SourceFolderEntryDrawer.cs +275 -0
- package/Editor/CustomEditors/SourceFolderEntryDrawer.cs.meta +3 -0
- package/Editor/FitTextureSizeWindow.cs +5 -44
- package/Editor/PersistentDirectorySettings.cs +248 -0
- package/Editor/PersistentDirectorySettings.cs.meta +3 -0
- package/Editor/PrefabChecker.cs +1 -2
- package/Editor/{AnimationCopier.cs → Sprites/AnimationCopier.cs} +33 -166
- package/Editor/{AnimationCreator.cs → Sprites/AnimationCreator.cs} +16 -80
- package/Editor/Sprites/ScriptableSpriteAtlas.cs +95 -0
- package/Editor/Sprites/ScriptableSpriteAtlas.cs.meta +3 -0
- package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs +930 -0
- package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs.meta +3 -0
- package/Editor/{SpriteCropper.cs → Sprites/SpriteCropper.cs} +80 -77
- package/Editor/{SpriteSettingsApplier.cs → Sprites/SpriteSettingsApplier.cs} +9 -76
- package/Editor/{TextureResizerWizard.cs → Sprites/TextureResizerWizard.cs} +1 -1
- package/Editor/{TextureSettingsApplier.cs → Sprites/TextureSettingsApplier.cs} +1 -1
- package/Editor/Sprites.meta +3 -0
- package/Editor/Utils/DxReadOnlyPropertyDrawer.cs +1 -1
- package/Runtime/Core/Helper/DirectoryHelper.cs +64 -0
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +3 -2
- package/Runtime/UI/LayeredImage.cs +10 -8
- package/package.json +13 -1
- package/Editor/SpriteAtlasGenerator.cs +0 -895
- package/Editor/SpriteAtlasGenerator.cs.meta +0 -3
- package/Editor/Utils/GUIHorizontalScope.cs +0 -20
- package/Editor/Utils/GUIHorizontalScope.cs.meta +0 -3
- package/Editor/Utils/GUIIndentScope.cs +0 -20
- package/Editor/Utils/GUIIndentScope.cs.meta +0 -3
- /package/Editor/{AnimationCopier.cs.meta → Sprites/AnimationCopier.cs.meta} +0 -0
- /package/Editor/{AnimationCreator.cs.meta → Sprites/AnimationCreator.cs.meta} +0 -0
- /package/Editor/{SpriteCropper.cs.meta → Sprites/SpriteCropper.cs.meta} +0 -0
- /package/Editor/{SpriteSettingsApplier.cs.meta → Sprites/SpriteSettingsApplier.cs.meta} +0 -0
- /package/Editor/{TextureResizerWizard.cs.meta → Sprites/TextureResizerWizard.cs.meta} +0 -0
- /package/Editor/{TextureSettingsApplier.cs.meta → Sprites/TextureSettingsApplier.cs.meta} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
namespace WallstopStudios.UnityHelpers.Editor
|
|
1
|
+
namespace WallstopStudios.UnityHelpers.Editor.Sprites
|
|
2
2
|
{
|
|
3
3
|
#if UNITY_EDITOR
|
|
4
4
|
using System;
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
using System.IO;
|
|
7
7
|
using System.Linq;
|
|
8
8
|
using System.Threading.Tasks;
|
|
9
|
-
using Core.Extension;
|
|
10
9
|
using UnityEditor;
|
|
11
10
|
using UnityEngine;
|
|
11
|
+
using Core.Extension;
|
|
12
|
+
using CustomEditors;
|
|
12
13
|
using Object = UnityEngine.Object;
|
|
13
14
|
|
|
14
15
|
public sealed class SpriteCropper : EditorWindow
|
|
@@ -35,64 +36,55 @@
|
|
|
35
36
|
[SerializeField]
|
|
36
37
|
private bool _onlyNecessary;
|
|
37
38
|
|
|
39
|
+
[SerializeField]
|
|
40
|
+
private int _leftPadding;
|
|
41
|
+
|
|
42
|
+
[SerializeField]
|
|
43
|
+
private int _rightPadding;
|
|
44
|
+
|
|
45
|
+
[SerializeField]
|
|
46
|
+
private int _topPadding;
|
|
47
|
+
|
|
48
|
+
[SerializeField]
|
|
49
|
+
private int _bottomPadding;
|
|
50
|
+
|
|
38
51
|
private List<string> _filesToProcess;
|
|
52
|
+
private SerializedObject _serializedObject;
|
|
53
|
+
private SerializedProperty _inputDirectoriesProperty;
|
|
54
|
+
private SerializedProperty _onlyNecessaryProperty;
|
|
55
|
+
private SerializedProperty _leftPaddingProperty;
|
|
56
|
+
private SerializedProperty _rightPaddingProperty;
|
|
57
|
+
private SerializedProperty _topPaddingProperty;
|
|
58
|
+
private SerializedProperty _bottomPaddingProperty;
|
|
39
59
|
|
|
40
60
|
[MenuItem("Tools/Wallstop Studios/Unity Helpers/" + Name)]
|
|
41
61
|
private static void ShowWindow() => GetWindow<SpriteCropper>(Name);
|
|
42
62
|
|
|
63
|
+
private void OnEnable()
|
|
64
|
+
{
|
|
65
|
+
_serializedObject = new SerializedObject(this);
|
|
66
|
+
_inputDirectoriesProperty = _serializedObject.FindProperty(nameof(_inputDirectories));
|
|
67
|
+
_onlyNecessaryProperty = _serializedObject.FindProperty(nameof(_onlyNecessary));
|
|
68
|
+
_leftPaddingProperty = _serializedObject.FindProperty(nameof(_leftPadding));
|
|
69
|
+
_rightPaddingProperty = _serializedObject.FindProperty(nameof(_rightPadding));
|
|
70
|
+
_topPaddingProperty = _serializedObject.FindProperty(nameof(_topPadding));
|
|
71
|
+
_bottomPaddingProperty = _serializedObject.FindProperty(nameof(_bottomPadding));
|
|
72
|
+
}
|
|
73
|
+
|
|
43
74
|
private void OnGUI()
|
|
44
75
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
EditorGUILayout.PropertyField(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"Select Sprite Input Folder",
|
|
58
|
-
Application.dataPath,
|
|
59
|
-
""
|
|
60
|
-
);
|
|
61
|
-
if (!string.IsNullOrWhiteSpace(path))
|
|
62
|
-
{
|
|
63
|
-
if (path.StartsWith(Application.dataPath, StringComparison.Ordinal))
|
|
64
|
-
{
|
|
65
|
-
path = "Assets" + path.Substring(Application.dataPath.Length);
|
|
66
|
-
if (
|
|
67
|
-
!_inputDirectories
|
|
68
|
-
.Select(AssetDatabase.GetAssetPath)
|
|
69
|
-
.Any(directory =>
|
|
70
|
-
string.Equals(
|
|
71
|
-
directory,
|
|
72
|
-
path,
|
|
73
|
-
StringComparison.OrdinalIgnoreCase
|
|
74
|
-
)
|
|
75
|
-
)
|
|
76
|
-
)
|
|
77
|
-
{
|
|
78
|
-
Object folder = AssetDatabase.LoadAssetAtPath<Object>(path);
|
|
79
|
-
if (folder == null)
|
|
80
|
-
{
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
_inputDirectories.Add(folder);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else
|
|
87
|
-
{
|
|
88
|
-
EditorUtility.DisplayDialog(
|
|
89
|
-
"Invalid Folder",
|
|
90
|
-
"Please select a folder inside the project's Assets directory.",
|
|
91
|
-
"OK"
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
76
|
+
EditorGUILayout.LabelField("Input directories", EditorStyles.boldLabel);
|
|
77
|
+
_serializedObject.Update();
|
|
78
|
+
PersistentDirectoryGUI.PathSelectorObjectArray(
|
|
79
|
+
_inputDirectoriesProperty,
|
|
80
|
+
nameof(SpriteCropper)
|
|
81
|
+
);
|
|
82
|
+
EditorGUILayout.PropertyField(_onlyNecessaryProperty, true);
|
|
83
|
+
EditorGUILayout.PropertyField(_leftPaddingProperty, true);
|
|
84
|
+
EditorGUILayout.PropertyField(_rightPaddingProperty, true);
|
|
85
|
+
EditorGUILayout.PropertyField(_topPaddingProperty, true);
|
|
86
|
+
EditorGUILayout.PropertyField(_bottomPaddingProperty, true);
|
|
87
|
+
_serializedObject.ApplyModifiedProperties();
|
|
96
88
|
|
|
97
89
|
if (GUILayout.Button("Find Sprites To Process"))
|
|
98
90
|
{
|
|
@@ -217,6 +209,10 @@
|
|
|
217
209
|
finally
|
|
218
210
|
{
|
|
219
211
|
AssetDatabase.StopAssetEditing();
|
|
212
|
+
foreach (TextureImporter newImporter in newImporters)
|
|
213
|
+
{
|
|
214
|
+
newImporter.SaveAndReimport();
|
|
215
|
+
}
|
|
220
216
|
AssetDatabase.SaveAssets();
|
|
221
217
|
AssetDatabase.Refresh();
|
|
222
218
|
}
|
|
@@ -229,9 +225,6 @@
|
|
|
229
225
|
$"An error occurred during processing. Last processed: {lastProcessed}.",
|
|
230
226
|
e
|
|
231
227
|
);
|
|
232
|
-
AssetDatabase.StopAssetEditing();
|
|
233
|
-
AssetDatabase.SaveAssets();
|
|
234
|
-
AssetDatabase.Refresh();
|
|
235
228
|
}
|
|
236
229
|
finally
|
|
237
230
|
{
|
|
@@ -302,9 +295,7 @@
|
|
|
302
295
|
int maxX = 0;
|
|
303
296
|
int maxY = 0;
|
|
304
297
|
bool hasVisible = false;
|
|
305
|
-
|
|
306
298
|
object lockObject = new();
|
|
307
|
-
|
|
308
299
|
Parallel.For(
|
|
309
300
|
0,
|
|
310
301
|
width * height,
|
|
@@ -341,15 +332,26 @@
|
|
|
341
332
|
}
|
|
342
333
|
);
|
|
343
334
|
|
|
335
|
+
int cropWidth;
|
|
336
|
+
int cropHeight;
|
|
344
337
|
if (!hasVisible)
|
|
345
338
|
{
|
|
346
|
-
|
|
339
|
+
cropWidth = 1;
|
|
340
|
+
cropHeight = 1;
|
|
341
|
+
minX = 0;
|
|
342
|
+
minY = 0;
|
|
343
|
+
}
|
|
344
|
+
else
|
|
345
|
+
{
|
|
346
|
+
minX = Mathf.Max(0, minX - _leftPadding);
|
|
347
|
+
minY = Mathf.Max(0, minY - _bottomPadding);
|
|
348
|
+
maxX = Mathf.Min(width, maxX + _rightPadding);
|
|
349
|
+
maxY = Mathf.Min(height, maxY + _topPadding);
|
|
350
|
+
cropWidth = maxX - minX + 1;
|
|
351
|
+
cropHeight = maxY - minY + 1;
|
|
347
352
|
}
|
|
348
353
|
|
|
349
|
-
|
|
350
|
-
int cropHeight = maxY - minY + 1;
|
|
351
|
-
|
|
352
|
-
if (_onlyNecessary && cropWidth == width && cropHeight == height)
|
|
354
|
+
if (_onlyNecessary && (!hasVisible || (cropWidth == width && cropHeight == height)))
|
|
353
355
|
{
|
|
354
356
|
return null;
|
|
355
357
|
}
|
|
@@ -387,17 +389,8 @@
|
|
|
387
389
|
return null;
|
|
388
390
|
}
|
|
389
391
|
|
|
390
|
-
newImporter.textureType = importer.textureType;
|
|
391
|
-
newImporter.spriteImportMode = importer.spriteImportMode;
|
|
392
|
-
newImporter.filterMode = importer.filterMode;
|
|
393
|
-
newImporter.textureCompression = importer.textureCompression;
|
|
394
|
-
newImporter.wrapMode = importer.wrapMode;
|
|
395
|
-
newImporter.mipmapEnabled = importer.mipmapEnabled;
|
|
396
|
-
newImporter.spritePixelsPerUnit = importer.spritePixelsPerUnit;
|
|
397
|
-
|
|
398
392
|
TextureImporterSettings newSettings = new();
|
|
399
393
|
importer.ReadTextureSettings(newSettings);
|
|
400
|
-
|
|
401
394
|
Vector2 origPivot = GetSpritePivot(importer);
|
|
402
395
|
Vector2 origCenter = new(width * origPivot.x, height * origPivot.y);
|
|
403
396
|
Vector2 newPivotPixels = origCenter - new Vector2(minX, minY);
|
|
@@ -406,17 +399,27 @@
|
|
|
406
399
|
cropHeight > 0 ? newPivotPixels.y / cropHeight : 0.5f
|
|
407
400
|
);
|
|
408
401
|
|
|
409
|
-
|
|
410
|
-
|
|
402
|
+
if (!hasVisible)
|
|
403
|
+
{
|
|
404
|
+
newPivotNorm = new Vector2(0.5f, 0.5f);
|
|
405
|
+
}
|
|
406
|
+
|
|
411
407
|
newSettings.spritePivot = newPivotNorm;
|
|
412
408
|
newSettings.spriteAlignment = (int)SpriteAlignment.Custom;
|
|
413
|
-
|
|
414
409
|
newImporter.SetTextureSettings(newSettings);
|
|
410
|
+
newImporter.spriteImportMode = SpriteImportMode.Single;
|
|
411
|
+
newImporter.spritePivot = newPivotNorm;
|
|
412
|
+
newImporter.textureType = importer.textureType;
|
|
413
|
+
newImporter.spriteImportMode = importer.spriteImportMode;
|
|
414
|
+
newImporter.filterMode = importer.filterMode;
|
|
415
|
+
newImporter.textureCompression = importer.textureCompression;
|
|
416
|
+
newImporter.wrapMode = importer.wrapMode;
|
|
417
|
+
newImporter.mipmapEnabled = importer.mipmapEnabled;
|
|
418
|
+
newImporter.spritePixelsPerUnit = importer.spritePixelsPerUnit;
|
|
415
419
|
newImporter.isReadable = true;
|
|
416
420
|
newImporter.SaveAndReimport();
|
|
417
421
|
|
|
418
|
-
|
|
419
|
-
return resultImporter;
|
|
422
|
+
return newImporter;
|
|
420
423
|
}
|
|
421
424
|
|
|
422
425
|
private static Vector2 GetSpritePivot(TextureImporter importer)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// ReSharper disable CompareOfFloatsByEqualityOperator
|
|
2
|
-
namespace WallstopStudios.UnityHelpers.Editor
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Editor.Sprites
|
|
3
3
|
{
|
|
4
4
|
#if UNITY_EDITOR
|
|
5
|
-
using Core.Attributes;
|
|
6
|
-
using Core.Extension;
|
|
7
5
|
using System;
|
|
8
6
|
using System.Collections.Generic;
|
|
9
7
|
using System.IO;
|
|
10
8
|
using System.Linq;
|
|
11
9
|
using UnityEditor;
|
|
12
10
|
using UnityEngine;
|
|
13
|
-
using
|
|
11
|
+
using Core.Attributes;
|
|
12
|
+
using Core.Extension;
|
|
13
|
+
using CustomEditors;
|
|
14
14
|
using Object = UnityEngine.Object;
|
|
15
15
|
|
|
16
16
|
[Serializable]
|
|
@@ -77,7 +77,7 @@ namespace WallstopStudios.UnityHelpers.Editor
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
[CustomPropertyDrawer(typeof(SpriteSettings))]
|
|
80
|
-
public class SpriteSettingsDrawer : PropertyDrawer
|
|
80
|
+
public sealed class SpriteSettingsDrawer : PropertyDrawer
|
|
81
81
|
{
|
|
82
82
|
private const float CheckboxWidth = 18f;
|
|
83
83
|
private const float HorizontalSpacing = 5f;
|
|
@@ -204,7 +204,7 @@ namespace WallstopStudios.UnityHelpers.Editor
|
|
|
204
204
|
valuePropHeight
|
|
205
205
|
);
|
|
206
206
|
|
|
207
|
-
using (new
|
|
207
|
+
using (new EditorGUI.IndentLevelScope())
|
|
208
208
|
{
|
|
209
209
|
EditorGUI.PropertyField(valueRect, valueProp, GUIContent.none, true);
|
|
210
210
|
}
|
|
@@ -301,25 +301,16 @@ namespace WallstopStudios.UnityHelpers.Editor
|
|
|
301
301
|
private void OnGUI()
|
|
302
302
|
{
|
|
303
303
|
_serializedObject.Update();
|
|
304
|
-
|
|
305
304
|
_scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);
|
|
306
305
|
|
|
307
306
|
EditorGUILayout.LabelField("Sprite Sources", EditorStyles.boldLabel);
|
|
308
307
|
EditorGUILayout.PropertyField(_spritesProp, new GUIContent("Specific Sprites"), true);
|
|
309
|
-
|
|
310
308
|
EditorGUILayout.Space();
|
|
311
|
-
|
|
312
309
|
EditorGUILayout.LabelField("Directory Sources", EditorStyles.boldLabel);
|
|
313
|
-
|
|
310
|
+
PersistentDirectoryGUI.PathSelectorObjectArray(
|
|
314
311
|
_directoriesProp,
|
|
315
|
-
|
|
316
|
-
true
|
|
312
|
+
nameof(SpriteSettingsApplierWindow)
|
|
317
313
|
);
|
|
318
|
-
if (GUILayout.Button("Add Directory via Browser"))
|
|
319
|
-
{
|
|
320
|
-
AddDirectory();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
314
|
EditorGUILayout.Space();
|
|
324
315
|
EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel);
|
|
325
316
|
EditorGUILayout.PropertyField(
|
|
@@ -332,7 +323,6 @@ namespace WallstopStudios.UnityHelpers.Editor
|
|
|
332
323
|
new GUIContent("Sprite Settings Profiles"),
|
|
333
324
|
true
|
|
334
325
|
);
|
|
335
|
-
|
|
336
326
|
EditorGUILayout.Space();
|
|
337
327
|
EditorGUILayout.LabelField("Actions", EditorStyles.boldLabel);
|
|
338
328
|
|
|
@@ -363,67 +353,10 @@ namespace WallstopStudios.UnityHelpers.Editor
|
|
|
363
353
|
_serializedObject.ApplyModifiedProperties();
|
|
364
354
|
}
|
|
365
355
|
|
|
366
|
-
private void AddDirectory()
|
|
367
|
-
{
|
|
368
|
-
string path = EditorUtility.OpenFolderPanel("Select Directory", "Assets", "");
|
|
369
|
-
if (string.IsNullOrWhiteSpace(path))
|
|
370
|
-
{
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (path.StartsWith(Application.dataPath, StringComparison.Ordinal))
|
|
375
|
-
{
|
|
376
|
-
string relativePath = "Assets" + path.Substring(Application.dataPath.Length);
|
|
377
|
-
Object folderAsset = AssetDatabase.LoadAssetAtPath<Object>(relativePath);
|
|
378
|
-
if (folderAsset != null)
|
|
379
|
-
{
|
|
380
|
-
_directoriesProp.serializedObject.Update();
|
|
381
|
-
bool alreadyExists = false;
|
|
382
|
-
for (int i = 0; i < _directoriesProp.arraySize; i++)
|
|
383
|
-
{
|
|
384
|
-
if (
|
|
385
|
-
_directoriesProp.GetArrayElementAtIndex(i).objectReferenceValue
|
|
386
|
-
== folderAsset
|
|
387
|
-
)
|
|
388
|
-
{
|
|
389
|
-
alreadyExists = true;
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (!alreadyExists)
|
|
395
|
-
{
|
|
396
|
-
int newIndex = _directoriesProp.arraySize;
|
|
397
|
-
_directoriesProp.InsertArrayElementAtIndex(newIndex);
|
|
398
|
-
_directoriesProp.GetArrayElementAtIndex(newIndex).objectReferenceValue =
|
|
399
|
-
folderAsset;
|
|
400
|
-
this.Log($"Added directory: {relativePath}");
|
|
401
|
-
}
|
|
402
|
-
else
|
|
403
|
-
{
|
|
404
|
-
this.LogWarn($"Directory already in list: {relativePath}");
|
|
405
|
-
}
|
|
406
|
-
_directoriesProp.serializedObject.ApplyModifiedProperties();
|
|
407
|
-
}
|
|
408
|
-
else
|
|
409
|
-
{
|
|
410
|
-
this.LogError(
|
|
411
|
-
$"Could not load asset at path: {relativePath}. Is it a valid folder within Assets?"
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
else
|
|
416
|
-
{
|
|
417
|
-
this.LogError(
|
|
418
|
-
$"Selected folder must be inside the project's Assets folder. Path selected: {path}"
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
356
|
private List<(string fullFilePath, string relativePath)> GetTargetSpritePaths()
|
|
424
357
|
{
|
|
425
358
|
HashSet<string> uniqueRelativePaths = new(StringComparer.OrdinalIgnoreCase);
|
|
426
|
-
|
|
359
|
+
HashSet<Object> validDirectories = new();
|
|
427
360
|
|
|
428
361
|
for (int i = 0; i < _directoriesProp.arraySize; i++)
|
|
429
362
|
{
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#if UNITY_EDITOR
|
|
4
4
|
using UnityEditor;
|
|
5
5
|
using UnityEngine;
|
|
6
|
-
using
|
|
6
|
+
using Core.Attributes;
|
|
7
7
|
|
|
8
8
|
// https://www.patrykgalach.com/2020/01/20/readonly-attribute-in-unity-editor/
|
|
9
9
|
[CustomPropertyDrawer(typeof(DxReadOnlyAttribute))]
|
|
@@ -4,9 +4,73 @@
|
|
|
4
4
|
using System.IO;
|
|
5
5
|
using System.Runtime.CompilerServices;
|
|
6
6
|
using UnityEngine;
|
|
7
|
+
#if UNITY_EDITOR
|
|
8
|
+
using UnityEditor;
|
|
9
|
+
#endif
|
|
7
10
|
|
|
8
11
|
public static class DirectoryHelper
|
|
9
12
|
{
|
|
13
|
+
public static void EnsureDirectoryExists(string relativeDirectoryPath)
|
|
14
|
+
{
|
|
15
|
+
if (string.IsNullOrWhiteSpace(relativeDirectoryPath))
|
|
16
|
+
{
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#if UNITY_EDITOR
|
|
21
|
+
if (!relativeDirectoryPath.StartsWith("Assets/"))
|
|
22
|
+
{
|
|
23
|
+
if (relativeDirectoryPath.Equals("Assets", StringComparison.OrdinalIgnoreCase))
|
|
24
|
+
{
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Debug.LogError(
|
|
29
|
+
$"Attempted to create directory outside of Assets: '{relativeDirectoryPath}'"
|
|
30
|
+
);
|
|
31
|
+
throw new ArgumentException(
|
|
32
|
+
"Cannot create directories outside the Assets folder using AssetDatabase.",
|
|
33
|
+
nameof(relativeDirectoryPath)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (AssetDatabase.IsValidFolder(relativeDirectoryPath))
|
|
38
|
+
{
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
string parentPath = Path.GetDirectoryName(relativeDirectoryPath).SanitizePath();
|
|
43
|
+
if (
|
|
44
|
+
string.IsNullOrWhiteSpace(parentPath)
|
|
45
|
+
|| parentPath.Equals("Assets", StringComparison.OrdinalIgnoreCase)
|
|
46
|
+
)
|
|
47
|
+
{
|
|
48
|
+
string folderNameToCreate = Path.GetFileName(relativeDirectoryPath);
|
|
49
|
+
if (
|
|
50
|
+
!string.IsNullOrWhiteSpace(folderNameToCreate)
|
|
51
|
+
&& !AssetDatabase.IsValidFolder(relativeDirectoryPath)
|
|
52
|
+
)
|
|
53
|
+
{
|
|
54
|
+
AssetDatabase.CreateFolder("Assets", folderNameToCreate);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
EnsureDirectoryExists(parentPath);
|
|
60
|
+
string currentFolderName = Path.GetFileName(relativeDirectoryPath);
|
|
61
|
+
if (
|
|
62
|
+
!string.IsNullOrWhiteSpace(currentFolderName)
|
|
63
|
+
&& !AssetDatabase.IsValidFolder(relativeDirectoryPath)
|
|
64
|
+
)
|
|
65
|
+
{
|
|
66
|
+
AssetDatabase.CreateFolder(parentPath, currentFolderName);
|
|
67
|
+
Debug.Log($"Created folder: {relativeDirectoryPath}");
|
|
68
|
+
}
|
|
69
|
+
#else
|
|
70
|
+
Directory.CreateDirectory(relativeDirectoryPath);
|
|
71
|
+
#endif
|
|
72
|
+
}
|
|
73
|
+
|
|
10
74
|
public static string GetCallerScriptDirectory([CallerFilePath] string sourceFilePath = "")
|
|
11
75
|
{
|
|
12
76
|
return string.IsNullOrWhiteSpace(sourceFilePath)
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
using System;
|
|
4
4
|
using Extension;
|
|
5
5
|
using UnityEditor;
|
|
6
|
-
using UnityEditor.SceneManagement;
|
|
7
6
|
using UnityEngine;
|
|
8
7
|
using UnityEngine.SceneManagement;
|
|
9
8
|
using Object = UnityEngine.Object;
|
|
10
|
-
|
|
9
|
+
#if UNITY_EDITOR
|
|
10
|
+
using UnityEditor.SceneManagement;
|
|
11
|
+
#endif
|
|
11
12
|
public static partial class Helpers
|
|
12
13
|
{
|
|
13
14
|
public static T Find<T>(this Object component, string tag, bool log = true)
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
public AnimatedSpriteLayer(
|
|
26
26
|
IEnumerable<Sprite> sprites,
|
|
27
|
-
IEnumerable<Vector2
|
|
27
|
+
IEnumerable<Vector2> worldSpaceOffsets = null,
|
|
28
28
|
float alpha = 1
|
|
29
29
|
)
|
|
30
30
|
{
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
|
|
76
76
|
public AnimatedSpriteLayer(
|
|
77
77
|
AnimationClip clip,
|
|
78
|
-
IEnumerable<Vector2
|
|
78
|
+
IEnumerable<Vector2> worldSpaceOffsets = null,
|
|
79
79
|
float alpha = 1
|
|
80
80
|
)
|
|
81
81
|
: this(
|
|
@@ -139,11 +139,14 @@
|
|
|
139
139
|
TimeSpan fpsSpan = TimeSpan.FromMilliseconds(1000f / fps);
|
|
140
140
|
int index = 0;
|
|
141
141
|
Stopwatch timer = Stopwatch.StartNew();
|
|
142
|
-
EditorApplication.update +=
|
|
142
|
+
EditorApplication.update += Tick;
|
|
143
|
+
return;
|
|
144
|
+
|
|
145
|
+
void Tick()
|
|
143
146
|
{
|
|
144
147
|
if (panel == null)
|
|
145
148
|
{
|
|
146
|
-
EditorApplication.update
|
|
149
|
+
EditorApplication.update -= Tick;
|
|
147
150
|
return;
|
|
148
151
|
}
|
|
149
152
|
TimeSpan elapsed = timer.Elapsed;
|
|
@@ -152,11 +155,10 @@
|
|
|
152
155
|
return;
|
|
153
156
|
}
|
|
154
157
|
|
|
155
|
-
index = (
|
|
158
|
+
index = index.WrappedIncrement(_computed.Length);
|
|
156
159
|
lastTick = elapsed;
|
|
157
160
|
Render(index);
|
|
158
|
-
}
|
|
159
|
-
return;
|
|
161
|
+
}
|
|
160
162
|
}
|
|
161
163
|
#endif
|
|
162
164
|
if (Application.isPlaying && CoroutineHandler.Instance != null)
|
|
@@ -170,7 +172,7 @@
|
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
index = (
|
|
175
|
+
index = index.WrappedIncrement(_computed.Length);
|
|
174
176
|
Render(index);
|
|
175
177
|
},
|
|
176
178
|
1f / fps
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.wallstop-studios.unity-helpers",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc74.00",
|
|
4
4
|
"displayName": "Unity Helpers",
|
|
5
5
|
"description": "Various Unity Helper Library",
|
|
6
6
|
"dependencies": {},
|
|
@@ -44,3 +44,15 @@
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|