com.wallstop-studios.unity-helpers 2.0.0-rc08 → 2.0.0-rc10

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.
Files changed (85) hide show
  1. package/CHANGELOG.md.meta +7 -7
  2. package/Editor/AnimationEventEditor.cs.meta +11 -11
  3. package/Editor.meta +8 -8
  4. package/LICENSE.md.meta +7 -7
  5. package/README.md.meta +7 -7
  6. package/Runtime/Core/Attributes/AnimationEventAttribute.cs.meta +11 -11
  7. package/Runtime/Core/Attributes/ChildComponentAttribute.cs.meta +11 -11
  8. package/Runtime/Core/Attributes/KSerializableAttribute.cs.meta +11 -11
  9. package/Runtime/Core/Attributes/NotNullAttribute.cs.meta +11 -11
  10. package/Runtime/Core/Attributes/ParentComponent.cs.meta +11 -11
  11. package/Runtime/Core/Attributes/ReadOnlyAttribute.cs.meta +11 -11
  12. package/Runtime/Core/Attributes/RelationalComponentExtensions.cs.meta +11 -11
  13. package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs.meta +11 -11
  14. package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs.meta +11 -11
  15. package/Runtime/Core/DataStructure/Adapters/KGuid.cs.meta +11 -11
  16. package/Runtime/Core/DataStructure/Adapters/KVector2.cs.meta +11 -11
  17. package/Runtime/Core/DataStructure/Adapters.meta +8 -8
  18. package/Runtime/Core/DataStructure/Circle.cs.meta +11 -11
  19. package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +11 -11
  20. package/Runtime/Core/DataStructure/QuadTree.cs.meta +11 -11
  21. package/Runtime/Core/DataStructure/StringWrapper.cs.meta +11 -11
  22. package/Runtime/Core/DataStructure/TimedCache.cs.meta +11 -11
  23. package/Runtime/Core/DataStructure.meta +8 -8
  24. package/Runtime/Core/Extension/AnimatorExtensions.cs.meta +11 -11
  25. package/Runtime/Core/Extension/CircleExtensions.cs.meta +11 -11
  26. package/Runtime/Core/Extension/ColorExtensions.cs.meta +11 -11
  27. package/Runtime/Core/Extension/DictionaryExtensions.cs.meta +11 -11
  28. package/Runtime/Core/Extension/DirectionExtensions.cs.meta +11 -11
  29. package/Runtime/Core/Extension/HashSetExtensions.cs.meta +11 -11
  30. package/Runtime/Core/Extension/IEnumerableExtensions.cs.meta +11 -11
  31. package/Runtime/Core/Extension/IListExtensions.cs.meta +11 -11
  32. package/Runtime/Core/Extension/LoggingExtensions.cs +96 -74
  33. package/Runtime/Core/Extension/LoggingExtensions.cs.meta +11 -11
  34. package/Runtime/Core/Extension/RandomExtensions.cs.meta +11 -11
  35. package/Runtime/Core/Extension/StringExtensions.cs.meta +11 -11
  36. package/Runtime/Core/Extension/UnityExtensions.cs.meta +11 -11
  37. package/Runtime/Core/Extension.meta +8 -8
  38. package/Runtime/Core/Helper/Enumerables.cs.meta +11 -11
  39. package/Runtime/Core/Helper/Geometry.cs.meta +11 -11
  40. package/Runtime/Core/Helper/LifetimeHelpers.cs.meta +11 -11
  41. package/Runtime/Core/Helper/Objects.cs +394 -74
  42. package/Runtime/Core/Helper/Objects.cs.meta +11 -11
  43. package/Runtime/Core/Helper/WallMath.cs.meta +11 -11
  44. package/Runtime/Core/Helper.meta +8 -8
  45. package/Runtime/Core/Math/Line.cs.meta +11 -11
  46. package/Runtime/Core/Math/Parabola.cs.meta +11 -11
  47. package/Runtime/Core/Math/Range.cs.meta +11 -11
  48. package/Runtime/Core/Math.meta +8 -8
  49. package/Runtime/Core/Model/Direction.cs.meta +11 -11
  50. package/Runtime/Core/Model.meta +8 -8
  51. package/Runtime/Core/OneOf/FastOneOf.cs.meta +11 -11
  52. package/Runtime/Core/OneOf/None.cs.meta +11 -11
  53. package/Runtime/Core/OneOf.meta +8 -8
  54. package/Runtime/Core/Random/AbstractRandom.cs.meta +11 -11
  55. package/Runtime/Core/Random/IRandom.cs.meta +11 -11
  56. package/Runtime/Core/Random/NativePcgRandom.cs.meta +11 -11
  57. package/Runtime/Core/Random/PcgRandom.cs.meta +11 -11
  58. package/Runtime/Core/Random/RandomState.cs.meta +11 -11
  59. package/Runtime/Core/Random/SquirrelRandom.cs.meta +11 -11
  60. package/Runtime/Core/Random/SystemRandom.cs.meta +11 -11
  61. package/Runtime/Core/Random/ThreadLocalRandom.cs.meta +11 -11
  62. package/Runtime/Core/Random.meta +8 -8
  63. package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs.meta +11 -11
  64. package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs.meta +11 -11
  65. package/Runtime/Core/Serialization/JsonConverters.meta +8 -8
  66. package/Runtime/Core/Serialization/Serializer.cs.meta +11 -11
  67. package/Runtime/Core/Serialization.meta +8 -8
  68. package/Runtime/Core/Threading/SingleThreadedThreadPool.cs.meta +11 -11
  69. package/Runtime/Core/Threading.meta +8 -8
  70. package/Runtime/Core.meta +8 -8
  71. package/Runtime/Protobuf-Net.meta +8 -8
  72. package/Runtime/Utils/AnimationEventEqualityComparer.cs.meta +11 -11
  73. package/Runtime/Utils/AnimatorEnumStateMachine.cs.meta +11 -11
  74. package/Runtime/Utils/Buffers.cs.meta +11 -11
  75. package/Runtime/Utils/CircleLineRenderer.cs.meta +11 -11
  76. package/Runtime/Utils/Oscillator.cs.meta +11 -11
  77. package/Runtime/Utils/RuntimeSingleton.cs +26 -4
  78. package/Runtime/Utils/SetTextureImportData.cs.meta +11 -11
  79. package/Runtime/Utils.meta +8 -8
  80. package/Runtime/WallstopStudios.UnityHelpers.asmdef.meta +7 -7
  81. package/Runtime.meta +8 -8
  82. package/Tests.meta +8 -8
  83. package/Third Party Notices.md.meta +7 -7
  84. package/package.json +1 -1
  85. package/package.json.meta +7 -7
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 3470cf3d28c05ad4a8c63bcaa168b4a0
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 3470cf3d28c05ad4a8c63bcaa168b4a0
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: cc0fd5f65729462428811e55928b5bd2
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: cc0fd5f65729462428811e55928b5bd2
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -5,18 +5,26 @@
5
5
  namespace UnityHelpers.Core.Extension
