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.
- package/Editor/AnimationCopier.cs +7 -14
- package/Editor/AnimationCreator.cs +7 -11
- package/Editor/AnimationEventEditor.cs +6 -6
- package/Editor/AnimatorControllerCopier.cs +7 -13
- package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +4 -6
- package/Editor/FitTextureSizeWizard.cs +4 -4
- package/Editor/PrefabCheckWizard.cs +10 -13
- package/Editor/SpriteSettingsApplier.cs +4 -4
- package/Editor/StringInListeDrawer.cs +2 -2
- package/Editor/TextureResizerWizard.cs +6 -12
- package/Editor/TextureSettingsApplier.cs +5 -5
- package/Editor/Utils/DxReadOnlyPropertyDrawer.cs +2 -2
- package/Editor/Utils/EditorUtilities.cs +1 -1
- package/Editor/WShowIfPropertyDrawer.cs +4 -4
- package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef +1 -1
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs +1 -1
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs +2 -1
- package/Runtime/Core/Attributes/DxReadOnlyAttribute.cs +1 -1
- package/Runtime/Core/Attributes/KSerializableAttribute.cs +1 -1
- package/Runtime/Core/Attributes/NotNullAttribute.cs +1 -1
- package/Runtime/Core/Attributes/ParentComponent.cs +1 -1
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +1 -1
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +1 -1
- package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +12 -7
- package/Runtime/Core/Attributes/WShowIfAttribute.cs +1 -1
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +1 -1
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +1 -1
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs +1 -1
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs +1 -1
- package/Runtime/Core/DataStructure/Circle.cs +1 -1
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +1 -1
- package/Runtime/Core/DataStructure/ISpatialTree.cs +1 -1
- package/Runtime/Core/DataStructure/KDTree.cs +1 -1
- package/Runtime/Core/DataStructure/QuadTree.cs +1 -1
- package/Runtime/Core/DataStructure/RTree.cs +1 -1
- package/Runtime/Core/DataStructure/StringWrapper.cs +1 -1
- package/Runtime/Core/DataStructure/TimedCache.cs +1 -1
- package/Runtime/Core/Extension/AnimatorExtensions.cs +1 -1
- package/Runtime/Core/Extension/AsyncOperationExtensions.cs +1 -1
- package/Runtime/Core/Extension/CircleExtensions.cs +1 -1
- package/Runtime/Core/Extension/ColorExtensions.cs +16 -1
- package/Runtime/Core/Extension/DictionaryExtensions.cs +1 -1
- package/Runtime/Core/Extension/DirectionExtensions.cs +1 -1
- package/Runtime/Core/Extension/EnumExtensions.cs +1 -1
- package/Runtime/Core/Extension/HashSetExtensions.cs +1 -1
- package/Runtime/Core/Extension/IEnumerableExtensions.cs +1 -1
- package/Runtime/Core/Extension/IListExtensions.cs +1 -1
- package/Runtime/Core/Extension/LoggingExtensions.cs +69 -122
- package/Runtime/Core/Extension/RandomExtensions.cs +1 -1
- package/Runtime/Core/Extension/SerializedPropertyExtensions.cs +2 -2
- package/Runtime/Core/Extension/StringExtensions.cs +1 -1
- package/Runtime/Core/Extension/UnityExtensions.cs +1 -2
- package/Runtime/Core/Helper/ArrayConverter.cs +1 -1
- package/Runtime/Core/Helper/AssignUtilities.cs +1 -1
- package/Runtime/Core/Helper/DirectoryHelper.cs +1 -1
- package/Runtime/Core/Helper/Enumerables.cs +1 -1
- package/Runtime/Core/Helper/FormattingHelpers.cs +1 -1
- package/Runtime/Core/Helper/Geometry.cs +1 -1
- package/Runtime/Core/Helper/Helpers.cs +6 -9
- package/Runtime/Core/Helper/IterationHelpers.cs +1 -1
- package/Runtime/Core/Helper/LifetimeHelpers.cs +2 -1
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +517 -0
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs.meta +3 -0
- package/Runtime/Core/Helper/Logging.meta +3 -0
- package/Runtime/Core/Helper/Objects.cs +1 -1
- package/Runtime/Core/Helper/Partials/LogHelpers.cs +2 -2
- package/Runtime/Core/Helper/Partials/MathHelpers.cs +1 -1
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +5 -11
- package/Runtime/Core/Helper/Partials/TransformHelpers.cs +1 -1
- package/Runtime/Core/Helper/ReflectionHelpers.cs +173 -36
- package/Runtime/Core/Helper/SceneHelper.cs +3 -5
- package/Runtime/Core/Helper/SpriteHelpers.cs +3 -3
- package/Runtime/Core/Helper/StringInList.cs +1 -1
- package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs +2 -4
- package/Runtime/Core/Helper/WallMath.cs +1 -1
- package/Runtime/Core/Math/Line.cs +1 -1
- package/Runtime/Core/Math/Parabola.cs +1 -1
- package/Runtime/Core/Math/PointPolygonCheck.cs +1 -1
- package/Runtime/Core/Math/Range.cs +1 -1
- package/Runtime/Core/Math/XXHash.cs +1 -1
- package/Runtime/Core/Model/Direction.cs +1 -1
- package/Runtime/Core/OneOf/FastOneOf.cs +1 -1
- package/Runtime/Core/OneOf/None.cs +1 -1
- package/Runtime/Core/Random/AbstractRandom.cs +1 -1
- package/Runtime/Core/Random/DotNetRandom.cs +1 -1
- package/Runtime/Core/Random/IRandom.cs +1 -1
- package/Runtime/Core/Random/LinearCongruentialGenerator.cs +1 -1
- package/Runtime/Core/Random/NativePcgRandom.cs +1 -1
- package/Runtime/Core/Random/PRNG.cs +1 -1
- package/Runtime/Core/Random/PcgRandom.cs +1 -1
- package/Runtime/Core/Random/PerlinNoise.cs +1 -1
- package/Runtime/Core/Random/RandomState.cs +1 -1
- package/Runtime/Core/Random/RandomUtilities.cs +1 -1
- package/Runtime/Core/Random/RomuDuo.cs +1 -1
- package/Runtime/Core/Random/SplitMix64.cs +1 -1
- package/Runtime/Core/Random/SquirrelRandom.cs +1 -1
- package/Runtime/Core/Random/SystemRandom.cs +1 -1
- package/Runtime/Core/Random/ThreadLocalRandom.cs +1 -1
- package/Runtime/Core/Random/UnityRandom.cs +1 -1
- package/Runtime/Core/Random/WyRandom.cs +1 -1
- package/Runtime/Core/Random/XorShiftRandom.cs +1 -1
- package/Runtime/Core/Random/XorShiroRandom.cs +1 -1
- package/Runtime/Core/Serialization/JsonConverters/ColorConverter.cs +1 -1
- package/Runtime/Core/Serialization/JsonConverters/GameObjectConverter.cs +1 -2
- package/Runtime/Core/Serialization/JsonConverters/Matrix4x4Converter.cs +1 -1
- package/Runtime/Core/Serialization/JsonConverters/TypeConverter.cs +1 -1
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +1 -1
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +1 -1
- package/Runtime/Core/Serialization/JsonConverters/Vector4Converter.cs +1 -1
- package/Runtime/Core/Serialization/Serializer.cs +1 -1
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +1 -1
- package/Runtime/UI/LayeredImage.cs +1 -1
- package/Runtime/Utils/AnimationEventEqualityComparer.cs +1 -1
- package/Runtime/Utils/AnimatorEnumStateMachine.cs +1 -1
- package/Runtime/Utils/Buffers.cs +1 -1
- package/Runtime/Utils/CenterPointOffset.cs +1 -1
- package/Runtime/Utils/CircleLineRenderer.cs +4 -6
- package/Runtime/Utils/CoroutineHandler.cs +1 -1
- package/Runtime/Utils/DeferredDisposalResult.cs +1 -1
- package/Runtime/Utils/MatchColliderToSprite.cs +1 -1
- package/Runtime/Utils/Oscillator.cs +1 -1
- package/Runtime/Utils/RuntimeSingleton.cs +1 -1
- package/Runtime/Utils/SetTextureImportData.cs +1 -1
- package/Runtime/Utils/SpriteRendererMetadata.cs +1 -1
- package/Runtime/Utils/SpriteRendererSyncer.cs +1 -1
- package/Runtime/Utils/StartTracker.cs +1 -1
- package/Runtime/Utils/TextureScale.cs +1 -1
- package/Runtime/Utils/TypeNameSorter.cs +17 -0
- package/Runtime/Utils/TypeNameSorter.cs.meta +3 -0
- package/Runtime/Utils/UnityObjectNameComparer.cs +1 -1
- package/Runtime/WallstopStudios.UnityHelpers.asmdef +1 -1
- package/Tests/Runtime/Attributes/ChildComponentTests.cs +2 -2
- package/Tests/Runtime/Attributes/Components/ExpectChildSpriteRenderers.cs +2 -2
- package/Tests/Runtime/Attributes/Components/ExpectParentSpriteRenderers.cs +2 -2
- package/Tests/Runtime/Attributes/ParentComponentTests.cs +2 -2
- package/Tests/Runtime/Components/RelationalComponentTesterComplex.cs +2 -2
- package/Tests/Runtime/Components/RelationalComponentsTesterSimple.cs +4 -4
- package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +2 -2
- package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +3 -3
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs +2 -2
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +4 -4
- package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +2 -2
- package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs +2 -3
- package/Tests/Runtime/Extensions/EnumExtensionTests.cs +2 -2
- package/Tests/Runtime/Extensions/IListExtensionTests.cs +3 -3
- package/Tests/Runtime/Extensions/LoggingExtensionTests.cs +718 -0
- package/Tests/Runtime/Extensions/LoggingExtensionTests.cs.meta +3 -0
- package/Tests/Runtime/Extensions/RandomExtensionTests.cs +3 -3
- package/Tests/Runtime/Extensions/StringExtensionTests.cs +2 -2
- package/Tests/Runtime/Helper/ArrayConverterTests.cs +3 -3
- package/Tests/Runtime/Helper/FormattingHelperTests.cs +3 -3
- package/Tests/Runtime/Helper/ObjectHelperTests.cs +2 -2
- package/Tests/Runtime/Helper/ReflectionHelperTests.cs +3 -3
- package/Tests/Runtime/Helper/SceneHelperTests.cs +3 -3
- package/Tests/Runtime/Helper/WallMathTests.cs +5 -5
- package/Tests/Runtime/Performance/KDTreePerformanceTests.cs +2 -2
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +2 -2
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +2 -2
- package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs +2 -2
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +2 -2
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +2 -2
- package/Tests/Runtime/Random/DotNetRandomTests.cs +2 -2
- package/Tests/Runtime/Random/LinearCongruentialGeneratorTests.cs +2 -2
- package/Tests/Runtime/Random/PcgRandomTests.cs +2 -2
- package/Tests/Runtime/Random/RandomTestBase.cs +7 -7
- package/Tests/Runtime/Random/RomuDuoRandomTests.cs +2 -2
- package/Tests/Runtime/Random/SplitMix64RandomTests.cs +2 -2
- package/Tests/Runtime/Random/SquirrelRandomTests.cs +2 -2
- package/Tests/Runtime/Random/SystemRandomTests.cs +2 -2
- package/Tests/Runtime/Random/UnityRandomTests.cs +2 -2
- package/Tests/Runtime/Random/WyRandomTests.cs +2 -2
- package/Tests/Runtime/Random/XorShiftRandomTests.cs +2 -2
- package/Tests/Runtime/Random/XorShiroRandomTests.cs +2 -2
- package/Tests/Runtime/Serialization/JsonSerializationTest.cs +5 -5
- package/Tests/Runtime/Utils/SpriteRendererMetadataTests.cs +3 -4
- package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -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
|
|
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,
|
|
28
|
-
|
|
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
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
94
|
+
GenericObject.Clear();
|
|
95
|
+
foreach ((string name, Func<object, object> access) in metadataAccess)
|
|
94
96
|
{
|
|
95
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
120
|
-
|
|
114
|
+
[HideInCallstack]
|
|
115
|
+
private static string ValueFormat(object value)
|
|
121
116
|
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
[
|
|
124
|
+
[HideInCallstack]
|
|
144
125
|
public static void Log(
|
|
145
126
|
this Object component,
|
|
146
|
-
|
|
147
|
-
Exception e,
|
|
148
|
-
|
|
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,
|
|
133
|
+
LogDebug(component, message, e, pretty);
|
|
153
134
|
#endif
|
|
154
135
|
}
|
|
155
136
|
|
|
156
|
-
[
|
|
137
|
+
[HideInCallstack]
|
|
157
138
|
public static void LogDebug(
|
|
158
139
|
this Object component,
|
|
159
|
-
|
|
160
|
-
Exception e,
|
|
161
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
153
|
+
[HideInCallstack]
|
|
176
154
|
public static void LogWarn(
|
|
177
155
|
this Object component,
|
|
178
|
-
|
|
179
|
-
Exception e,
|
|
180
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
169
|
+
[HideInCallstack]
|
|
195
170
|
public static void LogError(
|
|
196
171
|
this Object component,
|
|
197
|
-
|
|
198
|
-
Exception e,
|
|
199
|
-
|
|
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
|
-
|
|
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,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,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
|
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 {
|
|
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 {
|
|
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 {
|
|
443
|
+
original.LogWarn($"Failed to copy property {property.Name}.");
|
|
447
444
|
}
|
|
448
445
|
}
|
|
449
446
|
|