@@ -24,21 +24,33 @@ public class TypeReference : ISerializationCallbackReceiver
2424 [ FormerlySerializedAs ( "_typeNameAndAssembly" ) ]
2525 [ SerializeField ] internal string TypeNameAndAssembly ;
2626
27+ [ SerializeField ] private bool _suppressLogs ;
28+
2729 private Type _type ;
2830
2931 private bool _needToLogTypeNotFound ;
3032
3133 /// <summary>
3234 /// Initializes a new instance of the <see cref="TypeReference"/> class with Type equal to null.
3335 /// </summary>
34- public TypeReference ( ) { }
36+ /// <param name="suppressLogs">
37+ /// Whether to suppress logs that show up when a type disappeared or was renamed. Default is <c>false</c>.
38+ /// </param>
39+ public TypeReference ( bool suppressLogs = false )
40+ {
41+ _suppressLogs = suppressLogs ;
42+ }
3543
3644 /// <summary>
3745 /// Initializes a new instance of the <see cref="TypeReference"/> class
3846 /// with Type equal to the name of the type passed in.
3947 /// </summary>
4048 /// <param name="assemblyQualifiedTypeName">Assembly qualified type name.</param>
41- public TypeReference ( string assemblyQualifiedTypeName )
49+ /// <param name="suppressLogs">
50+ /// Whether to suppress logs that show up when a type disappeared or was renamed. Default is <c>false</c>.
51+ /// </param>
52+ public TypeReference ( string assemblyQualifiedTypeName , bool suppressLogs = false )
53+ : this ( suppressLogs )
4254 {
4355 Type = IsNotEmpty ( assemblyQualifiedTypeName )
4456 ? Type . GetType ( assemblyQualifiedTypeName )
@@ -50,10 +62,14 @@ public TypeReference(string assemblyQualifiedTypeName)
5062 /// with Type equal to the passed type.
5163 /// </summary>
5264 /// <param name="type">Type.</param>
65+ /// <param name="suppressLogs">
66+ /// Whether to suppress logs that show up when a type disappeared or was renamed. Default is <c>false</c>.
67+ /// </param>
5368 /// <exception cref="System.ArgumentException">
5469 /// If <paramref name="type"/> does not have a full name.
5570 /// </exception>
56- public TypeReference ( Type type )
71+ public TypeReference ( Type type , bool suppressLogs = false )
72+ : this ( suppressLogs )
5773 {
5874 Type = type ;
5975 }
@@ -174,12 +190,17 @@ private void TryUpdatingTypeUsingGUID()
174190 _type = type ;
175191 string previousTypeName = TypeNameAndAssembly ;
176192 TypeNameAndAssembly = GetTypeNameAndAssembly ( _type ) ;
177- Debug . Log ( $ "Type reference has been updated from '{ previousTypeName } ' to '{ TypeNameAndAssembly } '.") ;
193+
194+ if ( ! _suppressLogs )
195+ Debug . Log ( $ "Type reference has been updated from '{ previousTypeName } ' to '{ TypeNameAndAssembly } '.") ;
178196#endif
179197 }
180198
181- private void LogTypeNotFound ( ) =>
182- Debug . LogWarning ( $ "'{ TypeNameAndAssembly } ' was referenced but such type was not found.") ;
199+ private void LogTypeNotFound ( )
200+ {
201+ if ( ! _suppressLogs )
202+ Debug . LogWarning ( $ "'{ TypeNameAndAssembly } ' was referenced but such type was not found.") ;
203+ }
183204
184205 /// <summary>
185206 /// Sometimes, the fact that the type disappeared is found during the deserialization. A warning cannot be
0 commit comments