6
6
  {
7
7
  using System;
8
- using System.Diagnostics;
8
+ using System.Collections.Generic;
9
+ using System.Linq;
10
+ using System.Runtime.CompilerServices;
9
11
  using System.Threading;
10
12
  using Helper;
11
13
  using JetBrains.Annotations;
12
14
  using UnityEngine;
15
+ using Utils;
13
16
  using Debug = UnityEngine.Debug;
17
+ using Object = UnityEngine.Object;
14
18
 
15
19
  public static class LoggingExtensions
16
20
  {
17
21
  private static readonly Thread UnityMainThread;
22
+ private const int LogsPerCacheClean = 5;
18
23
 
19
24
  private static bool LoggingEnabled = true;
25
+ private static long _cacheAccessCount;
26
+
27
+ private static readonly HashSet<Object> Disabled = new();
20
28
 
21
29
  static LoggingExtensions()
22
30
  {
@@ -32,162 +40,176 @@ namespace UnityHelpers.Core.Extension
32
40
  #endif
33
41
  }
34
42
 
35
- public static void EnableLogging(this UnityEngine.Object component)
43
+ public static void GlobalEnableLogging(this Object component)
36
44
  {
37
45
  LoggingEnabled = true;
38
46
  }
39
47
 
40
- public static void DisableLogging(this UnityEngine.Object component)
48
+ public static void GlobalDisableLogging(this Object component)
41
49
  {
42
50
  LoggingEnabled = false;
43
51
  }
44
52
 
45
-
53
+ public static void EnableLogging(this Object component)
54
+ {
55
+ Disabled.Remove(component);
56
+ }
57
+
58
+ public static void DisableLogging(this Object component)
59
+ {
60
+ Disabled.Add(component);
61
+ }
62
+
46
63
  [StringFormatMethod("message")]
47
- public static void Log(this UnityEngine.Object component, string message, params object[] args)
64
+ public static void Log(this Object component, string message, params object[] args)
48
65
  {
49
66
  #if ENABLE_UBERLOGGING
50
- if (!LoggingEnabled)
51
- {
52
- return;
53
- }
54
67
  LogDebug(component, message, args);
55
68
  #endif
56
69
  }
57
70
 
58
-
59
71
  [StringFormatMethod("message")]
60
- public static void LogMethod(this UnityEngine.Object component)
72
+ public static void LogMethod(this Object component, [CallerMemberName] string caller = "")
61
73
  {
62
74
  #if ENABLE_UBERLOGGING
63
- StackTrace stackTrace = new StackTrace();
64
- string methodName = stackTrace.GetFrame(1).GetMethod().Name;
65
- LogDebug(component, methodName);
75
+ LogDebug(component, caller);
66
76
  #endif
67
77
  }
68
78
 
69
-
70
79
  [StringFormatMethod("message")]
71
- public static void LogDebug(this UnityEngine.Object component, string message, params object[] args)
80
+ public static void LogDebug(this Object component, string message, params object[] args)
72
81
  {
73
82
  #if ENABLE_UBERLOGGING
74
- if (!LoggingEnabled)
75
- {
76
- return;
77
- }
78
83
  LogDebug(component, message, null, args);
79
84
  #endif
80
85
  }
81
86
 
82
-
83
87
  [StringFormatMethod("message")]
84
- public static void LogWarn(this UnityEngine.Object component, string message, params object[] args)
88
+ public static void LogWarn(this Object component, string message, params object[] args)
85
89
  {
86
90
  #if ENABLE_UBERLOGGING
87
- if (!LoggingEnabled)
88
- {
89
- return;
90
- }
91
91
  LogWarn(component, message, null, args);
92
92
  #endif
93
93
  }
94
94
 
95
-
96
95
  [StringFormatMethod("message")]
97
- public static void LogError(this UnityEngine.Object component, string message, params object[] args)
96
+ public static void LogError(this Object component, string message, params object[] args)
98
97
  {
99
98
  #if ENABLE_UBERLOGGING
100
- if (!LoggingEnabled)
101
- {
102
- return;
103
- }
104
99
  LogError(component, message, null, args);
105
100
  #endif
106
101
  }
107
102
 
108
-
109
103
  [StringFormatMethod("message")]
110
- public static void Log(this UnityEngine.Object component, string message, Exception e, params object[] args)
104
+ public static void Log(
105
+ this Object component,
106
+ string message,
107
+ Exception e,
108
+ params object[] args
109
+ )
111
110
  {
112
111
  #if ENABLE_UBERLOGGING
113
- if (!LoggingEnabled)
114
- {
115
- return;
116
- }
117
112
  LogDebug(component, message, e, args);
118
113
  #endif
119
114
  }
120
115
 
121
-
122
116
  [StringFormatMethod("message")]
123
- public static void LogDebug(this UnityEngine.Object component, string message, Exception e, params object[] args)
117
+ public static void LogDebug(
118
+ this Object component,
119
+ string message,
120
+ Exception e,
121
+ params object[] args
122
+ )
124
123
  {
125
124
  #if ENABLE_UBERLOGGING
126
- if (!LoggingEnabled)
125
+ if (LoggingAllowed(component))
127
126
  {
128
- return;
129
- }
130
- if (Equals(Thread.CurrentThread, UnityMainThread))
131
- {
132
- Debug.Log(Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e));
127
+ Debug.Log(
128
+ Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e),
129
+ component
130
+ );
133
131
  }
134
132
  #endif
135
133
  }
