com.wallstop-studios.unity-helpers 2.0.0-rc61 → 2.0.0-rc63

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 (177) hide show
  1. package/Editor/AnimationCopier.cs +7 -14
  2. package/Editor/AnimationCreator.cs +7 -11
  3. package/Editor/AnimationEventEditor.cs +6 -6
  4. package/Editor/AnimatorControllerCopier.cs +7 -13
  5. package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +4 -6
  6. package/Editor/FitTextureSizeWizard.cs +4 -4
  7. package/Editor/PrefabCheckWizard.cs +10 -13
  8. package/Editor/SpriteSettingsApplier.cs +4 -4
  9. package/Editor/StringInListeDrawer.cs +2 -2
  10. package/Editor/TextureResizerWizard.cs +6 -12
  11. package/Editor/TextureSettingsApplier.cs +5 -5
  12. package/Editor/Utils/DxReadOnlyPropertyDrawer.cs +2 -2
  13. package/Editor/Utils/EditorUtilities.cs +1 -1
  14. package/Editor/WShowIfPropertyDrawer.cs +4 -4
  15. package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef +1 -1
  16. package/Runtime/Core/Attributes/AnimationEventAttribute.cs +1 -1
  17. package/Runtime/Core/Attributes/ChildComponentAttribute.cs +2 -1
  18. package/Runtime/Core/Attributes/DxReadOnlyAttribute.cs +1 -1
  19. package/Runtime/Core/Attributes/KSerializableAttribute.cs +1 -1
  20. package/Runtime/Core/Attributes/NotNullAttribute.cs +1 -1
  21. package/Runtime/Core/Attributes/ParentComponent.cs +1 -1
  22. package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +1 -1
  23. package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +1 -1
  24. package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +12 -7
  25. package/Runtime/Core/Attributes/WShowIfAttribute.cs +1 -1
  26. package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +1 -1
  27. package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +1 -1
  28. package/Runtime/Core/DataStructure/Adapters/KGuid.cs +1 -1
  29. package/Runtime/Core/DataStructure/Adapters/KVector2.cs +1 -1
  30. package/Runtime/Core/DataStructure/Circle.cs +1 -1
  31. package/Runtime/Core/DataStructure/CyclicBuffer.cs +1 -1
  32. package/Runtime/Core/DataStructure/ISpatialTree.cs +1 -1
  33. package/Runtime/Core/DataStructure/KDTree.cs +1 -1
  34. package/Runtime/Core/DataStructure/QuadTree.cs +1 -1
  35. package/Runtime/Core/DataStructure/RTree.cs +1 -1
  36. package/Runtime/Core/DataStructure/StringWrapper.cs +1 -1
  37. package/Runtime/Core/DataStructure/TimedCache.cs +1 -1
  38. package/Runtime/Core/Extension/AnimatorExtensions.cs +1 -1
  39. package/Runtime/Core/Extension/AsyncOperationExtensions.cs +1 -1
  40. package/Runtime/Core/Extension/CircleExtensions.cs +1 -1
  41. package/Runtime/Core/Extension/ColorExtensions.cs +16 -1
  42. package/Runtime/Core/Extension/DictionaryExtensions.cs +1 -1
  43. package/Runtime/Core/Extension/DirectionExtensions.cs +1 -1
  44. package/Runtime/Core/Extension/EnumExtensions.cs +1 -1
  45. package/Runtime/Core/Extension/HashSetExtensions.cs +1 -1
  46. package/Runtime/Core/Extension/IEnumerableExtensions.cs +1 -1
  47. package/Runtime/Core/Extension/IListExtensions.cs +1 -1
  48. package/Runtime/Core/Extension/LoggingExtensions.cs +69 -122
  49. package/Runtime/Core/Extension/RandomExtensions.cs +1 -1
  50. package/Runtime/Core/Extension/SerializedPropertyExtensions.cs +2 -2
  51. package/Runtime/Core/Extension/StringExtensions.cs +1 -1
  52. package/Runtime/Core/Extension/UnityExtensions.cs +1 -2
  53. package/Runtime/Core/Helper/ArrayConverter.cs +1 -1
  54. package/Runtime/Core/Helper/AssignUtilities.cs +1 -1
  55. package/Runtime/Core/Helper/DirectoryHelper.cs +1 -1
  56. package/Runtime/Core/Helper/Enumerables.cs +1 -1
  57. package/Runtime/Core/Helper/FormattingHelpers.cs +1 -1
  58. package/Runtime/Core/Helper/Geometry.cs +1 -1
  59. package/Runtime/Core/Helper/Helpers.cs +6 -9
  60. package/Runtime/Core/Helper/IterationHelpers.cs +1 -1
  61. package/Runtime/Core/Helper/LifetimeHelpers.cs +2 -1
  62. package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +517 -0
  63. package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs.meta +3 -0
  64. package/Runtime/Core/Helper/Logging.meta +3 -0
  65. package/Runtime/Core/Helper/Objects.cs +1 -1
  66. package/Runtime/Core/Helper/Partials/LogHelpers.cs +2 -2
  67. package/Runtime/Core/Helper/Partials/MathHelpers.cs +1 -1
  68. package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +5 -11
  69. package/Runtime/Core/Helper/Partials/TransformHelpers.cs +1 -1
  70. package/Runtime/Core/Helper/ReflectionHelpers.cs +173 -36
  71. package/Runtime/Core/Helper/SceneHelper.cs +3 -5
  72. package/Runtime/Core/Helper/SpriteHelpers.cs +3 -3
  73. package/Runtime/Core/Helper/StringInList.cs +1 -1
  74. package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs +2 -4
  75. package/Runtime/Core/Helper/WallMath.cs +1 -1
  76. package/Runtime/Core/Math/Line.cs +1 -1
  77. package/Runtime/Core/Math/Parabola.cs +1 -1
  78. package/Runtime/Core/Math/PointPolygonCheck.cs +1 -1
  79. package/Runtime/Core/Math/Range.cs +1 -1
  80. package/Runtime/Core/Math/XXHash.cs +1 -1
  81. package/Runtime/Core/Model/Direction.cs +1 -1
  82. package/Runtime/Core/OneOf/FastOneOf.cs +1 -1
  83. package/Runtime/Core/OneOf/None.cs +1 -1
  84. package/Runtime/Core/Random/AbstractRandom.cs +1 -1
  85. package/Runtime/Core/Random/DotNetRandom.cs +1 -1
  86. package/Runtime/Core/Random/IRandom.cs +1 -1
  87. package/Runtime/Core/Random/LinearCongruentialGenerator.cs +1 -1
  88. package/Runtime/Core/Random/NativePcgRandom.cs +1 -1
  89. package/Runtime/Core/Random/PRNG.cs +1 -1
  90. package/Runtime/Core/Random/PcgRandom.cs +1 -1
  91. package/Runtime/Core/Random/PerlinNoise.cs +1 -1
  92. package/Runtime/Core/Random/RandomState.cs +1 -1
  93. package/Runtime/Core/Random/RandomUtilities.cs +1 -1
  94. package/Runtime/Core/Random/RomuDuo.cs +1 -1
  95. package/Runtime/Core/Random/SplitMix64.cs +1 -1
  96. package/Runtime/Core/Random/SquirrelRandom.cs +1 -1
  97. package/Runtime/Core/Random/SystemRandom.cs +1 -1
  98. package/Runtime/Core/Random/ThreadLocalRandom.cs +1 -1
  99. package/Runtime/Core/Random/UnityRandom.cs +1 -1
  100. package/Runtime/Core/Random/WyRandom.cs +1 -1
  101. package/Runtime/Core/Random/XorShiftRandom.cs +1 -1
  102. package/Runtime/Core/Random/XorShiroRandom.cs +1 -1
  103. package/Runtime/Core/Serialization/JsonConverters/ColorConverter.cs +1 -1
  104. package/Runtime/Core/Serialization/JsonConverters/GameObjectConverter.cs +1 -2
  105. package/Runtime/Core/Serialization/JsonConverters/Matrix4x4Converter.cs +1 -1
  106. package/Runtime/Core/Serialization/JsonConverters/TypeConverter.cs +1 -1
  107. package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +1 -1
  108. package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +1 -1
  109. package/Runtime/Core/Serialization/JsonConverters/Vector4Converter.cs +1 -1
  110. package/Runtime/Core/Serialization/Serializer.cs +1 -1
  111. package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +1 -1
  112. package/Runtime/UI/LayeredImage.cs +1 -1
  113. package/Runtime/Utils/AnimationEventEqualityComparer.cs +1 -1
  114. package/Runtime/Utils/AnimatorEnumStateMachine.cs +1 -1
  115. package/Runtime/Utils/Buffers.cs +1 -1
  116. package/Runtime/Utils/CenterPointOffset.cs +1 -1
  117. package/Runtime/Utils/CircleLineRenderer.cs +4 -6
  118. package/Runtime/Utils/CoroutineHandler.cs +1 -1
  119. package/Runtime/Utils/DeferredDisposalResult.cs +1 -1
  120. package/Runtime/Utils/MatchColliderToSprite.cs +1 -1
  121. package/Runtime/Utils/Oscillator.cs +1 -1
  122. package/Runtime/Utils/RuntimeSingleton.cs +1 -1
  123. package/Runtime/Utils/SetTextureImportData.cs +1 -1
  124. package/Runtime/Utils/SpriteRendererMetadata.cs +1 -1
  125. package/Runtime/Utils/SpriteRendererSyncer.cs +1 -1
  126. package/Runtime/Utils/StartTracker.cs +1 -1
  127. package/Runtime/Utils/TextureScale.cs +1 -1
  128. package/Runtime/Utils/TypeNameSorter.cs +17 -0
  129. package/Runtime/Utils/TypeNameSorter.cs.meta +3 -0
  130. package/Runtime/Utils/UnityObjectNameComparer.cs +1 -1
  131. package/Runtime/WallstopStudios.UnityHelpers.asmdef +1 -1
  132. package/Tests/Runtime/Attributes/ChildComponentTests.cs +2 -2
  133. package/Tests/Runtime/Attributes/Components/ExpectChildSpriteRenderers.cs +2 -2
  134. package/Tests/Runtime/Attributes/Components/ExpectParentSpriteRenderers.cs +2 -2
  135. package/Tests/Runtime/Attributes/ParentComponentTests.cs +2 -2
  136. package/Tests/Runtime/Components/RelationalComponentTesterComplex.cs +2 -2
  137. package/Tests/Runtime/Components/RelationalComponentsTesterSimple.cs +4 -4
  138. package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +2 -2
  139. package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +3 -3
  140. package/Tests/Runtime/DataStructures/QuadTreeTests.cs +2 -2
  141. package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +4 -4
  142. package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +2 -2
  143. package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs +2 -3
  144. package/Tests/Runtime/Extensions/EnumExtensionTests.cs +2 -2
  145. package/Tests/Runtime/Extensions/IListExtensionTests.cs +3 -3
  146. package/Tests/Runtime/Extensions/LoggingExtensionTests.cs +718 -0
  147. package/Tests/Runtime/Extensions/LoggingExtensionTests.cs.meta +3 -0
  148. package/Tests/Runtime/Extensions/RandomExtensionTests.cs +3 -3
  149. package/Tests/Runtime/Extensions/StringExtensionTests.cs +2 -2
  150. package/Tests/Runtime/Helper/ArrayConverterTests.cs +3 -3
  151. package/Tests/Runtime/Helper/FormattingHelperTests.cs +3 -3
  152. package/Tests/Runtime/Helper/ObjectHelperTests.cs +2 -2
  153. package/Tests/Runtime/Helper/ReflectionHelperTests.cs +3 -3
  154. package/Tests/Runtime/Helper/SceneHelperTests.cs +3 -3
  155. package/Tests/Runtime/Helper/WallMathTests.cs +5 -5
  156. package/Tests/Runtime/Performance/KDTreePerformanceTests.cs +2 -2
  157. package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +2 -2
  158. package/Tests/Runtime/Performance/RandomPerformanceTests.cs +2 -2
  159. package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs +2 -2
  160. package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +2 -2
  161. package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +2 -2
  162. package/Tests/Runtime/Random/DotNetRandomTests.cs +2 -2
  163. package/Tests/Runtime/Random/LinearCongruentialGeneratorTests.cs +2 -2
  164. package/Tests/Runtime/Random/PcgRandomTests.cs +2 -2
  165. package/Tests/Runtime/Random/RandomTestBase.cs +7 -7
  166. package/Tests/Runtime/Random/RomuDuoRandomTests.cs +2 -2
  167. package/Tests/Runtime/Random/SplitMix64RandomTests.cs +2 -2
  168. package/Tests/Runtime/Random/SquirrelRandomTests.cs +2 -2
  169. package/Tests/Runtime/Random/SystemRandomTests.cs +2 -2
  170. package/Tests/Runtime/Random/UnityRandomTests.cs +2 -2
  171. package/Tests/Runtime/Random/WyRandomTests.cs +2 -2
  172. package/Tests/Runtime/Random/XorShiftRandomTests.cs +2 -2
  173. package/Tests/Runtime/Random/XorShiroRandomTests.cs +2 -2
  174. package/Tests/Runtime/Serialization/JsonSerializationTest.cs +5 -5
  175. package/Tests/Runtime/Utils/SpriteRendererMetadataTests.cs +3 -4
  176. package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef +1 -1
  177. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.DataStructure
