@@ -1858,6 +1858,7 @@ internal void Initialize(IInputRuntime runtime, InputSettings settings)
18581858 Debug . Assert ( settings != null ) ;
18591859
18601860 m_Settings = settings ;
1861+ m_LazyLoadCustomTypes = ( ) => RegisterCustomTypes ( ) ; // Cached delegate
18611862
18621863 InitializeActions ( ) ;
18631864 InitializeData ( ) ;
@@ -1913,9 +1914,9 @@ private void InitializeActions()
19131914 internal void InitializeData ( )
19141915 {
19151916 m_Layouts . Allocate ( ) ;
1916- m_Processors . Initialize ( ) ;
1917- m_Interactions . Initialize ( ) ;
1918- m_Composites . Initialize ( ) ;
1917+ m_Processors . Initialize ( this ) ;
1918+ m_Interactions . Initialize ( this ) ;
1919+ m_Composites . Initialize ( this ) ;
19191920 m_DevicesById = new Dictionary < int , InputDevice > ( ) ;
19201921
19211922 // Determine our default set of enabled update types. By
@@ -2030,7 +2031,7 @@ internal void InitializeData()
20302031 // .inputaction JSON assets. This is managed via TypeTable.cs.
20312032 }
20322033
2033- void RegisterCustomTypes ( Type [ ] types )
2034+ static void RegisterCustomTypes ( Type [ ] types )
20342035 {
20352036 foreach ( Type type in types )
20362037 {
@@ -2053,13 +2054,17 @@ void RegisterCustomTypes(Type[] types)
20532054 }
20542055 }
20552056
2056- internal bool hasCustomTypesBeenRegistered { get ; private set ; }
2057+ private bool m_CustomTypesRegistered ;
20572058
2058- internal void RegisterCustomTypes ( )
2059+ internal bool RegisterCustomTypes ( )
20592060 {
2060- if ( hasCustomTypesBeenRegistered )
2061- return ;
2062- hasCustomTypesBeenRegistered = true ;
2061+ // If we have already attempted to register custom types, there is no need to reattempt since we
2062+ // would end up with the same result again. Only with a domain reload would the resulting types
2063+ // be different, and hence it is sufficient to use a static flag that we do not reset.
2064+ if ( ! m_CustomTypesRegistered )
2065+ return false ;
2066+
2067+ m_CustomTypesRegistered = true ;
20632068
20642069 k_InputRegisterCustomTypesMarker . Begin ( ) ;
20652070
@@ -2085,11 +2090,13 @@ internal void RegisterCustomTypes()
20852090 }
20862091 catch ( ReflectionTypeLoadException )
20872092 {
2088- continue ;
2093+ // Ignore exception
20892094 }
20902095 }
20912096
20922097 k_InputRegisterCustomTypesMarker . End ( ) ;
2098+
2099+ return true ;
20932100 }
20942101
20952102 internal void InstallRuntime ( IInputRuntime runtime )
@@ -2270,6 +2277,7 @@ internal struct AvailableDevice
22702277 internal IInputRuntime m_Runtime ;
22712278 internal InputMetrics m_Metrics ;
22722279 internal InputSettings m_Settings ;
2280+ private Func < bool > m_LazyLoadCustomTypes ;
22732281
22742282 // Extract as booleans (from m_Settings) because feature check is in the hot path
22752283
0 commit comments