136
134
 
137
-
138
135
  [StringFormatMethod("message")]
139
- public static void LogWarn(this UnityEngine.Object component, string message, Exception e, params object[] args)
136
+ public static void LogWarn(
137
+ this Object component,
138
+ string message,
139
+ Exception e,
140
+ params object[] args
141
+ )
140
142
  {
141
143
  #if ENABLE_UBERLOGGING
142
- if (!LoggingEnabled)
143
- {
144
- return;
145
- }
146
- if (Equals(Thread.CurrentThread, UnityMainThread))
144
+ if (LoggingAllowed(component))
147
145
  {
148
- Debug.LogWarning(Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e));
146
+ Debug.LogWarning(
147
+ Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e),
148
+ component
149
+ );
149
150
  }
150
151
  #endif
151
152
  }
152
153
 
153
-
154
154
  [StringFormatMethod("message")]
155
- public static void LogError(this UnityEngine.Object component, string message, Exception e, params object[] args)
155
+ public static void LogError(
156
+ this Object component,
157
+ string message,
158
+ Exception e,
159
+ params object[] args
160
+ )
156
161
  {
157
162
  #if ENABLE_UBERLOGGING
158
- if (!LoggingEnabled)
163
+ if (LoggingAllowed(component))
159
164
  {
160
- return;
165
+ Debug.LogError(
166
+ Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e),
167
+ component
168
+ );
161
169
  }