1
+ namespace WallstopStudios.UnityHelpers.Core.DataStructure
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Generic;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.DataStructure
1
+ namespace WallstopStudios.UnityHelpers.Core.DataStructure
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Generic;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.DataStructure
1
+ namespace WallstopStudios.UnityHelpers.Core.DataStructure
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Concurrent;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.DataStructure
1
+ namespace WallstopStudios.UnityHelpers.Core.DataStructure
2
2
  {
3
3
  using System;
4
4
  using Helper;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using UnityEngine;
4
4
 
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Concurrent;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System.Collections.Generic;
4
4
  using DataStructure;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System.Collections.Generic;
4
4
  using System.ComponentModel;
@@ -20,6 +20,21 @@
20
20
  {
21
21
  private static readonly Dictionary<Vector3Int, int> ColorBucketCache = new();
22
22
 
23
+ public static string ToHex(this Color color, bool includeAlpha = true)
24
+ {
25
+ int r = (int)(Mathf.Clamp01(color.r) * 255f);
26
+ int g = (int)(Mathf.Clamp01(color.g) * 255f);
27
+ int b = (int)(Mathf.Clamp01(color.b) * 255f);
28
+
29
+ if (!includeAlpha)
30
+ {
31
+ return $"#{r:X2}{g:X2}{b:X2}";
32
+ }
33
+
34
+ int a = (int)(Mathf.Clamp01(color.a) * 255f);
35
+ return $"#{r:X2}{g:X2}{b:X2}{a:X2}";
36
+ }
37
+
23
38
  public static Color GetAverageColor(
24
39
  this Sprite sprite,
25
40
  ColorAveragingMethod method = ColorAveragingMethod.LAB,
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Concurrent;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Generic;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System;
4
4
  using System.Runtime.CompilerServices;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System.Collections.Generic;
4
4
 
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Concurrent;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Generic;
@@ -2,21 +2,25 @@
2
2
  #define ENABLE_UBERLOGGING
3
3
  #endif
4
4
 
5
- namespace UnityHelpers.Core.Extension
5
+ namespace WallstopStudios.UnityHelpers.Core.Extension
6
6
  {
7
7
  using System;
8
8
  using System.Collections.Generic;
9
+ using System.Linq;
9
10
  using System.Reflection;
10
- using System.Runtime.CompilerServices;
11
11
  using System.Threading;
12
- using JetBrains.Annotations;
12
+ using Helper;
13
+ using Helper.Logging;
13
14
  using UnityEngine;
14
15
  using Utils;
15
- using Debug = UnityEngine.Debug;
16
16
  using Object = UnityEngine.Object;
17
17
 
18
18
  public static class LoggingExtensions
19
19
  {
20
+ public static readonly UnityLogTagFormatter LogInstance = new(
21
+ createDefaultDecorators: true
22
+ );
23
+
20
24
  private static readonly Thread UnityMainThread;
21
25
  private const int LogsPerCacheClean = 5;
22
26
 
@@ -24,8 +28,10 @@ namespace UnityHelpers.Core.Extension
24
28
  private static long _cacheAccessCount;
25
29
 
26
30
  private static readonly HashSet<Object> Disabled = new();
27
- private static readonly Dictionary<Type, FieldInfo[]> FieldCache = new();
28
- private static readonly Dictionary<Type, PropertyInfo[]> PropertyCache = new();
31
+ private static readonly Dictionary<Type, (string, Func<object, object>)[]> MetadataCache =
32
+ new();
33
+
34
+ private static readonly Dictionary<string, object> GenericObject = new();
29
35
 
30
36
  static LoggingExtensions()
31
37
  {
@@ -33,7 +39,7 @@ namespace UnityHelpers.Core.Extension
33
39
  /*
34
40
  Unity throws exceptions if you try to log on something that isn't the main thread.
35
41
  Sometimes, it's nice to log in async Tasks. Assume that the first initialization of
36
- this class will be done by the Unity main thread, and then check every time we log.
42
+ this class will be done by the Unity main thread and then check every time we log.
37
43
  If the logging thread is not the unity main thread, then do nothing
38
44
  (instead of throwing...)
39
45
  */
@@ -61,6 +67,7 @@ namespace UnityHelpers.Core.Extension
61
67
  Disabled.Add(component);
62
68
  }
63
69
 
70
+ [HideInCallstack]
64
71
  public static string GenericToString(this Object component)
65
72
  {
66
73
  if (component == null)
@@ -68,148 +75,114 @@ namespace UnityHelpers.Core.Extension
68
75
  return "null";
69
76
  }
70
77
 
71
- Dictionary<string, object> structure = new();
72
- Type type = component.GetType();
73
- FieldInfo[] fields = FieldCache.GetOrAdd(
74
- type,
75
- inType => inType.GetFields(BindingFlags.Public | BindingFlags.Instance)
76
- );
77
- PropertyInfo[] properties = PropertyCache.GetOrAdd(
78
- type,
79
- inType => inType.GetProperties(BindingFlags.Public | BindingFlags.Instance)
78
+ (string, Func<object, object>)[] metadataAccess = MetadataCache.GetOrAdd(
79
+ component.GetType(),
80
+ inType =>
81
+ inType
82
+ .GetFields(BindingFlags.Public | BindingFlags.Instance)
83
+ .Select(field => (field.Name, ReflectionHelpers.GetFieldGetter(field)))
84
+ .Concat(
85
+ inType
86
+ .GetProperties(BindingFlags.Public | BindingFlags.Instance)
87
+ .Select(property =>
88
+ (property.Name, ReflectionHelpers.GetPropertyGetter(property))
89
+ )
90
+ )
91
+ .ToArray()
80
92
  );
81
- foreach (FieldInfo field in fields)
82
- {
83
- structure[field.Name] = ValueFormat(field.GetValue(component));
84
- }
85
-
86
- foreach (PropertyInfo property in properties)
87
- {
88
- structure[property.Name] = ValueFormat(property.GetValue(component));
89
- }
90
-
91
- return structure.ToJson();
92
93
 
93
- object ValueFormat(object value)
94
+ GenericObject.Clear();
95
+ foreach ((string name, Func<object, object> access) in metadataAccess)
94
96
  {
95
- if (value is Object obj)
97
+ try
98
+ {
99
+ string valueFormat = ValueFormat(access(component));
100
+ if (valueFormat != null)
101
+ {
102
+ GenericObject[name] = valueFormat;
103
+ }
104
+ }
105
+ catch
96
106
  {
97
- return obj != null ? obj.name : null;
107
+ // Skip
98
108
  }
99
- return value?.ToString();
100
109
  }
101
- }
102
-
103
- [StringFormatMethod("message")]
104
- public static void Log(this Object component, string message, params object[] args)
105
- {
106
- #if ENABLE_UBERLOGGING
107
- LogDebug(component, message, args);
108
- #endif
109
- }
110
110
 
111
- [StringFormatMethod("message")]
112
- public static void LogMethod(this Object component, [CallerMemberName] string caller = "")
113
- {
114
- #if ENABLE_UBERLOGGING
115
- LogDebug(component, caller);
116
- #endif
111
+ return GenericObject.ToJson();
117
112
  }
118
113
 
119
- [StringFormatMethod("message")]
120
- public static void LogDebug(this Object component, string message, params object[] args)
114
+ [HideInCallstack]
115
+ private static string ValueFormat(object value)
121
116
  {
122
- #if ENABLE_UBERLOGGING
123
- LogDebug(component, message, null, args);
124
- #endif
125
- }
126
-
127
- [StringFormatMethod("message")]
128
- public static void LogWarn(this Object component, string message, params object[] args)
129
- {
130
- #if ENABLE_UBERLOGGING
131
- LogWarn(component, message, null, args);
132
- #endif
133
- }
134
-
135
- [StringFormatMethod("message")]
136
- public static void LogError(this Object component, string message, params object[] args)
137
- {
138
- #if ENABLE_UBERLOGGING
139
- LogError(component, message, null, args);
140
- #endif
117
+ if (value is Object obj)
118
+ {
119
+ return obj != null ? obj.name : "null";
120
+ }
121
+ return value?.ToString();
141
122
  }
142
123
 
143
- [StringFormatMethod("message")]
124
+ [HideInCallstack]
144
125
  public static void Log(
145
126
  this Object component,
146
- string message,
147
- Exception e,
148
- params object[] args
127
+ FormattableString message,
128
+ Exception e = null,
129
+ bool pretty = true
149
130
  )
150
131
  {
151
132
  #if ENABLE_UBERLOGGING
152
- LogDebug(component, message, e, args);
133
+ LogDebug(component, message, e, pretty);
153
134
  #endif
154
135
  }
155
136
 
156
- [StringFormatMethod("message")]
137
+ [HideInCallstack]
157
138
  public static void LogDebug(
158
139
  this Object component,
159
- string message,
160
- Exception e,
161
- params object[] args
140
+ FormattableString message,
141
+ Exception e = null,
142
+ bool pretty = true
162
143
  )
163
144
  {
164
145
  #if ENABLE_UBERLOGGING
165
146
  if (LoggingAllowed(component))
166
147
  {
167
- Debug.Log(
168
- Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e),
169
- component
170
- );
148
+ LogInstance.Log(message, component, e, pretty);
171
149
  }
172
150
  #endif
173
151
  }
174
152
 
175
- [StringFormatMethod("message")]
153
+ [HideInCallstack]
176
154
  public static void LogWarn(
177
155
  this Object component,
178
- string message,
179
- Exception e,
180
- params object[] args
156
+ FormattableString message,
157
+ Exception e = null,
158
+ bool pretty = true
181
159
  )
182
160
  {
183
161
  #if ENABLE_UBERLOGGING
184
162
  if (LoggingAllowed(component))
185
163
  {
186
- Debug.LogWarning(
187
- Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e),
188
- component
189
- );
164
+ LogInstance.LogWarn(message, component, e, pretty);
190
165
  }
191
166
  #endif
192
167
  }
193
168
 
194
- [StringFormatMethod("message")]
169
+ [HideInCallstack]
195
170
  public static void LogError(
196
171
  this Object component,
197
- string message,
198
- Exception e,
199
- params object[] args
172
+ FormattableString message,
173
+ Exception e = null,
174
+ bool pretty = true
200
175
  )
201
176
  {
202
177
  #if ENABLE_UBERLOGGING
203
178
  if (LoggingAllowed(component))
204
179
  {
205
- Debug.LogError(
206
- Wrap(component, args.Length != 0 ? string.Format(message, args) : message, e),
207
- component
208
- );
180
+ LogInstance.LogError(message, component, e, pretty);
209
181
  }
210
182
  #endif
211
183
  }
212
184
 
185
+ [HideInCallstack]
213
186
  private static bool LoggingAllowed(Object component)
214
187
  {
215
188
  if (Interlocked.Increment(ref _cacheAccessCount) % LogsPerCacheClean == 0)
@@ -234,31 +207,5 @@ namespace UnityHelpers.Core.Extension
234
207
  && Equals(Thread.CurrentThread, UnityMainThread)
235
208
  && !Disabled.Contains(component);
236
209
  }
237
-
238
- private static string Wrap(Object component, string message, Exception e)
239
- {
240
- #if ENABLE_UBERLOGGING
241
- float now = Time.time;
242
- string componentType;
243
- string gameObjectName;
244
- if (component != null)
245
- {
246
- componentType = component.GetType().Name;
247
- gameObjectName = component.name;
248
- }
249
- else
250
- {
251
- componentType = "NO_TYPE";
252
- gameObjectName = "NO_NAME";
253
- }
254
-
255
- return e != null
256
- ? $"{now}|{gameObjectName}[{componentType}]|{message}\n {e}"
257
- : $"{now}|{gameObjectName}[{componentType}]|{message}";
258
-
259
- #else
260
- return string.Empty;
261
- #endif
262
- }
263
210
  }
264
211
  }
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Generic;
@@ -1,9 +1,9 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  #if UNITY_EDITOR
4
- using UnityEditor;
5
4
  using System;
6
5
  using System.Reflection;
6
+ using UnityEditor;
7
7
 
8
8
  public static class SerializedPropertyExtensions
9
9
  {
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System.Collections.Generic;
4
4
  using System.Text;
@@ -1,9 +1,8 @@
1
- namespace UnityHelpers.Core.Extension
1
+ namespace WallstopStudios.UnityHelpers.Core.Extension
2
2
  {
3
3
  using System;
4
4
  using System.Collections.Generic;
5
5
  using System.Linq;
6
- using System.Threading.Tasks;
7
6
  using DataStructure;
8
7
  using DataStructure.Adapters;
9
8
  using Helper;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  using System;
4
4
 
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  public static class AssignUtilities
4
4
  {
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  using System;
4
4
  using System.IO;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  using System.Collections.Generic;
4
4
 
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  using System;
4
4
 
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  using System.Collections.Generic;
4
4
  using System.Linq;
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  using System;
4
4
  using System.Collections;
@@ -7,15 +7,12 @@
7
7
  using System.Reflection;
8
8
  using DataStructure.Adapters;
9
9
  using Extension;
10
+ using Partials;
10
11
  using Random;
12
+ using UnityEditor;
11
13
  using UnityEngine;
12
- using UnityEngine.SceneManagement;
13
14
  using Utils;
14
15
  using Object = UnityEngine.Object;
15
- #if UNITY_EDITOR
16
- using UnityEditor;
17
- using UnityEditor.SceneManagement;
18
- #endif
19
16
 
20
17
  public static partial class Helpers
21
18
  {
@@ -411,7 +408,7 @@
411
408
  }
412
409
  catch
413
410
  {
414
- original.LogWarn("Failed to copy public field {0}.", field.Name);
411
+ original.LogWarn($"Failed to copy public field {field.Name}.");
415
412
  }
416
413
  }
417
414
 
@@ -426,7 +423,7 @@
426
423
  }
427
424
  catch
428
425
  {
429
- original.LogWarn("Failed to copy non-public field {0}.", field.Name);
426
+ original.LogWarn($"Failed to copy non-public field {field.Name}.");
430
427
  }
431
428
  }
432
429
 
@@ -443,7 +440,7 @@
443
440
  }
444
441
  catch
445
442
  {
446
- original.LogWarn("Failed to copy property {0}.", property.Name);
443
+ original.LogWarn($"Failed to copy property {property.Name}.");
447
444
  }
448
445
  }
449
446
 
@@ -1,4 +1,4 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  using System.Collections.Generic;
4
4
 
@@ -1,5 +1,6 @@
1
- namespace UnityHelpers.Core.Helper
1
+ namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
+ using Partials;
3
4
  using Object = UnityEngine.Object;
4
5
 
5
6
  public static class LifetimeHelpers