@@ -271,7 +271,7 @@ private void EnsureMixedRealityRequirements()
271271 /// <summary>
272272 /// Returns the Singleton instance of the classes type.
273273 /// If no instance is found, then we search for an instance in the scene.
274- /// If more than one instance is found, we throw an error and no instance is returned.
274+ /// If more than one instance is found, we log an error and no instance is returned.
275275 /// </summary>
276276 public static MixedRealityManager Instance
277277 {
@@ -514,8 +514,16 @@ public void AddManager(Type type, IMixedRealityManager manager)
514514 Debug . LogError ( $ "Unable to add a new { type . Name } Manager as the Mixed Reality manager has to Active Profile") ;
515515 }
516516
517- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
518- if ( manager == null ) { throw new ArgumentNullException ( nameof ( manager ) ) ; }
517+ if ( type == null )
518+ {
519+ Debug . LogWarning ( "Unable to add a manager of type null." ) ;
520+ return ;
521+ }
522+ if ( manager == null )
523+ {
524+ Debug . LogWarning ( "Unable to add a manager with a null instance." ) ;
525+ return ;
526+ }
519527
520528 if ( IsCoreManagerType ( type ) )
521529 {
@@ -566,15 +574,21 @@ public IMixedRealityManager GetManager(Type type)
566574 {
567575 if ( ActiveProfile == null )
568576 {
569- throw new ArgumentNullException ( $ "Unable to get { nameof ( type ) } Manager as the Mixed Reality Manager has no Active Profile.") ;
577+ Debug . LogError ( $ "Unable to get { nameof ( type ) } Manager as the Mixed Reality Manager has no Active Profile.") ;
578+ return null ;
570579 }
571580
572581 if ( ! IsInitialized )
573582 {
574- throw new ArgumentNullException ( $ "Unable to get { nameof ( type ) } Manager as the Mixed Reality Manager has not been initialized!") ;
583+ Debug . LogError ( $ "Unable to get { nameof ( type ) } Manager as the Mixed Reality Manager has not been initialized!") ;
584+ return null ;
575585 }
576586
577- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
587+ if ( type == null )
588+ {
589+ Debug . LogError ( "Unable to get null manager type." ) ;
590+ return null ;
591+ }
578592
579593 IMixedRealityManager manager ;
580594 if ( IsCoreManagerType ( type ) )
@@ -588,7 +602,7 @@ public IMixedRealityManager GetManager(Type type)
588602
589603 if ( manager == null )
590604 {
591- throw new NullReferenceException ( $ "Unable to find { type . Name } .") ;
605+ Debug . Log ( $ "Unable to find { type . Name } .") ;
592606 }
593607
594608 return manager ;
@@ -604,11 +618,20 @@ public IMixedRealityManager GetManager(Type type, string managerName)
604618 {
605619 if ( ActiveProfile == null )
606620 {
607- throw new ArgumentNullException ( $ "Unable to get { managerName } Manager as the Mixed Reality Manager has no Active Profile") ;
621+ Debug . LogError ( $ "Unable to get { managerName } Manager as the Mixed Reality Manager has no Active Profile.") ;
622+ return null ;
608623 }
609624
610- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
611- if ( string . IsNullOrEmpty ( managerName ) ) { throw new ArgumentNullException ( nameof ( managerName ) ) ; }
625+ if ( type == null )
626+ {
627+ Debug . LogError ( "Unable to get null manager type." ) ;
628+ return null ;
629+ }
630+ if ( string . IsNullOrEmpty ( managerName ) )
631+ {
632+ Debug . LogError ( "Unable to get manager by name without the name being specified." ) ;
633+ return null ;
634+ }
612635
613636 IMixedRealityManager manager ;
614637 if ( IsCoreManagerType ( type ) )
@@ -622,7 +645,7 @@ public IMixedRealityManager GetManager(Type type, string managerName)
622645
623646 if ( manager == null )
624647 {
625- throw new NullReferenceException ( $ "Unable to find { managerName } Manager.") ;
648+ Debug . LogError ( $ "Unable to find { managerName } Manager.") ;
626649 }
627650
628651 return manager ;
@@ -636,10 +659,15 @@ public void RemoveManager(Type type)
636659 {
637660 if ( ActiveProfile == null )
638661 {
639- throw new ArgumentNullException ( $ "Unable to remove { nameof ( type ) } Manager as the Mixed Reality Manager has no Active Profile") ;
662+ Debug . LogError ( $ "Unable to remove { nameof ( type ) } Manager as the Mixed Reality Manager has no Active Profile.") ;
663+ return ;
640664 }
641665
642- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
666+ if ( type == null )
667+ {
668+ Debug . LogError ( "Unable to remove null manager type." ) ;
669+ return ;
670+ }
643671
644672 if ( IsCoreManagerType ( type ) )
645673 {
@@ -666,11 +694,21 @@ public void RemoveManager(Type type, string managerName)
666694 {
667695 if ( ActiveProfile == null )
668696 {
669- throw new ArgumentNullException ( $ "Unable to remove { nameof ( type ) } Manager as the Mixed Reality Manager has no Active Profile") ;
697+ Debug . LogError ( $ "Unable to remove { managerName } Manager as the Mixed Reality Manager has no Active Profile.") ;
698+ return ;
670699 }
671700
672- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
673- if ( string . IsNullOrEmpty ( managerName ) ) { throw new ArgumentNullException ( nameof ( managerName ) ) ; }
701+ if ( type == null )
702+ {
703+ Debug . LogError ( "Unable to remove null manager type." ) ;
704+ return ;
705+ }
706+
707+ if ( string . IsNullOrEmpty ( managerName ) )
708+ {
709+ Debug . LogError ( "Unable to remove manager by name without the name being specified." ) ;
710+ return ;
711+ }
674712
675713 if ( IsCoreManagerType ( type ) )
676714 {
@@ -693,7 +731,11 @@ public void RemoveManager(Type type, string managerName)
693731 /// <param name="type">The interface type for the system to be removed. E.G. InputSystem, BoundarySystem</param>
694732 public void DisableManager ( Type type )
695733 {
696- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
734+ if ( type == null )
735+ {
736+ Debug . LogError ( "Unable to disable null manager type." ) ;
737+ return ;
738+ }
697739
698740 if ( IsCoreManagerType ( type ) )
699741 {
@@ -715,8 +757,16 @@ public void DisableManager(Type type)
715757 /// <param name="managerName">Name of the specific manager</param>
716758 public void DisableManager ( Type type , string managerName )
717759 {
718- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
719- if ( string . IsNullOrEmpty ( managerName ) ) { throw new ArgumentNullException ( nameof ( managerName ) ) ; }
760+ if ( type == null )
761+ {
762+ Debug . LogError ( "Unable to disable null manager type." ) ;
763+ return ;
764+ }
765+ if ( string . IsNullOrEmpty ( managerName ) )
766+ {
767+ Debug . LogError ( "Unable to disable manager by name without the name being specified." ) ;
768+ return ;
769+ }
720770
721771 if ( IsCoreManagerType ( type ) )
722772 {
@@ -737,7 +787,11 @@ public void DisableManager(Type type, string managerName)
737787 /// <param name="type">The interface type for the system to be removed. E.G. InputSystem, BoundarySystem</param>
738788 public void EnableManager ( Type type )
739789 {
740- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
790+ if ( type == null )
791+ {
792+ Debug . LogError ( "Unable to enable null manager type." ) ;
793+ return ;
794+ }
741795
742796 if ( IsCoreManagerType ( type ) )
743797 {
@@ -759,8 +813,16 @@ public void EnableManager(Type type)
759813 /// <param name="managerName">Name of the specific manager</param>
760814 public void EnableManager ( Type type , string managerName )
761815 {
762- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
763- if ( string . IsNullOrEmpty ( managerName ) ) { throw new ArgumentNullException ( nameof ( managerName ) ) ; }
816+ if ( type == null )
817+ {
818+ Debug . LogError ( "Unable to enable null manager type." ) ;
819+ return ;
820+ }
821+ if ( string . IsNullOrEmpty ( managerName ) )
822+ {
823+ Debug . LogError ( "Unable to enable manager by name without the name being specified." ) ;
824+ return ;
825+ }
764826
765827 if ( IsCoreManagerType ( type ) )
766828 {
@@ -786,7 +848,11 @@ public void EnableManager(Type type, string managerName)
786848 /// <returns>An array of Managers that meet the search criteria</returns>
787849 public IEnumerable < IMixedRealityManager > GetManagers ( Type type )
788850 {
789- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
851+ if ( type == null )
852+ {
853+ Debug . LogWarning ( "Unable to get managers with a type of null." ) ;
854+ return new List < IMixedRealityManager > ( ) ;
855+ }
790856
791857 return GetManagers ( type , string . Empty ) ;
792858 }
@@ -801,10 +867,15 @@ public List<IMixedRealityManager> GetManagers(Type type, string managerName)
801867 {
802868 if ( ActiveProfile == null )
803869 {
804- throw new ArgumentNullException ( $ "Unable to get { nameof ( type ) } Manager as the Mixed Reality Manager has no Active Profile") ;
870+ Debug . LogWarning ( $ "Unable to get { nameof ( type ) } Manager as the Mixed Reality Manager has no Active Profile") ;
871+ return new List < IMixedRealityManager > ( ) ;
805872 }
806873
807- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
874+ if ( type == null )
875+ {
876+ Debug . LogWarning ( "Unable to get managers with a type of null." ) ;
877+ return new List < IMixedRealityManager > ( ) ;
878+ }
808879
809880 var managers = new List < IMixedRealityManager > ( ) ;
810881
@@ -965,7 +1036,11 @@ public bool ManagerExists<T>() where T : class
9651036
9661037 private bool IsCoreManagerType ( Type type )
9671038 {
968- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
1039+ if ( type == null )
1040+ {
1041+ Debug . LogWarning ( $ "Null cannot be a core manager.") ;
1042+ return false ;
1043+ }
9691044
9701045 return type == typeof ( IMixedRealityInputSystem ) ||
9711046 type == typeof ( IMixedRealityTeleportSystem ) ||
@@ -980,7 +1055,12 @@ private bool IsCoreManagerType(Type type)
9801055 /// <param name="manager">return parameter of the function</param>
9811056 private void GetComponentByType ( Type type , out IMixedRealityManager manager )
9821057 {
983- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
1058+ if ( type == null )
1059+ {
1060+ Debug . LogWarning ( "Unable to get a component with a type of null." ) ;
1061+ manager = null ;
1062+ return ;
1063+ }
9841064
9851065 GetComponentByTypeAndName ( type , string . Empty , out manager ) ;
9861066 }
@@ -993,7 +1073,12 @@ private void GetComponentByType(Type type, out IMixedRealityManager manager)
9931073 /// <param name="manager">return parameter of the function</param>
9941074 private void GetComponentByTypeAndName ( Type type , string managerName , out IMixedRealityManager manager )
9951075 {
996- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
1076+ if ( type == null )
1077+ {
1078+ Debug . LogWarning ( "Unable to get a component with a type of null." ) ;
1079+ manager = null ;
1080+ return ;
1081+ }
9971082
9981083 manager = null ;
9991084
@@ -1020,14 +1105,22 @@ private void GetComponentByTypeAndName(Type type, string managerName, out IMixed
10201105
10211106 private void GetComponentsByType ( Type type , ref List < IMixedRealityManager > managers )
10221107 {
1023- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
1108+ if ( type == null )
1109+ {
1110+ Debug . LogWarning ( "Unable to get components with a type of null." ) ;
1111+ return ;
1112+ }
10241113
10251114 GetComponentsByTypeAndName ( type , string . Empty , ref managers ) ;
10261115 }
10271116
10281117 private void GetComponentsByTypeAndName ( Type type , string managerName , ref List < IMixedRealityManager > managers )
10291118 {
1030- if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; }
1119+ if ( type == null )
1120+ {
1121+ Debug . LogWarning ( "Unable to get components with a type of null." ) ;
1122+ return ;
1123+ }
10311124
10321125 for ( int i = 0 ; i < mixedRealityComponentsCount ; i ++ )
10331126 {
0 commit comments