162
- if (Equals(Thread.CurrentThread, UnityMainThread))
170
+ #endif
171
+ }
172
+
173
+ private static bool LoggingAllowed(Object component)
174
+ {
175
+ if (Interlocked.Increment(ref _cacheAccessCount) % LogsPerCacheClean == 0)
163
176
  {
164
- Debug.LogError(Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e));
177
+ List<Object> buffer = Buffers<Object>.List;
178
+ buffer.Clear();
179
+ buffer.AddRange(Disabled);
180
+ buffer.RemoveAll(element => element != null);
181
+ if (0 < buffer.Count)
182
+ {
183
+ Disabled.ExceptWith(buffer);
184
+ }
165
185
  }
166
- #endif
186
+
187
+ return LoggingEnabled
188
+ && Equals(Thread.CurrentThread, UnityMainThread)
189
+ && !Disabled.Contains(component);
167
190
  }
168
191
 
169
- private static string Wrap(UnityEngine.Object component, string message, Exception e)
192
+ private static string Wrap(Object component, string message, Exception e)
170
193
  {
171
194
  #if ENABLE_UBERLOGGING
172
195
  float now = Time.time;
173
- string componentType = component == null ? "NO_TYPE" : component.GetType().Name;
174
- string gameObjectName = "NO_NAME";
196
+ string componentType;
197
+ string gameObjectName;
175
198
  if (component != null)
176
199
  {
177
- GameObject owner = component.GetGameObject();
178
- if (owner != null)
179
- {
180
- gameObjectName = owner.name;
181
- }
200
+ componentType = component.GetType().Name;
201
+ gameObjectName = component.name;
182
202
  }
183
-
184
- string prepend = $"{now}|{gameObjectName}[{componentType}]|";
185
- if (e != null)
203
+ else
186
204
  {
187
- return prepend + message + "\n " + e;
205
+ componentType = "NO_TYPE";
206
+ gameObjectName = "NO_NAME";
188
207
  }
189
208
 
190
- return prepend + message;
209
+ return e != null
210
+ ? $"{now}|{gameObjectName}[{componentType}]|{message}\n {e}"
211
+ : $"{now}|{gameObjectName}[{componentType}]|{message}";
212
+
191
213
  #else
192
214
  return string.Empty;
193
215
  #endif
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 9f2ac4106848eb345bcd57352a716d54
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 9f2ac4106848eb345bcd57352a716d54
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: ec0e4839ae4386b42b719a215dbc21a4
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: ec0e4839ae4386b42b719a215dbc21a4
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: e406db60762cae54cb45ba98c37ad022
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: e406db60762cae54cb45ba98c37ad022
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 5e109c62507ff9b4bbf63cc53dc2f2df
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 5e109c62507ff9b4bbf63cc53dc2f2df
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: 0d93c076498bde4489f30315784b7303
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 0d93c076498bde4489f30315784b7303
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: ed00743ed86d5d54c87cf73a57c9226e
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: ed00743ed86d5d54c87cf73a57c9226e
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 18f4ae2186130474dae2b33609a14235
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 18f4ae2186130474dae2b33609a14235
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: ea2fd993d32f4de99c8470019c604060
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: ea2fd993d32f4de99c8470019c604060
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: