com.wallstop-studios.unity-helpers 2.0.0-rc74.2 → 2.0.0-rc74.4

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#
@@ -7,14 +7,14 @@
7
7
  using Object = UnityEngine.Object;
8
8
 
9
9
  [InitializeOnLoad]
10
- public static class ScriptableSingletonCreator
10
+ public static class ScriptableObjectSingletonCreator
11
11
  {
12
- static ScriptableSingletonCreator()
12
+ static ScriptableObjectSingletonCreator()
13
13
  {
14
14
  bool anyCreated = false;
15
15
  foreach (
16
16
  Type derivedType in TypeCache.GetTypesDerivedFrom(
17
- typeof(UnityHelpers.Utils.ScriptableSingleton<>)
17
+ typeof(UnityHelpers.Utils.ScriptableObjectSingleton<>)
18
18
  )
19
19
  )
20
20
  {
@@ -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
@@ -6,13 +6,13 @@
6
6
  using Sirenix.OdinInspector;
7
7
  #endif
8
8
 
9
- public abstract class ScriptableSingleton<T> :
9
+ public abstract class ScriptableObjectSingleton<T> :
10
10
  #if ODIN_INSPECTOR
11
11
  SerializedScriptableObject
12
12
  #else
13
13
  ScriptableObject
14
14
  #endif
15
- where T : ScriptableSingleton<T>
15
+ where T : ScriptableObjectSingleton<T>
16
16
  {
17
17
  protected static readonly Lazy<T> LazyInstance = new(() =>
18
18
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc74.2",
3
+ "version": "2.0.0-rc74.4",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -55,6 +55,8 @@
55
55
 
56
56
 
57
57
 
58
+
59
+
58
60
 
59
61
 
60
62